LaTeX \phantom, \vphantom, and \hphantom Commands
\phantom command
\phantom{subformula}: The \phantom command creates a box with the same height, depth, and width as subformula, but empty. That is, this command causes LaTeX to typeset the space but not fill it with the material.1
Example 11
1
2
3
4
5
6
7
8
9
\documentclass{article}
\begin{document}
\begin{displaymath}
\int x^2\,dx=\mbox{\underline{$\phantom{(1/3)x^3+C}$}}
\end{displaymath}
\end{document}

Example 2
1
2
3
4
5
6
7
8
9
\documentclass{article}
\begin{document}
\noindent
Thequickbrownfoxjumpsoverthelazydog\\
Thequick\phantom{brownfox}jumps\phantom{over}thelazydog.
\end{document}

Example 32
1
2
3
4
5
6
7
8
9
10
11
12
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
&\mathrel{\phantom{=}} (a+b)(a^2-ab+b^2) \notag \\
&= a^3 - a^2b + ab^2 + a^2b - ab^2 + b^2 \notag \\
&= a^3 + b^3
\end{align}
\end{document}

Example 42
1
2
3
4
5
6
7
8
\documentclass{article}
\usepackage{amsmath}
\begin{document}
$A_m^n$, $A_m{}^n$ or $A_m^{\phantom{m}n}$
\end{document}

Example 53
1
2
3
4
5
6
7
8
9
10
11
12
13
14
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
\Gamma^{\phantom{i}j}_{i\phantom{j}k},\
\begin{bmatrix}
1 & -1\\
2 & \phantom{-}3\\
\end{bmatrix}
\end{equation}
\end{document}

\vphantom command
\vphantom{subformula}: The \vphantom variant produces an invisible box with the same vertical size as subformula, the same height and depth, but having zero width.1
Example 12
1
2
3
4
5
6
7
8
9
10
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
\sqrt{\frac 12} < \sqrt{\vphantom{\frac12}2},\quad
\sqrt{\frac 12} < \sqrt{2}
\end{equation}
\end{document}

Example 21
1
2
3
4
5
6
7
8
9
10
\documentclass{article}
\begin{document}
\begin{displaymath}
\sum_{j\in\{0,\ldots\, 10\}\vphantom{3^{3^{3^j}}}}
\sum_{i\in\{0,\ldots\, 3^{3^{3^j}}\}} i\cdot j
\end{displaymath}
\end{document}

Example 34
1
2
3
4
5
6
7
8
9
10
11
12
13
14
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
\sqrt{\sum_{0\leq k< n} f(k)}
\sqrt{\vphantom{\sum}\smash{\sum_{0\leq k< n}} f(k)}
\quad\text{vs.}\quad
\sqrt{\sum_{0\leq k< n} f(k)}
\sqrt{\sum\sum_{0\leq k< n} f(k)}
\end{equation}
\end{document}

\hphantom command
\hphantom{subformula}: \hphantom makes a box with the same width as subformula but with zero height and depth.1
Example 1
1
2
3
4
5
6
7
8
9
\documentclass{article}
\begin{document}
\noindent
Thequickbrownfoxjumpsoverthelazydog\\
Thequick\hphantom{brownfox}jumps\hphantom{over}thelazydog.
\end{document}

References
-
\phantom&\vphantom&\hphantom(LaTeX2e unofficial reference manual (January 2025)). ˄ ˄2 ˄3 ˄4 ˄5 -
LaTeX入门, 刘海洋编著, pp. 228, 233, 265. ˄ ˄2 ˄3
-
\smash(LaTeX2e unofficial reference manual (January 2025)). ˄