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!

8

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}
  • 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. :) – loved.by.Jesus Jun 6 '18 at 12:04
  • @loved.by.Jesus How much protection a fragile argument needs depends on the actual usage. – Steven B. Segletes Jun 6 '18 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. – Steven B. Segletes Jun 6 '18 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! – loved.by.Jesus Jun 6 '18 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.