Fair warning: I know approximately zero things about fonts and font encodings, so this is perhaps another naive question on my part.

Recently, I asked about the behavior of \detokenize{_}, as one needs to specify \usepackage[T1]{fontenc} for it to work as expected.

Apparently, the default font encoding for LaTeX is OT1, and there is no _ in OT1. Thus, for something like \detokenize{_} or \string_ to render as _ and not ˙, one must specify T1 font encoding.

Yet, as @egreg points out in a comment on that question and as we all are likely aware, \_ renders as _ in LaTeX without having to do anything to the font encoding.

So, my question is how can LaTeX actually render \_ as _ if there is no _ in OT1, which is the default encoding?


plain.tex includes

\def\_{\leavevmode \kern.06em \vbox{\hrule width.3em}}

latex.ltx includes

  \leavevmode \kern.06em\vbox{\hrule\@width.3em}}



but t1enc.def includes


so that the actual underscore from the font is used if T1 is loaded. In that case, the \DeclareTextSymbol from t1enc.def overrides the default meaning of \textunderscore from latex.ltx and, hence, of \_. If T1 is not loaded, of course, and OT1 is used, the default definition is not overridden and TeX essentially fakes the underscore when \textunderscore or \_ is typeset.

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.