Undefined control sequence.
LaTeX met a command it does not know: usually a typo, or a command whose package is not loaded. The log's l. line ends with the culprit.
Help centre › LaTeX errors › Commands and packages · Error: the build stops or the output is wrong
What the log says
! Undefined control sequence.
<recently read> \mathbb
l.3 The real numbers $\mathbb
{R}$ form a field.What it means
TeX read a command (a backslash followed by a name) that nothing has defined. The command it stopped at is the last thing on the first line of the context: in the log above, the l.3 line ends with \mathbb, so \mathbb is the unknown command. TeX skips it and carries on, so the output may look almost right, but the command's effect is missing.
Causes and fixes
Most common first. Each example is a complete document; the first fails with this message, the second is the same document fixed.
1. The command comes from a package that is not loaded
Many everyday commands are not part of LaTeX itself: \mathbb and \checkmark need amssymb, \includegraphics needs graphicx, \toprule needs booktabs, \textcolor needs xcolor, \text and \eqref need amsmath, \url needs url or hyperref. Add the right \usepackage{…} line to the preamble, above \begin{document}.
\documentclass{article}
\begin{document}
The real numbers $\mathbb{R}$ form a field.
\end{document}\documentclass{article}
\usepackage{amssymb}
\begin{document}
The real numbers $\mathbb{R}$ form a field.
\end{document}2. The command name is misspelled
Command names are case-sensitive and exact: \textbff, \Alpha, \beign and \cite{…} written as \citep{…} without natbib are all unknown. Compare the name at the end of the l. line with the documentation of the command you meant.
\documentclass{article}
\begin{document}
This word is \textbff{important}.
\end{document}\documentclass{article}
\begin{document}
This word is \textbf{important}.
\end{document}3. A backslash in ordinary text starts an accidental command
A Windows path such as C:\Users\data or a stray backslash before a word makes TeX read \Users and \data as commands. Write paths with \texttt{C:\textbackslash Users}, or use \path from the url package.
\documentclass{article}
\begin{document}
The data are in C:\Users\data.
\end{document}\documentclass{article}
\usepackage{url}
\begin{document}
The data are in \path{C:\Users\data}.
\end{document}4. The command is defined by a document class you are not using
Journal templates define their own commands (\address, \corresp, \keywords, \affiliation and the like). Copied into a document with another class, or after the class was changed to article, they are unknown. Use the journal's class, or remove or replace those commands.
5. A command of your own is used before it is defined
A \newcommand takes effect only from the line where it appears. Move the definition into the preamble, above the first use; also check that the definition line is not commented out with %.
\documentclass{article}
\begin{document}
The error is \err.
\newcommand{\err}{$\varepsilon$}
\end{document}\documentclass{article}
\newcommand{\err}{$\varepsilon$}
\begin{document}
The error is \err.
\end{document}Finding the line when the line number does not help
- The unknown command is the last one on the first context line under the error (the
l.<n>line, or a<recently read>line when the command came from a macro). - When that line shows a command you did not write, such as one with
@in its name, the unknown command was used inside a package or class: look at the package that the log was reading at the time, or at the arguments you passed it.
In Manulyx
The editor shows the error beside the line with an explanation, and for commands that a common package provides (such as \mathbb, \toprule or \includegraphics) it names the package and the \usepackage line to add.
Write in Manulyx for free · Journal templates
More in commands and packages
- Missing number, treated as zero.A command that needs a number or length (\vspace, \setcounter, a width) got a word or nothing. Give it a value such as 1em or 3.
- LaTeX Error: Command \<name> already defined.\newcommand or a package tried to define a name that already exists. Pick another name, use \renewcommand, or drop the clashing package.
- Illegal parameter number in definition of \<name>.A # in a definition does not refer to a declared argument: #1 without [1], #1 in an environment's end code, or a # in a URL. Fix the count or escape it.
- Use of \<name> doesn't match its definition.A command with a special argument syntax, such as \put(x,y) or a \def with delimiters, was called without that syntax. Follow its exact form.
- LaTeX Error: Environment <name> undefined\begin{…} names an environment no loaded package defines: load the package (amsmath for align), fix the spelling, or define it with \newtheorem.
- LaTeX Error: Option clash for package <name>A package is loaded twice with different options, often because the class or another package loaded it first. Load it once, with all options.
Every example on this page was compiled with pdfLaTeX to check that it fails and is fixed as described. All LaTeX errors