Fix "Undefined control sequence" in LaTeX
This error means LaTeX met a command it does not know. You will learn how to find the command and make it known.
The message
Section titled “The message”In the Output panel’s full log:
./main.tex:3: Undefined control sequence.l.3 The deadline is \textcolor {red}{Friday}.The l.3 line shows the source up to the point where LaTeX stopped. The last command on that line (here \textcolor) is the undefined one.
Why it happens
Section titled “Why it happens”- The command is misspelled, for example
\beignor\textbg. - The command comes from a package you have not loaded, for example
\textcolor(xcolor),\includegraphics(graphicx) or\mathbb(amssymb). - The command is defined in a file that is not part of this compile, or in a document class you are not using.
Example
Section titled “Example”\documentclass{article}\begin{document}The deadline is \textcolor{red}{Friday}.\end{document}Load the package that provides the command in the preamble, before \begin{document}:
\documentclass{article}\usepackage{xcolor}\begin{document}The deadline is \textcolor{red}{Friday}.\end{document}If the command is a typo, correct its spelling instead.
Help from Luzbase
Section titled “Help from Luzbase”- For commands that are often used without their package, the error summary in the Output panel suggests the fix, for example “Add \usepackage{xcolor} to the preamble.”
- For
\includegraphics,\href,\url,\autoref,\nameref,\crefand\Cref, the editor underlines the command before you compile and offers a quick fix, Add \usepackage{…}. - To add a package without typing, use Add LaTeX package in the editor toolbar.
Not on Luzbase yet? It compiles LaTeX in your browser and links each error to its line, often with the fix. Start writing free.