LaTeX error: Undefined control sequence
TeX met a command, a word starting with a backslash, that nothing has defined. It prints the line up to the unknown command, then stops. The command itself is the last thing on the first line of the error context.
! Undefined control sequence.
Try it: this example has the error
Press Fix it in the error box, and it compiles to a PDF. What pdfTeX printed for it:
! Undefined control sequence.
l.3 This is \textbff
{bold} text.
Ready. Press Compile (or Ctrl/Cmd + Enter).
Common causes
- A typo in a command name:
\textbffinstead of\textbf,\beigninstead of\begin. - A command from a package you did not load:
\includegraphicsneedsgraphicx,\mathbbneedsamssymb,\SIneedssiunitx. - A backslash in ordinary text, such as a Windows path (
C:\temp). Write\textbackslashor use\verb. - A command defined later in the file than where it is used, or a
\newcommandwith a misspelled name.
How to fix it
- Read the end of the first context line in the log: that is the unknown command.
- If it is a typo, correct it. TeXpad suggests the closest known command and fixes it in one click.
- If it belongs to a package, add the
\usepackageline to the preamble. TeXpad recognizes over 130 common package commands and offers to add the package.