LaTeX Underline: Text and Math
Use \underline{text} to underline a word or a formula. It cannot break across lines, so for longer text load \usepackage[normalem]{ulem} and write \uline{text}, which wraps normally. ulem also gives double (\uuline), wavy (\uwave) and strike-through (\sout) lines.
Underline commands
\underline{text}Underline in text or math; does not break across lines.
- Text mode, no math preview
\uline{text}Underline that wraps across lines —
\usepackage[normalem]{ulem}. - Text mode, no math preview
\uuline{text}Double underline (ulem).
- Text mode, no math preview
\uwave{text}Wavy underline (ulem).
- Text mode, no math preview
\sout{text}Strike-through (ulem).
- Text mode, no math preview
\ul{text}Underline from the soul package; wraps and hyphenates.
\underline{x}Underlined symbol in math.
\underbrace{a+b}_{n}Brace under a formula with a label.
\overline{AB}Line over a formula (the opposite side).
Try it live
Change the formula and the preview redraws as you type. Copy the LaTeX, download a PNG or SVG, copy it for Word, or use Edit here on any example below to load it.
Underline examples
Each result below is drawn from the LaTeX under it. Copy the code, edit it on this page, or open it in the full editor.
Underlined word in math
LaTeX\underline{\text{Answer}}: x = 4Underlined variable
LaTeX\underline{x} \le x \le \overline{x}Common notation for a lower and upper bound.
Double underline
LaTeX\underline{\underline{x = 42}}Nesting
\underlinetwice is how a final answer is often marked.Underbrace with a label
LaTeX\underbrace{1 + 2 + \cdots + n}_{n \text{ terms}} = \frac{n(n+1)}{2}Line segment
LaTeX\overline{AB} \parallel \overline{CD}
In a LaTeX document
These commands work in the text of a .tex document (Overleaf, TeX Live, MiKTeX), not inside math. The box on the right shows what the compiled PDF looks like.
Short underline
LaTeXSubmit by \underline{Friday}.Compiled resultSubmit by Friday.
Long underline that wraps (ulem)
LaTeX\usepackage[normalem]{ulem} % preamble \uline{This sentence is long enough to run onto a second line and stays underlined.}Compiled resultThis sentence is long enough to run onto a
second line and stays underlined.
Which underline command to use
\underline is built in and works in text and math, but the underlined text becomes one unbreakable box: a long phrase runs into the margin instead of wrapping, and the line sits lower under letters with descenders.
For running text use the ulem package. Load it as \usepackage[normalem]{ulem} — without normalem, ulem changes \emph to underline instead of italics. The soul package's \ul also wraps and allows hyphenation, but it is fussy about commands inside its argument.
\usepackage[normalem]{ulem}
\uline{wraps} \uuline{double} \uwave{wavy} \sout{struck}Underlines in math
In math, \underline{…} draws a line under the whole expression and \overline{…} a line over it. For a labelled grouping use \underbrace{…}_{label} or \overbrace{…}^{label}. Underlined links come from hyperref settings, not from \underline.
Common mistakes
\underlinecannot break a line, so long text overflows the margin.\uline(ulem) wraps.Instead of\underline{a very long phrase that should wrap onto the next line}Write\uline{a very long phrase that should wrap onto the next line}Plain ulem redefines
\emphto underline, which changes every emphasis in the document.Instead of\usepackage{ulem}Write\usepackage[normalem]{ulem}ulem commands are for text. Use
\underlineinside math.Instead of\uline{} in a formulaWrite\underline{x + y}
In Overleaf, MathJax and Word
Overleaf and pdfLaTeX
\underlineneeds nothing.\uline,\uuline,\uwaveand\soutneed ulem (load it withnormalem);\ulneeds soul, or soulutf8 with non-ASCII text in pdfLaTeX.MathJax and KaTeX
MathJax and KaTeX support
\underline,\overline,\underbraceand\overbracein math. ulem and soul commands are not available; underline plain text with HTML or Markdown instead.Microsoft Word
Underline text in Word with Ctrl+U. For an underlined or underbraced formula, build it in the editor above and paste it with Copy for Word.
Underline in LaTeX: questions
- How do I underline text in LaTeX?
- Write
\underline{text}for a word or short phrase. For longer text load\usepackage[normalem]{ulem}and use\uline{text}so the line can wrap. - How do I double underline in LaTeX?
- Use
\uuline{text}from ulem in text, or nest\underline{\underline{x}}in math. - Why does my underlined text not wrap to the next line?
\underlineputs its argument in a box that cannot break. Switch to\ulinefrom ulem or\ulfrom soul.- How do I strike through text?
- Load ulem and write
\sout{text};\xout{text}crosses it out with slashes.
Related LaTeX reference
- How to Bold in LaTeX\textbf for bold text, \mathbf for upright bold math, \boldsymbol or \bm for bold italic and Greek symbols.
- Italics in LaTeX\textit and \emph for italic text, \itshape for longer passages, and upright vs italic letters in math mode.
- How to Add a Hyperlink in LaTeXhyperref's \href for linked text, \url for printed addresses, internal links to sections and figures, and link colors.
- LaTeX equation editorSymbol panel, live preview, and PNG, SVG, MathML or Word export.
- All LaTeX reference pagesSymbols, math structures and text formatting in one list.
Have the formula as a picture?
Paste a screenshot or photo of the equation and get its LaTeX, ready to copy or open in the editor.
Convert an image to LaTeX