I know a number of ways to fix this (e.g. \usepackage[T1]{fontenc}), but I want to understand what's happening in the following example.

\$ \% \& \{ \} \_ \# \textbackslash \\
\ttfamily \$ \% \& \{ \} \_ \# \textbackslash \\
\verb+$ % & { } _ # \ +

escaped characters

  • Why does attempting to obtain a \ttfamily brace, underscore or backslash result in the substitution of the ordinary roman symbol? The glyphs are clearly not missing, because verbatim mode can access them.

  • How exactly is verbatim mode accessing these glyphs?

  • Deleting the braces and the backslash, so that the underscore is the only remaining 'problem' character eliminates the font warnings, despite the fact that a substitution is still taking place. Why is this?


\verb and verbatim assume the font has these characters in their ascii positions and locally makes the characters be catcode 12 (like punctuation) with no special defintion.

\textbackslash (and friends) is defined to be a encoding-specific command and (to fake an air of sanity over the original TeX encodings) LaTeX assumes that OT1 encoding is the encoding of cmr10 which does not have a backslash char. So in OT the default definition is used (which uses the math fonts). \ttfamily changes the family but not the encoding and so in that case you get the OT1 definition even though the cmtt font is really encoded differently.

Things work better in T1 because the fonts labelled as T1 encoded do in fact have the same encoding.

\_ is different because \textunderscore has a default definition that doesn't use a font at all but a horizontal rule.


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.