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