! Undefined control sequence is the most common LaTeX error: it means LaTeX hit a command (a \name) it does not recognize. It is almost always one of three things — a typo, a package you forgot to load, or a custom command you never defined. This page walks through each.
What it looks like
The error reads ! Undefined control sequence, then l.NN showing the line split right after the unknown command. The token just before the break is the command LaTeX does not know. Here is a typo of \frac as \fra (for reading errors in general, see “Reading errors & debugging”):
! Undefined control sequence.
l.12 \fra
c{1}{2}Three causes and fixes
- A typo (most common) —
\fra→\frac,\textbnf→\textbf. Fix the spelling. - A package not loaded — the command’s package was never
\usepackaged (e.g.\includegraphicsneedsgraphicx,\topruleneedsbooktabs, many math symbols needamsmath). Load it in the preamble. - A custom command not defined — you forgot the
\newcommand, used it before its definition, or it was out of scope. Put the definition (before first use).
Tracking it down
The token just before l.NN is the undefined command, so look at that line in your editor. If nothing stands out, suspect a command or package you added recently — that is the fastest lead. To find which package provides a command, texdoc PACKAGE helps. To isolate the cause, comment out the suspect part and recompile.