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_1
    x 1

    Subscript of one character.

  • x^2
    x 2

    Superscript (exponent) of one character.

  • x_{i+1}
    x i + 1

    Braces for a subscript longer than one character.

  • x^{n-1}
    x n − 1

    Braces for a longer superscript.

  • x_i^2
    x i 2

    Subscript and superscript on the same symbol.

  • x_{\text{max}}
    x max

    Upright word as an index (amsmath).

  • a^{b^{c}}
    a b c

    Nested superscripts.

  • {}^{14}_{6}\mathrm{C}
    6 14 C

    Scripts on the left, e.g. isotopes.

  • H\textsubscript{2}O
    Text mode, no math preview

    Subscript in normal text (built into LaTeX since 2015).

  • 1\textsuperscript{st}
    Text mode, no math preview

    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.

Templates

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

    a n + 1 = 2 a n + 1
    LaTeX
    a_{n+1} = 2a_n + 1
  • Exponent with braces

    e − x 2 / 2
    LaTeX
    e^{-x^2/2}
  • Double index

    A i j = a i , j
    LaTeX
    A_{ij} = a_{i,j}

    Add a comma when the indices could be misread: a_{i,j}.

  • Chemical formula

    H 2 O + CO 2
    LaTeX
    \mathrm{H_2O} + \mathrm{CO_2}

    \mathrm keeps element symbols upright.

  • Tensor-style indices

    T μ ν = g μ α g ν β T α β
    LaTeX
    T^{\mu\nu} = g^{\mu\alpha} g^{\nu\beta} T_{\alpha\beta}
  • Prime with an exponent

    f ′ ( x ) 2 f ″ ( x )
    LaTeX
    f'(x)^2 \quad f''(x)

    ' is already a superscript, so f'^2 works too.

  • Limits of a sum

    ∑ i = 1 n x i 2
    LaTeX
    \sum_{i=1}^{n} x_i^2

    On 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 of
    x^10
    Write
    x^{10}
  • Two subscripts on one symbol raise "Double subscript". Nest them or put both in one group.

    Instead of
    x_i_j
    Write
    x_{i_j}  or  x_{ij}
  • "Double superscript": make the grouping explicit.

    Instead of
    x^2^3
    Write
    {x^2}^3  or  x^{2^3}
  • Only "m" becomes the subscript, and "ax" follows as italic variables.

    Instead of
    v_max
    Write
    v_{\text{max}}

In Overleaf, MathJax and Word

  • Overleaf and pdfLaTeX

    _ and ^ are built in; \text needs 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. \textsubscript and \textsuperscript are 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_2 or x^2 followed 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}.

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