Subscripts and superscripts in LaTeX
In maths mode _ makes the next item a subscript and ^ makes it a superscript, so x_i prints a lowered i and x^2 a raised 2; braces group anything longer, as in x_{ij} or e^{2x}.
LaTeX command
x_{i}^{2}Not the symbol you meant? Draw it to find the command →
Typing up handwritten notes? Convert a whole page of handwriting to LaTeX →
_ and ^ take exactly one item: a single character, a command, or a group in braces. That is why x^10 prints x to the power 1 followed by a 0, and x^{10} prints x to the power 10. Bracing every subscript and superscript longer than one character is the habit that avoids these slips, which are among the most common when typing up handwritten notes.
A symbol can carry both at once, in either order: x_i^2 and x^2_i give the same result. The same marks put limits on operators, so \sum_{i=1}^{n} and \int_0^1 are subscripts and superscripts too. A superscript can hold its own superscript, as in , but two superscripts in a row on one base, x^2^3, stop with a 'Double superscript' error; brace one of them to say which you mean.
When a subscript is a word or a label rather than a variable, set it upright: x_{\text{max}} or T_{\mathrm{room}}. An italic max reads as the product of m, a and x. Outside maths, in a sentence, the text-mode commands in the section below raise or lower text without switching to maths.
Subscripts and superscripts in ordinary text
\textsuperscript and \textsubscript raise and lower text in a sentence, in the text font, with no maths mode: 1\textsuperscript{st}, H\textsubscript{2}O. Both are built into LaTeX. In maths mode, write the chemistry or the unit in upright type instead, as in .
1\textsuperscript{st}H\textsubscript{2}OOther forms
x_{i}subscriptx^{2}superscriptx_{\text{max}}a word as a subscript, uprightH\textsubscript{2}Osubscript in ordinary textExamples
$x_i^2$a subscript and a superscript on one letter
$x^{10}$a superscript of two digits, braced
$a_{i,j}$a double index
$e^{-x^2/2}$an exponent with its own superscript
$T_{\text{max}}$a word as an upright subscript
$\sum_{k=1}^{n} k^2$limits on a sum are subscripts and superscripts too
Tips and common mistakes
- Brace anything longer than one character: x^{10}, not x^10, and a_{12}, not a_12.
- Write words in subscripts upright with
\textor\mathrm, so max does not read as m times a times x. - Two superscripts on one base are an error; brace one, as in {x^2}^3 or x^{2^3}, to say which you mean.
- A prime is a superscript already: is short for f^{
\prime}(x), so ^2 needs braces as {}^2. - In ordinary text use
\textsuperscriptand\textsubscriptrather than switching into maths for one raised word.
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 write a subscript in LaTeX?
In maths mode put _ before it: x_i, or x_{max} with braces for more than one character. Use x_{\text{max}} to keep a word upright.
How do I write a superscript or exponent in LaTeX?
Put ^ before it in maths mode: x^2, or x^{10} with braces for more than one character.
How do I write a subscript outside maths mode?
Use \textsubscript{...}, for example H\textsubscript{2}O, or \textsuperscript{...} for a raised one. Both are built into LaTeX.
Why do I get a Double superscript error?
Two superscripts sit on the same base, as in x^2^3. Brace one of them, {x^2}^3 or x^{2^3}, to say which you mean.