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}$
Result
The compiled example

Open in the editor

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.

xi2an+12k∑k=1nk2x_i^2 \qquad a_{n+1}^{2k} \qquad \sum_{k=1}^{n} k^2

Open this formula in the editor

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.

e−x2ank22n(x2)3e^{-x^2} \qquad a_{n_k} \qquad 2^{2^n} \qquad (x^2)^3

Open this formula in the editor

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.

vmaxTinxnew=xold+1v_{\text{max}} \qquad T_{\mathrm{in}} \qquad x_{\text{new}} = x_{\text{old}} + 1

Open this formula in the editor

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}}
\]
Result
The compiled example

Open in the editor

Pitfalls

Compiled with pdfLaTeX from TeX Live 2023.

Related pages