I am trying to add a table of contents for my LaTex document. The issue I am having is that this line:
\subsubsection{The expectation of \(X^2\)}
Causes an error in the file that contains the table of contents
\contentsline {subsubsection}{\numberline {1.2.3}
The expectation of \relax $X^2\relax \GenericError { }{
LaTeX Error: Bad math environment delimiter}{
See the LaTeX manual or LaTeX Companion for explanation.}
{Your command was ignored.\MessageBreak Type I <command> <return>
to replace it with another command,\MessageBreak or <return> to
continue without it.}}{5}
Which causes the document not to be generated.
Does anyone have a solution to having maths in sections while still having the table of contents
There are a few ways to enter math mode, however the most common is $.... $, where the text within the dollar signs is in the math mode environment. You have already been using math mode unknowingly by using the \begin{equation} and \end{equation} commands.
Display math mode Use one of these constructions to typeset maths in display mode: \[...\] \begin{displaymath}...\end{displaymath} \begin{equation}...\end{equation}
You should use the Amsmath inline math delimiter $
instead of \(
and \)
. Thus:
\subsubsection{The expectation of $X^2$}
Note: be sure to remove the currently generated .toc
file first, otherwise the error will not go away.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With