Underline text in LaTeX

Use \underline{} to underline text in LaTeX.

Quick answer

latex
This is \underline{underlined text} in LaTeX.

The \underline command

\underline{} is the built-in LaTeX command for underlining. It works in both text mode and math mode with no additional packages.

latex
\documentclass{article}
\begin{document}

This is text \underline{and parts of it} are underlined.

\end{document}
Note: The built-in \underline does not break across line endings. If your underlined text is long, it will overflow instead of wrapping. Use the ulem package for line-breaking underlines.

Line-breaking underlines with ulem

The ulem package provides underlines that wrap across lines, plus dashed and dotted variants.

latex
\usepackage{ulem}  % in preamble

\uline{This underlined text will break across lines automatically.}

\dashuline{Dashed underline}

\dotuline{Dotted underline}

Important: ulem redefines \emph to underline instead of italicise. Add \usepackage[normalem]{ulem} to prevent this.

Underline in math mode

latex
\begin{equation}
  \underline{x + y} = z
\end{equation}

Combining underline with bold or italic

latex
\textbf{\underline{Bold and underlined}}
\textit{\underline{Italic and underlined}}

Related topics