In this tutorial, you will learn how to print underscore in a LaTeX document with different methods. You can’t print this by using _ directly in your source code, because this symbol is used for superscript.
To get an underscore in LaTeX text mode, you can use the default command \textunderscore or <\_>. You can also use \_ but I recommend using this <\_>.
\documentclass \begin One\_two\_three Underscore<\_>in<\_>text Code\textunderscore Speedy \endOutput:
For math mode, you use the text mode commands <\_>or \textunderscore to print the underscore (Using <\_>is recommended in math mode). You can also use the \verb|| command to print anything without compiling that.
\documentclass \begin $$ One\_two\_three $$ $$ Underscore<\_>in<\_>mathmode $$ $$ Code\textunderscore Speedy $$ $$ \verb|A_B| $$ \endOutput:
If you want an underscore with a custom size, you can use the \underline<\hspace<
Output: