W3cubDocs

/LaTeX

Subscripts & superscripts

Synopsis (in math mode or display math mode), one of:

base^exp
base^{exp}

or, one of:

base_exp
base_{exp}

Make exp appear as a superscript of base (with the caret character, ^) or a subscript (with underscore, _).

In this example the 0’s and 1’s are subscripts while the 2’s are superscripts.

\( (x_0+x_1)^2 \leq (x_0)^2+(x_1)^2 \)

To have the subscript or superscript contain more than one character, surround the expression with curly braces, as in e^{-2x}. This example’s fourth line shows curly braces used to group an expression for the exponent.

\begin{displaymath}
  (3^3)^3=27^3=19\,683
  \qquad
  3^{(3^3)}=3^{27}=7\,625\,597\,484\,987
\end{displaymath}

LaTeX knows how to handle a superscript on a superscript, or a subscript on a subscript, or supers on subs, or subs on supers. So, expressions such as e^{x^2} and x_{i_0} give correct output. Note the use in those expressions of curly braces to give the base a determined exp. If you enter \(3^3^3\) then you get ‘Double superscript’.

LaTeX does the right thing when something has both a subscript and a superscript. In this example the integral has both. They come out in the correct place without any author intervention.

\begin{displaymath}
  \int_{x=a}^b f'(x)\,dx = f(b)-f(a)
\end{displaymath}

Note the parentheses around x=a to make the entire expression a subscript.

To put a superscript or subscript before a symbol, use a construct like {}_t K^2. The empty curly braces {} give the subscript something to attach to and keeps it from accidentally attaching to a prior symbols.

Using the subscript or superscript character outside of math mode or display math mode, as in the expression x^2, will get you the error ‘Missing $ inserted’.

A common reason to want subscripts outside of a mathematics mode is to typeset chemical formulas. There are packages for that, such as mhchem; see CTAN.

© 2007–2018 Karl Berry
Public Domain Software
http://latexref.xyz/Subscripts-_0026-superscripts.html