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}
    text ―

    Underline in text or math; does not break across lines.

  • \uline{text}
    Text mode, no math preview

    Underline that wraps across lines — \usepackage[normalem]{ulem}.

  • \uuline{text}
    Text mode, no math preview

    Double underline (ulem).

  • \uwave{text}
    Text mode, no math preview

    Wavy underline (ulem).

  • \sout{text}
    Text mode, no math preview

    Strike-through (ulem).

  • \ul{text}
    Text mode, no math preview

    Underline from the soul package; wraps and hyphenates.

  • \underline{x}
    x ―

    Underlined symbol in math.

  • \underbrace{a+b}_{n}
    a + b ⏟ n

    Brace under a formula with a label.

  • \overline{AB}
    A B ―

    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.

Templates

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

    Answer ― : x = 4
    LaTeX
    \underline{\text{Answer}}: x = 4
  • Underlined variable

    x ― ≤ x ≤ x ―
    LaTeX
    \underline{x} \le x \le \overline{x}

    Common notation for a lower and upper bound.

  • Double underline

    x = 42 ― ―
    LaTeX
    \underline{\underline{x = 42}}

    Nesting \underline twice is how a final answer is often marked.

  • Underbrace with a label

    1 + 2 + ⋯ + n ⏟ n  terms = n ( n + 1 ) 2
    LaTeX
    \underbrace{1 + 2 + \cdots + n}_{n \text{ terms}} = \frac{n(n+1)}{2}
  • Line segment

    A B ― ∥ C D ―
    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

    LaTeX
    Submit by \underline{Friday}.
    Compiled result

    Submit 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 result

    This 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.

LaTeX
\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

  • \underline cannot 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 \emph to underline, which changes every emphasis in the document.

    Instead of
    \usepackage{ulem}
    Write
    \usepackage[normalem]{ulem}
  • ulem commands are for text. Use \underline inside math.

    Instead of
    \uline{} in a formula
    Write
    \underline{x + y}

In Overleaf, MathJax and Word

  • Overleaf and pdfLaTeX

    \underline needs nothing. \uline, \uuline, \uwave and \sout need ulem (load it with normalem); \ul needs soul, or soulutf8 with non-ASCII text in pdfLaTeX.

  • MathJax and KaTeX

    MathJax and KaTeX support \underline, \overline, \underbrace and \overbrace in 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?
\underline puts its argument in a box that cannot break. Switch to \uline from ulem or \ul from soul.
How do I strike through text?
Load ulem and write \sout{text}; \xout{text} crosses it out with slashes.

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