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.

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