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
- Must be in math mode. Wrap inline math with
$...$or use a display environment like\[ ... \],equation, oralign. - Single-token shortcut. Without braces, only the next single token is super/subscripted.
x^n+1means(xn) + 1, notxn+1. Use braces:x^{n+1}. - Order doesn't matter.
x_i^2andx^2_itypeset identically. Most style guides prefer subscript first. - 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 piIndexed variables
$a_1, a_2, \ldots, a_n$ % indexed sequence
$x_{ij}$ % matrix element
$\sum_{i=1}^{n} x_i$ % indexed sumCombined sub and superscript
$T_n^k$ % stirling-style notation
$\binom{n}{k}$ % preferred binomial
$\sigma_x^2$ % variance
$\hat{\theta}_{\text{MLE}}$ % MLE estimatorChemistry (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+} % cationOrdinals (text mode)
1\textsuperscript{st} % 1st
21\textsuperscript{st} % 21st
2\textsuperscript{nd} % 2nd
N\textsuperscript{th} % NthCommon 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}.
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 freeFrequently Asked Questions
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.
Use the underscore _ in math mode. Single character: x_i. Multiple characters: x_{ij}. Same math-mode requirement as superscripts.
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.
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.
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}.
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).
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.
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.
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.
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.