3

This seems to me like a possibly common problem, the solution of which is probably already been posted somewhere, unfortunately I'm not quite sure what key words i should use to find it.

Anyway, to the problem: Something like this

\subsubsection{Spin-orbit coupling \( ciao \) }

will not usually pose a problem. However when i try to create a table of content with the

\tableofcontents

command i get the following error:

\contentsline {subsubsection}{\numberline {5.1.2}Spin-orbit coupling \relax $ ciao \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.}}{8}{subsubsection.5.1.2}

The table of contents seems to not be the problem by itself, because when i do not use commands as the one shown above everything works fine. Strangely enough, i can actually solve the problem by using instead of \( stuff \) the alternative $stuff$. Now, is this supposed to work this way? or is it some sort of bug? or (more likely) am i doing something wrong?

jub0bs
  • 58,916
glS
  • 546

1 Answers1

2

LaTeX's commands \( and \) are fragile commands per default which means they can cause an error in moving arguments such as sectioning commands in combination with \tableofcontents. The package fixltx2e fixes this, as Will Robertson mentions in his answer to Are \( and \) preferable to dollar signs for math mode?

Alternatively you can load mathtools (thanks to @daleif), load etoolbox and robustify them yourself

\usepackage{etoolbox}
\robustify\(
\robustify\)

or protect them manually:

\subsubsection{Spin-orbit coupling \protect\( ciao \protect\) }

See also What is the difference between Fragile and Robust commands?

cgnieder
  • 66,645
  • 1
    mathtools also robustify them, using the ideas from fixltx2e but without loading the extra stuff that may break packages. – daleif May 10 '13 at 09:14