16.5 Over- or under math

LaTeX provides commands for putting lines, braces, and arrows over or under math material.


Underline math. For example: \underline{x+y}. The line is always completely below the text, taking account of descenders, so in \(\underline{y}\) the line is lower than in \(\underline{x}\). As of approximately 2019, this command and others in this section are robust; before that, they were fragile (see \protect).

The package ulem (https://ctan.org/pkg/uelem) does text mode underlining and allows line breaking as well as a number of other features. See also \hrulefill & \dotfill for producing a line for such things as a signature or placeholder.


Put a horizontal line over math. For example: \overline{x+y}. This differs from the accent command \bar (see Math accents).


Put a brace under math. For example: (1-\underbrace{1/2)+(1/2}-1/3).

You can attach text to the brace as a subscript (_) or superscript (^) as here:


The superscript appears on top of the expression, and so can look unconnected to the underbrace.


Put a brace over math. For example:
\overbrace{x+x+\cdots+x}^{\mbox{\(k\) times}}.


Put a right arrow over math. For example: \overrightarrow{x+y}.


Put a left arrow over math. For example: \overleftarrow{a+b}.

The package mathtools (https://ctan.org/pkg/mathtools) adds an over- and underbracket, as well as some improvements on the braces.

Unofficial LaTeX2e reference manual