### How to use the underscore character

The underscore character `_` is ordinarily used in TeX to indicate a subscript in maths mode; if you type `_` in the course of ordinary text, TeX will complain. If you’re writing a document which will contain a large number of underscore characters, the prospect of typing `\``_` (or, worse, `\``textunderscore`) for every one of them will daunt most ordinary people.

Moderately skilled macro programmers can readily generate a quick hack to permit typing `_` to mean ‘text underscore’. However, the code is somewhat tricky, and more importantly there are significant points where it’s easy to get it wrong. There is therefore a package underscore which provides a general solution to this requirement.

There is a problem, though: OT1 text fonts don’t contain an underscore character, unless they’re in the typewriter version of the encoding (used by fixed-width fonts such as `cmtt`). So either you must ensure that your underscore characters only occur in text set in a typewriter font, or you must use a fuller encoding, such as T1, which has an underscore character in every font.

If the requirement is only for occasional uses of underscores, it may be acceptable to use the following construct:

>     \def\us{\char`\_}
>     ...
>     \texttt{create\us process}

The construction isn’t in the least robust (in the normal English sense of the word), but it is robust under expansion (i.e., the LaTeX sense of the word); so use it with care, but don’t worry about section headings and the like.

`underscore.sty`
  macros/latex/contrib/misc/underscore.sty

This question on the Web: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=underscore