> For the complete documentation index, see [llms.txt](https://overleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://overleaf-pro.ayaka.space/latex/latex-errors/31-undefined-control-sequence.md).

# Undefined control sequence

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`**

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

This will give an error message of

main.tex, line 10

Undefined control sequence.

< \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

```latex
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.

```latex
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.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://overleaf-pro.ayaka.space/latex/latex-errors/31-undefined-control-sequence.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
