# [OS X TeX] Writing an Underscore in LaTeX

Thu Jul 28 18:58:53 CEST 2011

I wrote:

> The solution should be something like:
>
> - select a font which contains an underscore
> - create a command which sets the character underscore as the glyph from the font
> - (optional?) set a command which adds special information to the .pdf so that your screenreader says something which makes sense.

With help from Rich Zaccone on the Texhax mailing list and some Google searching, I can now report that the solution is to:

add the following to the pre-amble:

\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{textcomp}

and then prefix _ with \string:

\begin{description}
\item[HKEY\string_USERS] For storing blah blah
\item[HKEY\string_CLASSES\string_ROOT]
\item[HKEY\string_CURRENT\string_CONFIG]
\end{description}

Full file:

\documentclass{article}
\nonstopmode

\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{textcomp}

\begin{document}
\title{THE WINDOWS REGISTRY}
\maketitle

\section{The Registry Structure}

Windows uses the Registry to store its settings. The registry is a central place blah, blah, blah

Some of the keys in the registry are:

\begin{description}
\item[HKEY\string_USERS] For storing blah blah
\item[HKEY\string_CLASSES\string_ROOT]
\item[HKEY\string_CURRENT\string_CONFIG]
\end{description}

\end{document}

William

--