Symbols above and below in LaTeX (overset, underset)
\overset{top}{base} sets something small above a symbol and \underset{bottom}{base} sets it below; both come from amsmath, and \stackrel is the older core LaTeX version for relations.
LaTeX command
\overset{\text{def}}{=}Not the symbol you meant? Draw it to find the command →
Typing up handwritten notes? Convert a whole page of handwriting to LaTeX →
The first argument is the small item and the second is the symbol it goes on: \overset{?}{=} prints an equals sign with a question mark over it. The result keeps the kind of the base symbol, so an equals sign with something over it is still spaced like an equals sign.
\stackrel{top}{base} does the same for a relation and is built into LaTeX, so it works without amsmath; it always treats the result as a relation. Nest the two amsmath commands for items above and below at once: \overset{a}{\underset{b}{=}}.
Common uses are a definition, , a step that needs checking, , and a reason over a step in a proof, . For a definition, mathtools also offers \coloneqq, which prints := with the colon centred.
Other forms
\underset{x}{\min}text under a symbol\stackrel{?}{=}above a relation, core LaTeX\overset{a}{\underset{b}{=}}above and below togetherExamples
$f(x) \overset{\text{def}}{=} x^2 + 1$equal by definition
$a \overset{?}{=} b$a questioned equality
$X \overset{d}{=} Y$equal in distribution
$x_n \overset{P}{\to} x$convergence in probability
$A \stackrel{(2)}{=} B$a step labelled with \stackrel
$\overset{a}{\underset{b}{=}}$above and below together
Tips and common mistakes
- The small item comes first:
\overset{top}{base},\underset{bottom}{base}. - Wrap words in
\text, as in\overset{\text{def}}{=}, so they are upright. \oversetand\undersetneed amsmath;\stackrelis built in and is only for relations.- For a long arrow with a label, use
\xrightarrowinstead: it stretches,\oversetdoes not. - For a single letter with an accent, use the accent commands,
\hat,\bar,\vec, rather than\overset.
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 put a symbol above another in LaTeX?
Use \overset{top}{base}, for example \overset{?}{=} for an equals sign with a question mark over it.
How do I put text under a symbol?
Use \underset{bottom}{base}, for example \underset{x}{\max}.
What is the difference between \overset and \stackrel?
Both put something over a symbol. \stackrel is built in and always spaced as a relation; \overset needs amsmath and keeps the base's own spacing.
How do I write 'equal by definition'?
Write \overset{\text{def}}{=}, or use \coloneqq from mathtools for :=.