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.
! Undefined control sequence.
LaTeX encountered a command (starting with \) that it doesn't recognise. This is one of the most common errors — it usually means a typo in a command name or a missing \usepackage.
Check the command spelling carefully. If the command comes from a package, add \usepackage{packagename} to your preamble. Use the LaTeX companion or the package documentation to confirm the correct command name.
\documentclass{article}
\begin{document}
\textboldd{This is bold text}
\end{document}\documentclass{article}
\begin{document}
\textbf{This is bold text}
\end{document}! LaTeX Error: Environment XXX undefined.
You tried to use \begin{envname} but LaTeX has no definition for that environment. Usually caused by a missing package or a typo in the environment name.
Add the required \usepackage to the preamble. The amsmath package provides align, aligned, gather, multline, and most math environments. The enumitem package extends list environments.
\documentclass{article}
% Missing \usepackage{amsmath}
\begin{document}
\begin{align}
E &= mc^2 \\
F &= ma
\end{align}
\end{document}\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
E &= mc^2 \\
F &= ma
\end{align}
\end{document}FormaTeX smart compile: FormaTeX smart compile detects AMS math environments and automatically adds \usepackage{amsmath} to the preamble before compiling.
! LaTeX Error: Command \XXX already defined.
You used \newcommand to define a command that already exists. LaTeX refuses to silently overwrite existing commands, which prevents hard-to-debug redefinition bugs.
Use \renewcommand instead of \newcommand if you intentionally want to override an existing command. If the conflict is between two packages, load them in a different order or use the \let technique to save and restore the original.
\documentclass{article}
\usepackage{amsmath}
% \text is already defined by amsmath
\newcommand{\text}[1]{\textit{#1}}
\begin{document}
Hello
\end{document}\documentclass{article}
\usepackage{amsmath}
% Use \renewcommand to override safely
\renewcommand{\text}[1]{\textit{#1}}
\begin{document}
Hello
\end{document}! LaTeX Error: Unknown option 'XXX' for package 'YYY'.
You passed an option to \usepackage that the package doesn't recognise. Options are package-specific — not all packages accept the same set.
Check the package documentation (run texdoc packagename in a terminal) to see the list of valid options. Some options like a4paper belong to \documentclass, not \usepackage.
\documentclass{article}
\usepackage[a4paper]{amsmath} % a4paper is not an amsmath option
\begin{document}
Hello
\end{document}\documentclass[a4paper]{article} % a4paper goes on documentclass
\usepackage{amsmath}
\begin{document}
Hello
\end{document}! LaTeX Error: Option clash for package XXX.
The same package is being loaded twice with different options, which LaTeX does not allow. This often happens when one package internally loads another with different settings than you specified.
Load the package with your desired options as early as possible — before any package that might load it automatically. If a dependency causes the conflict, load it first with your options, then load the dependent package.
\documentclass{article}
\usepackage{hyperref} % hyperref loads xcolor internally
\usepackage[dvipsnames]{xcolor} % Option clash!
\begin{document}
Hello
\end{document}\documentclass{article}
\usepackage[dvipsnames]{xcolor} % Load xcolor first with your options
\usepackage{hyperref} % hyperref reuses xcolor without conflict
\begin{document}
Hello
\end{document}FormaTeX smart compile: FormaTeX smart compile detects common option clash patterns and reorders package loading automatically.
! LaTeX Error: Something's wrong--perhaps a missing \item.
Text or content was placed directly inside an itemize, enumerate, or description environment without an \item command. Every piece of content inside a list must be introduced by \item.
Ensure every top-level item inside itemize, enumerate, or description is preceded by \item. If you need sub-lists, nest environments properly — each level still needs \item for each entry.
\documentclass{article}
\begin{document}
\begin{itemize}
This text has no item marker.
\item Second item
\end{itemize}
\end{document}\documentclass{article}
\begin{document}
\begin{itemize}
\item First item
\item Second item
\end{itemize}
\end{document}Runaway argument?
LaTeX started reading a mandatory argument (inside {}) but reached a paragraph break or end-of-file before finding the closing }. This typically means a brace was opened but never closed.
Find the unclosed { and add the matching }. Check the line indicated in the error. Blank lines inside command arguments are not allowed — if you need to break, end the command first.
\documentclass{article}
\begin{document}
\textbf{This text is bold
and continues on a new paragraph}
\end{document}\documentclass{article}
\begin{document}
\textbf{This text is bold.}
And continues on a new paragraph.
\end{document}! TeX capacity exceeded, sorry [main memory size=N].
LaTeX ran out of internal memory while processing your document. This can happen with very large documents, deeply nested structures, or infinite loops caused by recursive macro definitions.
If you have a recursive macro, fix the definition to terminate properly. For large documents, split them using \include{} and compile chapters separately. If caused by a package, try updating it or filing a bug report.
\documentclass{article}
\newcommand{\myloop}{\myloop} % Infinite recursion!
\begin{document}
\myloop
\end{document}\documentclass{article}
% Define commands that terminate
\newcommand{\mytext}{This is finite text.}
\begin{document}
\mytext
\end{document}! Argument of \XXX has an extra }.
\verb and verbatim environments are 'fragile' — they cannot be used inside arguments to other commands. Using \verb inside \section{}, \caption{}, footnotes, or similar commands causes a cryptic brace mismatch error.
Replace \verb with \texttt{} for monospace text inside command arguments. If you need true verbatim in a caption, use the caption package with the \protect\verb workaround, or use \lstinline from the listings package.
\documentclass{article}
\begin{document}
\section{Using \verb|\textbf{}| in LaTeX} % Error!
\end{document}\documentclass{article}
\begin{document}
\section{Using \texttt{\textbackslash textbf\{\}} in LaTeX}
\end{document}! LaTeX Error: Environment align undefined.
The align environment (and related environments like gather, multline, align*) are provided by the amsmath package. Without loading it, LaTeX has no definition for these environments.
Add \usepackage{amsmath} to your preamble. If you use any AMS math environments or commands (\text{}, \intertext{}, \tfrac{}, etc.), amsmath is required.
\documentclass{article}
% Missing \usepackage{amsmath}
\begin{document}
\begin{align}
a &= b + c \\
d &= e - f
\end{align}
\end{document}\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
a &= b + c \\
d &= e - f
\end{align}
\end{document}FormaTeX smart compile: FormaTeX smart compile automatically detects align, gather, multline, and other AMS environments and injects \usepackage{amsmath} into the preamble before compiling.
! LaTeX Error: Command \XXX is fragile.
Some LaTeX commands are 'fragile' and cannot be used directly in 'moving arguments' — arguments that LaTeX writes to auxiliary files (like .toc, .lof, .lot) for table of contents or captions. Examples include \footnote, \verb, and some formatting commands.
Add \protect before the fragile command to shield it: \section{My title \protect\footnote{Note}}. Alternatively, use \texorpdfstring{}{} from hyperref to provide different text for PDF bookmarks and the document.
\documentclass{article}
\begin{document}
\section{Introduction\footnote{A note}} % Fragile!
\end{document}\documentclass{article}
\begin{document}
\section{Introduction\protect\footnote{A note}}
\end{document}! Missing \endcsname inserted.
\csname...\endcsname is used to construct command names dynamically. This error means \endcsname is missing or the content between \csname and \endcsname contains invalid characters (like spaces or non-letter tokens).
Ensure every \csname has a matching \endcsname. The name between them must contain only letters. If you need numeric or special characters in command names, escape or encode them first.
\documentclass{article}
\begin{document}
% csname with space — invalid
\csname my command\endcsname
\end{document}\documentclass{article}
\begin{document}
% csname with letters only
\csname mycommand\endcsname
\end{document}