3

I want to use the symbol \angle at a section title but I get an error message:

! Illegal parameter number in definition of \reserved@a. to be read again $ l.9 \section{Second section: $\angle$ }

See the MWE:

\documentclass{article}

\begin{document}
    This is my document.

    \section{First section: $S=\sin(\alpha)$}
    Use $\angle$ at normal text.

    \section{Second section: $\angle$ } %Here the error occurs
    Text at second section.

\end{document}

So the question is, how may I use the \angle symbol in a section title?

Thanks!

2 Answers 2

10

You must $\protect\angle$ in the section heading. What this means is that \angle is a "fragile" command and must be protected from premature expansion.

\documentclass{article}

\begin{document}
    This is my document.

    \section{First section: $S=\sin(\alpha)$}
    Use $\angle$ at normal text.

    \section{Second section: $\protect\angle$ } %Here the error occurs
    Text at second section.

\end{document}

enter image description here

Alternately, you can \robustify\angle once in the preamble (with etoolbox). Then, it need not be protected.

\documentclass{article}
\usepackage{etoolbox}
\robustify\angle
\begin{document}
    This is my document.

    \section{First section: $S=\sin(\alpha)$}
    Use $\angle$ at normal text.

    \section{Second section: $\angle$ } %Here the error occurs
    Text at second section.

\end{document}
4
  • Formidable answer. In my MWE both methods worked, but in my real document the first one with \protect was still flawed. Nevertheless, \robustify fixed the error completely. Thanks for quickly answering. :) Jun 6, 2018 at 12:04
  • @loved.by.Jesus How much protection a fragile argument needs depends on the actual usage. Jun 6, 2018 at 12:08
  • 1
    @loved.by.Jesus Here's a useful description: texfaq.github.io/FAQ-protect.html. Also many questions on this stackexchange site, as well, can be searched. Jun 6, 2018 at 12:15
  • @StevenBSegletes Great! Actually, I had not enough with the answer. I wanted to understand the mechanism behind—I will read it, for sure! Jun 6, 2018 at 12:23
2

The accepted answer was correct at the time it was written (2018) but for LaTeX releases from 2019 on, this is not needed as \angle along with many other commands is now robust so \protect is not needed (although does no harm).

The test document in the question runs without error in current releases, so if readers come here as they get that error, a better answer is to update the TeX system.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .