Mathematics in LaTex table of contents

I am trying to add a table of contents for my LaTex document. The problem I am facing 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}

Because of what the document is not created.

Does anyone have a decision to have math in sections while still having a table of contents

+5
source share
3 answers

Instead \(, \)you should use the Amsmath math limiter $. Thus:

\subsubsection{The expectation of $X^2$}

Note: be sure to delete the file .tocthat is currently created , otherwise the error will not disappear.

+7
source

\(... \) , ( ) fixltx2e. LaTeX , - .

( , , \( \) "" , , , , fixltx2e .)

+5

Could you try adding the $ signs around the expression again? What error are you getting?

+1
source

All Articles