How to Write a Subscript in LaTeX
In math mode, _ makes a subscript and ^ a superscript: $x_1$, $x^2$. Each takes only the next character, so wrap longer scripts in braces: $x_{i+1}$, $e^{-x^2}$. Write both on one symbol as $x_i^2$.
Script syntax
x_1Subscript of one character.
x^2Superscript (exponent) of one character.
x_{i+1}Braces for a subscript longer than one character.
x^{n-1}Braces for a longer superscript.
x_i^2Subscript and superscript on the same symbol.
x_{\text{max}}Upright word as an index (amsmath).
a^{b^{c}}Nested superscripts.
{}^{14}_{6}\mathrm{C}Scripts on the left, e.g. isotopes.
- Text mode, no math preview
H\textsubscript{2}OSubscript in normal text (built into LaTeX since 2015).
- Text mode, no math preview
1\textsuperscript{st}Superscript in normal text, e.g. ordinals.
Try it live
Change the formula and the preview redraws as you type. Copy the LaTeX, download a PNG or SVG, copy it for Word, or use Edit here on any example below to load it.
Subscripts and superscripts examples
Each result below is drawn from the LaTeX under it. Copy the code, edit it on this page, or open it in the full editor.
Sequence and recurrence
LaTeXa_{n+1} = 2a_n + 1Exponent with braces
LaTeXe^{-x^2/2}Double index
LaTeXA_{ij} = a_{i,j}Add a comma when the indices could be misread:
a_{i,j}.Chemical formula
LaTeX\mathrm{H_2O} + \mathrm{CO_2}\mathrmkeeps element symbols upright.Tensor-style indices
LaTeXT^{\mu\nu} = g^{\mu\alpha} g^{\nu\beta} T_{\alpha\beta}Prime with an exponent
LaTeXf'(x)^2 \quad f''(x)'is already a superscript, sof'^2works too.Limits of a sum
LaTeX\sum_{i=1}^{n} x_i^2On big operators
_and^set the limits below and above.
How subscripts and superscripts work
_ and ^ only exist in math mode and apply to the single character or group that follows. x^10 therefore prints x¹ followed by 0; write x^{10}. Anything more than one character — numbers, expressions, commands with arguments — goes in braces.
The order does not matter: x_i^2 and x^2_i give the same result. Scripts stack neatly on the same symbol. To stagger them (tensor notation), use an empty group: T^{a}{}_{b}.
Text in subscripts and scripts outside math
Letters in a subscript are italic variables. For a label such as "max" or "eff", use x_{\text{max}} (amsmath) or x_{\mathrm{max}} so it is upright and correctly spaced.
In normal text use \textsubscript{…} and \textsuperscript{…} — for example CO\textsubscript{2} or 21\textsuperscript{st} century. For chemistry, the mhchem package's \ce{H2O} handles subscripts automatically.
Common mistakes
Without braces only the first character is raised, giving x¹0.
Instead ofx^10Writex^{10}Two subscripts on one symbol raise "Double subscript". Nest them or put both in one group.
Instead ofx_i_jWritex_{i_j} or x_{ij}"Double superscript": make the grouping explicit.
Instead ofx^2^3Write{x^2}^3 or x^{2^3}Only "m" becomes the subscript, and "ax" follows as italic variables.
Instead ofv_maxWritev_{\text{max}}
In Overleaf, MathJax and Word
Overleaf and pdfLaTeX
_and^are built in;\textneeds amsmath. Using them outside math gives "Missing $ inserted" — often from an underscore in a file name or URL; write\_there.MathJax and KaTeX
MathJax and KaTeX use the same
_and^rules and braces.\textsubscriptand\textsuperscriptare not available; write the formula in math mode instead. Some Markdown apps treat_as italics, so keep formulas inside$ … $.Microsoft Word
In a Word equation,
x_2orx^2followed by a space becomes a real subscript or superscript. For normal text, Word's shortcuts are Ctrl+= (subscript) and Ctrl+Shift+= (superscript) on Windows.
Subscripts and superscripts in LaTeX: questions
- How do I write a subscript in LaTeX?
- Use an underscore in math mode:
$x_1$. For more than one character, use braces:$x_{12}$or$x_{\text{max}}$. - How do I write a superscript or exponent?
- Use a caret:
$x^2$. Put longer exponents in braces:$2^{10}$,$e^{i\pi}$. - How do I put a subscript and superscript on the same letter?
- Write both:
$x_i^2$. They stack on top of each other. - How do I write a subscript outside math mode?
- Use
\textsubscript{2}, e.g.H\textsubscript{2}O, or wrap it in math:H$_2$O. - Why does x^10 only raise the 1?
^takes one character. Use braces:x^{10}.
Related LaTeX reference
- Math Mode in LaTeXInline math with $…$ or \(…\), displayed math with \[…\], numbered equation environments, references and \text inside formulas.
- Summation in LaTeX\sum with limits, why inline sums put the limits beside the sigma, \limits and \displaystyle, and multi-line conditions with \substack.
- How to Write a Fraction in LaTeX\frac{numerator}{denominator}, \dfrac and \tfrac for size, continued fractions with \cfrac, slanted fractions and the a/b form.
- LaTeX equation editorSymbol panel, live preview, and PNG, SVG, MathML or Word export.
- All LaTeX reference pagesSymbols, math structures and text formatting in one list.
Have the formula as a picture?
Paste a screenshot or photo of the equation and get its LaTeX, ready to copy or open in the editor.
Convert an image to LaTeX