LaTeX error · Commands, braces and arguments

Undefined control sequence.

Quick answer

LaTeX met a command (a word starting with a backslash) that is not defined anywhere. Either the name is misspelled (\textbol instead of \textbf), or the command comes from a package you have not loaded (\includegraphics needs \usepackage{graphicx}, \mathbb needs amssymb). The last command on the l.<n> line of the log is the unknown one: correct the spelling or add the \usepackage line to the preamble.

The error in the log

This is how the message appears in the .log file (and in the compile output). The line starting with l. is the line number where TeX noticed the problem; the real mistake is there or just before it.

! Undefined control sequence.
l.5 The set \mathbb
                   {R} of real numbers.

Why it happens

  • A typo in the command name: \textbol, \beign, \fraq, or a wrong capital letter (\Alpha does not exist in standard LaTeX).
  • The command belongs to a package that is not loaded: \mathbb and \mathfrak (amssymb), \includegraphics (graphicx), \url (url or hyperref), \SI (siunitx), \toprule (booktabs).
  • A backslash in text that was meant literally, such as a Windows path C:\Users\data or a stray \ before a word.
  • A command defined only in one class or template (for example \email or \affiliation) used with a different document class.

How to fix it

Read the line after the error: the log breaks it exactly after the unknown command, so the last token on the l.<n> line is the culprit. Here it is \mathbb, which is defined by the amssymb package, not by LaTeX itself.

If the spelling is right, search for the package that provides the command and load it in the preamble. If the backslash was meant to be printed, write \textbackslash instead.

Broken: reproduces the error

\documentclass{article}

\begin{document}

The set \mathbb{R} of real numbers.

\end{document}

Try this in Octree — free LaTeX editor with AI, compiles in your browser

Fixed: compiles cleanly

\documentclass{article}
\usepackage{amssymb}

\begin{document}

The set $\mathbb{R}$ of real numbers.

\end{document}

For a longer walkthrough with more examples, read Undefined control sequence in LaTeX: causes and fixes on the blog.

Related errors

Frequently Asked Questions

How do I find which command is undefined?

Look at the line in the log that starts with l. and a number. TeX splits it at the point where it stopped, so the last command on the first half is the undefined one. The number is the line in your source file.

Why do I get Undefined control sequence for \mathbb or \includegraphics?

These commands are not part of core LaTeX. Add \usepackage{amssymb} for \mathbb and \usepackage{graphicx} for \includegraphics to the preamble, before \begin{document}.

Can I ignore Undefined control sequence and still get a PDF?

In nonstop mode LaTeX skips the unknown command and keeps going, so a PDF may appear, but whatever the command should have produced is missing. Fix the error rather than relying on that output.

Why does the error point to the preamble?

A command used in the preamble, such as \setlength{\parskip} with a misspelled length or a \newcommand body that uses an unknown macro, is reported there. If the error appears when a macro you defined is used, the unknown command is inside your definition.

Paste your document into Octree — compile errors get a Fix with AI button

When a compile fails, Octree shows the error next to the line that caused it and offers a one-click fix that you can review before applying. Free, nothing to install.

Fix it in Octree →