One quick thing
We track anonymous usage — page views, feature usage, compilation events — to understand what works and what doesn't. No ads, no personal data, no third-party sharing.
\errors{latex}
50 common errors explained — what causes them, how to fix them, and working code examples. Bookmark this for when LaTeX inevitably surprises you.
! Missing $ inserted.
A math command or symbol (like _, ^, \alpha, \frac) was used outside of math mode. LaTeX only interprets these as math when they appear between $ delimiters or inside a math environment.
Wrap math content in inline math mode with $...$ or \(...\), or use a display math environment like \begin{equation}...\end{equation}. For subscripts in text use \textsubscript{} and for superscripts use \textsuperscript{}.
\documentclass{article}
\begin{document}
The value is x_1 + y^2 = z.
Let \alpha be a constant.
\end{document}\documentclass{article}
\begin{document}
The value is $x_1 + y^2 = z$.
Let $\alpha$ be a constant.
\end{document}! Double subscript.
Two consecutive subscript operators _ were applied to the same base without grouping. LaTeX doesn't allow ambiguous stacked subscripts.
Use braces {} to group subscripts. For nested subscripts like x with index i,j write x_{ij} or x_{i_j}. For a subscript that itself has a subscript, wrap the inner expression in braces.
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[ x_i_j = 0 \]
\end{document}\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[ x_{i_j} = 0 \]
\end{document}! Extra alignment tab has been changed to \cr.
A row in a tabular, array, or align environment contains more & column separators than the column specification allows. LaTeX forces a row break at the extra &.
Count the & characters in each row and ensure they match the number of columns minus one. For a 3-column table you need exactly 2 & per row. Update the column specification if you added a new column.
\documentclass{article}
\begin{document}
\begin{tabular}{ll} % 2 columns = 1 ampersand per row
Name & Age & City \\ % 3 columns worth of data!
Alice & 30 & Paris \\
\end{tabular}
\end{document}\documentclass{article}
\begin{document}
\begin{tabular}{lll} % 3 columns = 2 ampersands per row
Name & Age & City \\
Alice & 30 & Paris \\
\end{tabular}
\end{document}! LaTeX Error: Bad math environment delimiter.
A display math delimiter (\[ or \]) was used in an invalid context — such as closing a display math block that was never opened, or opening display math inside inline math.
Ensure every \[ is paired with exactly one \]. Do not nest display math inside other math environments. Use \( and \) for inline math, \[ and \] for unnumbered display math, or \begin{equation} for numbered equations.
\documentclass{article}
\begin{document}
\] x = 5 \[ % Delimiters in wrong order
\end{document}\documentclass{article}
\begin{document}
\[ x = 5 \] % Correct order
\end{document}! Double superscript.
Two consecutive superscript operators ^ were applied to the same base without grouping. Just like double subscript, LaTeX refuses ambiguous stacked superscripts.
Group the superscript content with braces. For x to the power of a+b, write x^{a+b}. For x to the power of a to the power of b, write x^{a^b}.
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[ e^x^2 \]
\end{document}\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[ e^{x^2} \]
\end{document}! LaTeX Error: \boldsymbol undefined.
\boldsymbol is used to produce bold symbols in math mode, but it requires either the bm package (preferred) or amsmath. Without loading one of these, the command is undefined.
Add \usepackage{bm} to your preamble. Use \bm{\symbol} instead of \boldsymbol{\symbol} — bm is the modern, recommended package. For simple Latin bold in math, \mathbf{x} works without any package.
\documentclass{article}
% Missing \usepackage{bm}
\begin{document}
\[ \boldsymbol{\alpha} + \boldsymbol{x} = 0 \]
\end{document}\documentclass{article}
\usepackage{bm}
\begin{document}
\[ \bm{\alpha} + \bm{x} = 0 \]
\end{document}! LaTeX Error: Environment proof undefined.
The proof, theorem, lemma, corollary, and definition environments are provided by the amsthm package. Without loading it, LaTeX has no definition for these environments.
Add \usepackage{amsthm} to your preamble. You also need to declare theorem-style environments with \newtheorem before using them. The proof environment is predefined by amsthm.
\documentclass{article}
% Missing \usepackage{amsthm}
\begin{document}
\begin{proof}
This is the proof.
\end{proof}
\end{document}\documentclass{article}
\usepackage{amsthm}
\newtheorem{theorem}{Theorem}
\begin{document}
\begin{theorem}
Statement of the theorem.
\end{theorem}
\begin{proof}
This is the proof.
\end{proof}
\end{document}FormaTeX smart compile: FormaTeX smart compile detects proof, theorem, lemma, corollary, and definition environments and automatically adds \usepackage{amsthm} to the preamble.
! Extra \right.
\left and \right must always appear as a matched pair in the same math group. A \right without a preceding \left, or a \left without a closing \right, causes this error.
Ensure every \left delimiter has a matching \right delimiter in the same math group. Use \left. (with a period) as an invisible delimiter when you need an asymmetric pair.
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[ f(x) = \right) x^2 \] % \right without \left
\end{document}\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[ f(x) = \left( x^2 \right) \]
\end{document}! Missing number, treated as zero.
LaTeX expected a number (for a dimension, counter, or numeric argument) but found something unexpected. This often happens when a \hspace, \vspace, or \rule command is given a non-numeric argument.
Provide a valid numeric dimension (e.g. \hspace{1em} or \vspace{12pt}). Dimensions require a unit — never write \hspace{1} without specifying pt, em, cm, etc.
\documentclass{article}
\begin{document}
\hspace{1} % Missing unit — error!
\end{document}\documentclass{article}
\begin{document}
\hspace{1em} % Correct: number + unit
\end{document}! Missing } inserted.
A display math environment or brace group was opened but not closed before the end of the document or the next environment. LaTeX inserts the missing } automatically but the surrounding structure is wrong.
Check every \[ has a matching \] and every \begin{equation} has a matching \end{equation}. Use an editor with bracket matching to identify the unclosed delimiter.
\documentclass{article}
\begin{document}
\[ x = 5
% Missing \]
More text.
\end{document}\documentclass{article}
\begin{document}
\[ x = 5 \]
More text.
\end{document}