Exponents and subscripts in LaTeX (superscript, index)
In math mode ^ raises the next character and _ lowers it: x^2, a_1. Put braces around anything longer than one character, as in x^{10} or a_{ij}.
Preamble
The snippets on this page need these lines before \begin{document}:
\usepackage{mathtools}Superscript and subscript
Without braces only the next character moves: x^10 prints x to the power of 1, followed by a normal 0. A whole formula can stand in the braces.
$x^2$, $a_1$, $x^{10}$, $a_{ij}$, $2^{n+1}$, $x^{-1}$Both on the same symbol
A symbol can carry a subscript and a superscript at once. The order does not matter: x_i^2 and x^2_i print the same.
\[
x_i^2 \qquad a_{n+1}^{2k} \qquad \sum_{k=1}^{n} k^2
\]Change the formula
The preview is drawn in your browser by KaTeX, which knows the common math commands. The editor compiles the formula with pdfTeX.
Nested exponents and subscripts
An exponent can have its own exponent or subscript when it stands in braces. Each level is set smaller, down to a third size.
\[
e^{-x^2} \qquad a_{n_k} \qquad 2^{2^n} \qquad (x^2)^3
\]Change the formula
The preview is drawn in your browser by KaTeX, which knows the common math commands. The editor compiles the formula with pdfTeX.
Words as subscripts
Letters in math mode are italic and stand for variables. A word such as "max" or "in" is set upright with \text{...} from amsmath or with \mathrm{...}.
\[
v_{\text{max}} \qquad T_{\mathrm{in}} \qquad x_{\text{new}} = x_{\text{old}} + 1
\]Change the formula
The preview is drawn in your browser by KaTeX, which knows the common math commands. The editor compiles the formula with pdfTeX.
Indices in front of a symbol
An empty group {} in front gives the indices something to attach to. \prescript{above}{below}{symbol} from mathtools does the same and right-aligns the two indices.
\[
{}^{14}_{6}\mathrm{C}
\qquad
\prescript{14}{6}{\mathrm{C}}
\]Pitfalls
x^2^3stops with Double superscript anda_1_2with Double subscript. Say what you mean with braces:x^{2^3}or{x^2}^3.- A prime is a superscript as well:
f'^2works, butf^2'stops with the double superscript error. ^and_in normal text stop with Missing $ inserted. For raised text outside formulas see Superscript and subscript in text in LaTeX; a literal underscore is\_.
Compiled with pdfLaTeX from TeX Live 2023.
Related pages
- Error Double superscript
- Error Double subscript
- How-to Superscript and subscript in text in LaTeX
- How-to Text in math mode in LaTeX
- Package
mathtools