Subscript and Superscript in LaTeX

Use _ for subscripts and ^ for superscripts inside math mode.

Quick Answer

latex
$x^2$          % superscript: x²
$x_i$          % subscript: xᵢ
$x^{2n}$       % multi-char superscript
$x_{ij}$       % multi-char subscript

Basic Usage

Superscripts and subscripts only work inside math mode ($...$ or \[...\]). Use curly braces for anything longer than a single character.

latex
% Superscript:
$x^2$           % x squared
$e^{i\pi}$      % Euler's formula
$2^{10} = 1024$ % powers

% Subscript:
$x_1, x_2, x_3$          % indexed variables
$a_{ij}$                  % matrix element
$\log_2 n$               % logarithm base

% Combined:
$x_i^2$          % subscript and superscript
$\sum_{i=1}^{n}$ % classic sum notation

Limits on Operators

On large operators like \sum and \int, sub/superscripts become limits (above/below in display mode, beside in inline mode).

latex
% Display mode — limits appear above and below:
\[ \sum_{i=1}^{n} i = \frac{n(n+1)}{2} \]

% Inline — limits appear beside: $\sum_{i=1}^{n} i$

% Force limits style in inline:
$\sum\limits_{i=1}^{n} i$

% Force beside style in display:
\[ \sum\nolimits_{i=1}^{n} i \]

Writing your thesis in LaTeX?

MonsterWriter's LaTeX Workspace gives you real-time PDF preview with no compile limits — at a fraction of Overleaf's price. Works just like Overleaf, costs 11× less.

Try MonsterWriter free

Text-Mode Sub/Superscript

For chemical formulas or text context, use \textsubscript and \textsuperscript — no math mode needed.

latex
H\textsubscript{2}O    % H₂O (water)
CO\textsubscript{2}   % CO₂ (carbon dioxide)

Area = 10 m\textsuperscript{2}
The 1\textsuperscript{st} result

Stacked Sub/Superscript

latex
% Both on the same symbol:
$x_i^2$          % subscript first, then superscript
${}_i^j X$       % both to the left (e.g., tensor notation)

% Primes:
$f'(x)$          % first derivative (f prime)
$f''(x)$         % second derivative
$f^{\prime}(x)$  % explicit prime command

Related Topics