Underlined text in LaTeX
\underline{...} draws a line under text or maths; it is built into LaTeX, but the underlined text cannot break across lines.
LaTeX command
\underline{underlined text}Not the symbol you meant? Draw it to find the command →
Typing up handwritten notes? Convert a whole page of handwriting to LaTeX →
\underline works in text and in maths alike, which makes it the quick choice for a word, a label or an answer. Its weakness is that the underlined text is one unbreakable box: a long underlined phrase runs into the margin instead of wrapping, and the line sits lower under words with descenders such as g and y.
For underlining that wraps, use the ulem package's \uline or the soul package's \ul. ulem also has \uuline for a double line, \uwave for a wavy one and \sout for crossing out. Load ulem with the normalem option, as below: without it, ulem changes \emph to underline everywhere in the document.
Many style guides prefer italics or bold to underlining in printed text, where underlining comes from the typewriter. In maths, \underline{x} is a notation in its own right, and \underbrace puts a labelled brace under a group of terms.
Underlining that breaks across lines (ulem)
Load ulem with normalem so \emph keeps its italics, then use \uline for a wrapping underline, or \sout to strike text through.
\usepackage[normalem]{ulem}\uline{a long underlined phrase}\sout{struck out}Other forms
\uline{underlined text}breaks across lines, ulem\ul{underlined text}breaks across lines, soul\underline{x}underline in mathsExamples
$\underline{\text{underlined text}}$an underline
$\underline{x} + \underline{y}$underlined letters in maths
$\underline{\underline{x = 4}}$a double underline for a final answer
$\underbrace{a + b + c}_{\text{sum}}$a labelled brace under terms
Tips and common mistakes
- Use
\underlinefor short text; it cannot wrap onto the next line. - For long underlined text, use ulem's
\ulineor soul's\ul. - Load ulem as
\usepackage[normalem]{ulem}, or\emphturns into underlining. - Nest
\underlinefor a double underline, or use ulem's\uuline. - Prefer
\emphor\textbffor emphasis in printed text.
Working from handwritten notes?
LatexNotes turns a photo or PDF of handwritten mathematics into LaTeX, graphs and all. It is built with real pdflatex before you see it, and the .tex file is yours to edit or take to Overleaf. Free to try, no sign-up.
See how handwriting to LaTeX works, step by step, or go from GoodNotes to LaTeX if you write on an iPad (Notability works the same way).
Convert your maths to LaTeX →FAQ
How do I underline text in LaTeX?
Write \underline{your text}. It works in text and maths.
How do I underline text that breaks across lines?
Use the ulem package's \uline{...}, loaded with \usepackage[normalem]{ulem}, or soul's \ul{...}.
How do I double underline in LaTeX?
Nest \underline twice, \underline{\underline{x}}, or use ulem's \uuline.
Why did my \emph text become underlined?
ulem was loaded without normalem. Load it as \usepackage[normalem]{ulem}.