Resurchify LaTeX Guide
Resurchify

Undefined control sequence


Tags: undefined control sequence latex includegraphics, undefined control sequence latex documentclass, undefined control sequence latex bibliography, undefined control sequence latex chapter, undefined control sequence latex begin document, undefined control sequence latex equation, undefined control sequence latex table

This error will appear when LaTeX is unable to understand the command you may have used.

Common Causes of Error

Typing mistake while writing a command:

The easiest way of making such mistakes is typing errors. An example of such an error is shown below: By mistake, you have written s instead of a here.

A typing mistake when writing $\alpha$ could be $\slpha$

This will give an error message of

! Undefined control sequence.			main.tex, line 6
<recently read> \slpha 
                       
l.6 ...take when writing $\alpha$ could be $\slpha
                                                  $
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

Forgetting to load a package

This type of error occurs often when you forget to include a specific package in the preamble required for some command. Below is an example to demonstrate that.

To include a space after the word \LaTeX\xspace, we require xspace package which I forgot to load.

In the example above, LaTeX will fail to compile the document as it won’t be able to recognize the \xspace command. This will not be classified as a typing mistake because \xspace is a correct command.

It will come under the second type of mistake, where we forget to load the package. To avoid this mistake, following line should have been included in the preamble: \usepackage{xspace}. On inclusion of this line, there will not be an error message as the associated package When this line is included, the error message will disappear as LaTeX will be able to interpret the \xspace command.

Backslash used in wrong place

Another reason the compiler may throw Undefined Control Sequence error is the inappropriate use of backslash. For example,

An error will be generated if we write the path of file as   C:\Users\Files\Pictures

In the above example, LaTeX will interpret it as a command upon seeing the backslash \. But here, there is no command as \Users and therefore, the compiler will throw Undefined Control Sequence error. To avoid this, you need to write a backslash as \backslash. For writing URLs and long file paths, you can use the url package instead of writing \backslash every time.

Powered by www.resurchify.com