Skip to content

This error appears when LaTeX does not understand one of the commands you have used.

Common Examples

Typo in a command:

The most common causes of such an error are simple typos. An example of such a typo is shown below, where you accidentally pressed Z instead of a when writing \alpha

A typo when writing $\alpha$ could be $\Zlpha$


This will give an error message of

main.tex, line 10

Undefined control sequence.

<<recently read> \Zlpha l.10 A typo when writing $\alpha$ could be $\Zlpha $ The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g., `\hobx'), type `I' and the correct spelling (e.g., `I\hbox'). Otherwise just continue, and I'll forget about whatever was undefined. [1

These errors are easily spotted by humans but can cause LaTeX to get confused as to what is being asked.

Forgetting to load a package:

Another cause of such an error is when a specific package is needed to use a certain command, but it is accidentally forgotten in the preamble. An example of this would be

I want to include a space after the word \LaTeX\xspace but I have forgotten to load the xspace package.

In this example, the document will fail to compile as LaTeX doesn't recognize the \xspace command. This is not a typo, as \xspace is a perfectly fine command. The problem is that you have forgotten to include \usepackage{xspace} in the preamble. When this line is included, the error message will disappear as LaTeX now knows how to interpret the \xspace command.


Backslash used in wrong place:

Another cause of an Undefined Control Sequence error is a backslash used inappropriately. This can happen particularly when writing file links as shown below.

An error will be generated if you write a file path as 

C:\Users\Files

The issue is that when LaTeX sees a backslash \, it interprets what follows as a command. Here, there is no such command as \Users, so you will get an Undefined Control Sequence error. To avoid this, when writing text you should write a backslash as \backslash. For writing long file paths and urls, it may sometimes be more convenient to use the url package rather than writing \backslash every time.

Overleaf guides

LaTeX Basics

Mathematics

Figures and tables

References and Citations

Languages

Document structure

Formatting

Fonts

Presentations

Commands

Field specific

Class files

Advanced TeX/LaTeX