LaTeX Guide

LaTeX Superscript & Subscript

^ for superscript, _ for subscript. Brace multi-character arguments. Always inside math mode. Here's every variation, with worked examples.

The two-second answer

% Single character
$x^2$       % superscript: x squared
$x_i$       % subscript: x sub i

% Multiple characters — use braces
$x^{n+1}$   % superscript with multi-char
$x_{i,j}$   % subscript with multi-char

% Both at once
$x_i^2$     % x sub i, squared

% Nested
$e^{x^2}$   % e to the (x squared)

The rules

  1. Must be in math mode. Wrap inline math with $...$ or use a display environment like \[ ... \], equation, or align.
  2. Single-token shortcut. Without braces, only the next single token is super/subscripted. x^n+1 means (xn) + 1, not xn+1. Use braces: x^{n+1}.
  3. Order doesn't matter. x_i^2 and x^2_i typeset identically. Most style guides prefer subscript first.
  4. Outside math mode, use \textsuperscript{...} and \textsubscript{...}. Example: 1\textsuperscript{st} → 1st.

Common patterns

Powers and exponents

$x^2$        % x squared
$x^3$        % x cubed
$x^{10}$     % x to the 10
$x^{n+1}$    % x to the n+1
$2^{32}$     % 2 to the 32
$e^{i\pi}$   % e to the i pi

Indexed variables

$a_1, a_2, \ldots, a_n$    % indexed sequence
$x_{ij}$                  % matrix element
$\sum_{i=1}^{n} x_i$      % indexed sum

Combined sub and superscript

$T_n^k$                    % stirling-style notation
$\binom{n}{k}$             % preferred binomial
$\sigma_x^2$               % variance
$\hat{\theta}_{\text{MLE}}$  % MLE estimator

Chemistry (text-mode subscripts)

H\textsubscript{2}O          % H2O — works
% Better with mhchem package:
\usepackage{mhchem}
\ce{H2O}                     % gets full chemical formatting
\ce{H2SO4}                   % sulfuric acid
\ce{Na+}                     % cation

Ordinals (text mode)

1\textsuperscript{st}        % 1st
21\textsuperscript{st}       % 21st
2\textsuperscript{nd}        % 2nd
N\textsuperscript{th}        % Nth

Common errors

"Missing $ inserted"

You forgot math mode. x^2 in plain text fails. Fix: $x^2$.

"Double superscript" / "Double subscript"

You wrote x^2^3 or x_i_j without braces. LaTeX can't tell what you mean. Fix: brace one of them, e.g. x^{2^3} or x_{i_j}.

Only one character is superscripted

You wrote x^n+1. Only n is in the superscript. Fix: x^{n+1}.

The Typst version is even simpler

In Typst, the same syntax works without LaTeX's edge cases. No "Missing $" errors, no double-superscript surprises:

$ x^2 $          // superscript
$ x_i $          // subscript
$ x_i^2 $        // both
$ x^(n+1) $      // multi-char (parentheses, not braces)

Typst compiles 10x faster than LaTeX and you can write your whole paper in your browser with TypeTeX — free, no signup needed to try it.

Try TypeTeX free

Frequently Asked Questions

How do I write a superscript in LaTeX?

Use the caret symbol ^ in math mode. For a single character, just type ^x. For multiple characters, wrap them in braces: x^{abc}. The math mode is required — you'll need $...$ for inline math or \[...\] for display math, or be inside an equation environment.

How do I write a subscript in LaTeX?

Use the underscore _ in math mode. Single character: x_i. Multiple characters: x_{ij}. Same math-mode requirement as superscripts.

How do I combine superscript and subscript on the same character?

Just chain them: x_i^2 produces x with subscript i and superscript 2. The order doesn't matter (x^2_i is the same), but most style guides prefer subscript-first then superscript: x_i^2.

Why do I get an error 'Missing $ inserted' when using ^ or _?

Superscripts and subscripts only work in math mode. If you write x^2 in regular text, LaTeX will throw 'Missing $ inserted'. Wrap it: $x^2$ for inline, or use \textsuperscript{} / \textsubscript{} for text-mode super/subscripts.

How do I write text-mode superscript/subscript (outside math mode)?

Use \textsuperscript{...} and \textsubscript{...}. Example: 1\textsuperscript{st} renders as '1ˢᵗ'. H\textsubscript{2}O works too, though chemists usually use the mhchem package: \ce{H2O}.

How do I write multi-character superscripts and subscripts?

Wrap the content in curly braces: x^{n+1}, y_{i,j}, e^{i\pi}. Without braces, only the next single token is super/subscripted, so x^n+1 means (x^n)+1, not x^(n+1).

How do I write x squared, x cubed, or x to the power of n?

x squared: $x^2$. x cubed: $x^3$. x to the n: $x^n$. x to the n+1: $x^{n+1}$. Always use math mode and braces for multi-character exponents.

How do I write nested superscripts (a superscript on a superscript)?

Nest with braces: e^{x^2} renders e raised to (x squared). Each level needs braces to scope the operator. e^{x^{y+1}} works for triple nesting.

How is super/subscript different in Typst?

Typst is dramatically simpler. In math mode you write x^2 and x_i exactly like LaTeX, but you don't need to wrap inline math in $...$ — Typst's $...$ syntax is consistent everywhere. For text-mode superscript Typst uses #super[1st] (not the verbose \textsuperscript{}). And there are no 'Missing $ inserted' errors — Typst's error messages tell you exactly what's wrong.

Can I use Unicode super/subscript characters instead?

Yes, but only if your font supports them: ² ³ ¹ ₁ ₂. They render as part of the text, not as math. For real math, use the LaTeX ^ and _ syntax — it integrates with equation numbering and produces consistent typesetting.

More LaTeX guides