[texhax] the Underscore

Heiko Oberdiek heiko.oberdiek at googlemail.com
Tue Jun 28 08:09:30 CEST 2011

On Tue, Jun 28, 2011 at 06:40:42AM +0530, E. Krishnan wrote:

> Krishnan
> On Fri, 24 Jun 2011, Heiko Oberdiek wrote:
> >On Fri, Jun 24, 2011 at 09:43:33AM +0100, Paul Stanley wrote:
> >
> >>Anyone know the macro for the underscore?
> >>I tried \_ but whatever that appears in the PDF is invisible to the
> >>screen reader.
> In text mode, \textunderscore produces an underscore.

\_ is defined in latex.ltx as:

    \ifmmode\nfss at text{\textunderscore}\else\textunderscore\fi

Thus it's calling \textunderscore and can also be used in math mode.

And \textunderscore is defined as rule:

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

The encoding OT1 (default in LaTeX 2.09) does not change this,
although cmtt would contain such glyph. The other families (rm, sf)
misses it. Thus it's a shortcoming of OT1.

T1 encoding (t1enc.def) uses a glyph of the font:


Then it depends on the font, what is used. Usually it's indeed a glyph,
but it could be a virtual font where this character is drawn as rule
again (e.g. package ae, font encoding T1, \rmfamily).

If someone wants to test this, here is a small pdflatex example
for playing:


No font is embedded, the underscore is drawn as rule.
A font glyph is used without package `ae' or using \texttt
instead of \textrm.

Yours sincerely
  Heiko Oberdiek

More information about the texhax mailing list