# Underscore(A_B) in LaTeX

The underscore character is usually used to write a subscript in Math mode in latex, so it is not possible to print this character directly in the document. So you need to use the \textunderscore command to print this or you can use \_ this too. And you can use this command in either math mode or text mode.

Symbol Underscore
Type of symbol Character
Package (requirement) No
Argument No
Latex command \textunderscore
Example A\textunderscore B → A_B
\documentclass{article}
\begin{document}
% Use underscore in text mode
word\textunderscore one \textunderscore two \\[6pt]
A\textunderscore B\textunderscore C \\[6pt]
Latex\textunderscore Help\\[8pt]
% use \_ to print underscore
word\_one\_two\\[6pt]
Samp\_Dist\_Corr
\end{document}

Output :

Below are some examples using Math mode. In the case of Math Mode, you will see some differences in the output.

\documentclass{article}
\begin{document}
% Use underscore in math mode
$$word\textunderscore one \textunderscore two$$
$$A\textunderscore B\textunderscore C$$
$$Latex\textunderscore Help$$
% use \_ to print underscore
$$word\_one\_two$$
$$Samp\_Dist\_Corr$$
\end{document}

Output :

## Using tt font with underscores

You can use tt font to make the output look better. For this, you can use \texttt{arg}, the default command of latex. And you can use this command in either math mode or text mode.

\documentclass{article}
\begin{document}
% use tt font
\texttt{word\_one\_two}\\[6pt]
\texttt{Samp\_Dist\_Corr}\\[6pt]
\texttt{Latex\_Help}
\end{document}

Output :

If you want to use more fonts then the best practice would be if you use it {\_}. It is comfortable with all fonts.

\documentclass{article}
\begin{document}
$$\texttt{Latex{\_}help}$$
$$\texttt{Word{\_}One{\_}Two}$$
\end{document}

Output :