[texhax] Use of \symbol{`\_} versus \symbol{'137} to produce \verb+_+ in moving arguments.
Ulrike Fischer
news3 at nililand.de
Wed Feb 25 15:33:33 CET 2015
Am Mon, 23 Feb 2015 15:02:51 -0500 schrieb Beuthe, Thomas:
> This one does not work:
> \chapter{\texttt{A\symbol{`\_}B}}
> and this one works:
> \chapter{\texttt{A\symbol{'137}B}}
> So I seem to have solved my problem, but I would like
> to know why.
Because \_ is a robust command but \symbol is not and when wandering
to the header you get something like "\char`\protect\_\relax" which
obviously can explode if \protect is something the primitive \char
doesn't expect at this place.
Use \protect\symbol{`\_} to avoid such problems. Or switch to
T1-encoding to get rid of the whole problem:
\documentclass[12pt]{report}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage[T1]{fontenc}
\begin{document}
\tableofcontents
\chapter{\texttt{A\_B A\textunderscore B}}
\verb+ A_B+
abc a\newpage abc
\end{document}
--
Ulrike Fischer
http://www.troubleshooting-tex.de/
More information about the texhax
mailing list