Over/under decorations

In mathematics you stack all sorts of things above and below symbols: bars and braces that run across a whole expression, hats and arrows that stretch to the width of what they cover, and small accents that stay the size of a single letter. They look related, but whether or not a mark *stretches* decides which one you reach for. This page sorts them into three groups — (1) lines and braces drawn over or under an expression, (2) stretchy accents that widen to fit, and (3) fixed-width accents sized for one symbol — and then shows how amsmath’s \overset / \underset place an arbitrary symbol above or below another.

Lines and braces over an expression

First, the commands that draw a horizontal line or brace across the whole argument. \overline{…} puts a line above its argument and \underline{…} puts one below; both are part of standard LaTeX and the line stretches to the width of the contents. \overline is common for a complement or a complex conjugate, and the rule from \underline is positioned to clear any descenders (letters such as y or g that hang below the baseline).

latex
\[
  \overline{a + b} = \overline{a} + \overline{b}, \qquad
  \underline{x + y}
\]

Here the left side draws a single line across the whole of a+b, while the right side sets a short line over each letter (as noted below, for a single letter \bar is sometimes more natural than \overline). \underline{x+y} draws a line beneath x+y, kept clear of the descender on y. Bars and underlines are among the few decorations that nest cleanly, so a double line such as \overline{\overline{z}} sets without trouble.

For braces, use \overbrace{…} and \underbrace{…}. These are standard LaTeX too, and the horizontal brace stretches to the full width of the contents. Their handy feature is that you can attach a label: because the brace behaves like a script on the expression, a superscript ^ places a label outside the upper brace — \overbrace{…}^{label} — and a subscript _ places one outside the lower brace, as in \underbrace{…}_{label}.

latex
\[
  \underbrace{1 + 2 + \cdots + n}_{n \text{ 個の項}}
  = \frac{n(n+1)}{2}
\]

This stretches a full-width brace below 1 + 2 + … + n, with the label “n terms” centered beneath it. Likewise \overbrace{x + x + \cdots + x}^{k} runs a brace above the sum with the term count k set above it. When a label contains words or Japanese, wrap it in \text{…} (from amsmath), since you are inside math mode.

Stretchy (wide) accents

Next come accents that stretch to the width of their argument. The chief ones are \widehat{…} (a wide hat) and \widetilde{…} (a wide tilde). Where \hat{x} is a small caret over one letter, \widehat{xyz} spreads a caret across the whole of xyz; \widetilde behaves the same way, laying a large wavy line over the entire expression. Both are available in standard LaTeX.

There is a limit to the stretching, though. \widehat and \widetilde pick the nearest fit from a few predrawn sizes, so over a very long expression the hat may not widen enough and can look a little awkward. When that happens, consider \overline or one of the line/arrow forms such as \overrightarrow, described below.

There are commands that lay an arrow over the argument as well. \overrightarrow{…} draws a rightward arrow and \overleftarrow{…} a leftward one across the argument, both stretching to fit (standard LaTeX). The double-headed \overleftrightarrow{…}, and the under-side forms \underrightarrow / \underleftarrow / \underleftrightarrow, require the amsmath package. For vector notation these stretchy arrows suit things like the directed segment over AB.

A common trap here is \vec. \vec{a} is a small, fixed arrow sized for one symbol and does not stretch. So \vec{AB} puts a small arrow effectively over B rather than across both A and B, and does not read as a directed segment. To run an arrow from A to B across the whole expression, use \overrightarrow{AB} instead.

latex
\[
  \widehat{x + y} \neq \hat{x} + \hat{y}, \qquad
  \vec{a} \quad \text{vs.} \quad \overrightarrow{AB}
\]

In this example the left side sets a wide caret over the whole of x+y with \widehat{x+y}, while \hat{x} puts a small caret over the single letter x. The right side places \vec{a}’s small fixed arrow beside the arrow of \overrightarrow{AB}, which stretches across the full width of AB, to show the contrast.

Fixed-width single-symbol accents

The third group is the fixed-width accents placed mostly over a single letter: \dot for a derivative, \ddot for a second derivative, \bar for a mean or conjugate, \hat for an estimator, \tilde for an approximation — the marks that turn up constantly in science and engineering. All are standard LaTeX; applied to several letters they do not stretch, but sit centered at the size of a single symbol.

CommandWhat it placesStretches?
\hatA caret (circumflex)Fixed; wide version is \widehat
\tildeA tilde (wave)Fixed; wide version is \widetilde
\barA short bar (macron)Fixed; for a whole expression use \overline
\vecA small rightward arrowFixed; wide arrow is \overrightarrow
\dotA single dotFixed
\ddotTwo dots (dieresis)Fixed; \dddot/\ddddot need amsmath
\acuteAn acute accentFixed
\graveA grave accentFixed
\checkA check (háček, ˇ)Fixed
\breveA breve (˘)Fixed
\mathringA small ring (˚)Fixed
latex
\[
  \dot{x}, \quad \ddot{x}, \quad \bar{x}, \quad \hat{p},
  \quad \tilde{a}, \quad \vec{v}, \quad \check{s}
\]

These set, respectively, one and two dots over x, a short bar over x, a small caret over p, a tilde over a, a small rightward arrow over v, and a v-shaped check over s. Note that putting an accent on i or j collides with its own dot, so the tradition is to use the **dotless \imath / \jmath**: writing \hat{\imath}, for instance, sets just the caret over a dotless i.

Placing any symbol above or below (\overset / \underset)

The commands so far placed fixed ornaments — lines, braces, accents. When you want an arbitrary symbol or expression set small above or below another symbol, use \overset{above}{base} and \underset{below}{base} from the amsmath package. \overset{a}{b} sets a small above b, and \underset{a}{b} sets a small below b. The second argument is the base; the first is what you add to it.

latex
\[
  A \overset{f}{\longrightarrow} B, \qquad
  X \underset{n \to \infty}{\longrightarrow} x, \qquad
  \overset{!}{=}
\]

Here \overset{f}{\longrightarrow} sets the map name f small above the arrow, and \underset{n\to\infty}{\longrightarrow} adds the limiting condition below it. \overset{!}{=} is the “equal by requirement” notation, an exclamation mark over an equals sign. Unlike the fixed accents of the previous section, you may choose freely what goes above or below — that is the point of these commands.

To add material both above and below, nest them as \overset{a}{\underset{b}{X}}. Note the difference from scripts: ^ and _ sit at the right side of a symbol, whereas \overset / \underset place material directly above and below. Operators that already take limits above and below, such as sums and \lim, have their own machinery, covered on a separate page.

Choosing well, and pitfalls

Finally, the points that trip people up. First, the **difference between \bar and \overline**. \bar{x} is a fixed-width accent the size of one letter, whereas \overline{x} is a rule that stretches to the width of its contents. The LaTeX2e reference states outright that “\overline differs from the accent command \bar.” Use \bar{x} for the mean of a single symbol and \overline{x+y} for a line across several terms.

Second, mixing up \hat (fixed) with \widehat (stretchy). For a single symbol like the estimator \hat{\beta} use \hat; to cover a whole expression like \widehat{f(x)} use \widehat. The pairs \tilde / \widetilde and \vec / \overrightarrow follow the same fixed-versus-stretchy split.

Third, double accents do not stack cleanly. Layering two accents, as in \hat{\vec{x}}, tends to leave the upper mark floating, too high, or off-center (about the only marks that nest comfortably are \overline and \underline). If you merely want more dots, use \ddot or amsmath’s \dddot / \ddddot; for genuinely layered marks, build them explicitly with \overset or rely on a dedicated package.

  • Small, over one letter → a fixed accent (\hat, \bar, \dot, \vec, …).
  • Covering a whole expression → a stretchy form (\widehat, \widetilde, \overline, \overrightarrow).
  • Marking a range with a brace\overbrace{…}^{…} / \underbrace{…}_{…}.
  • Any symbol above or below → amsmath’s \overset{…}{…} / \underset{…}{…}.
  • Accenting i or j → build on the dotless \imath / \jmath.