> For the complete documentation index, see [llms.txt](https://ayakaleaf-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://ayakaleaf-pro.ayaka.space/latex/zh-cn/latex-cuo-wu/31-undefined-control-sequence.md).

# 未定义的控制序列

当 LaTeX 无法理解你使用的某个命令时，就会出现此错误。

## 常见示例

**命令中的拼写错误：**

导致此类错误的最常见原因是简单的拼写错误。下面展示了这样一个例子，你不小心按下了 **`Z`** 而不是 **`a`** 在输入 **`\alpha`**

```latex
输入 $\alpha$ 时的拼写错误可能会变成 $\Zlpha$
```

这将产生如下错误信息：

main.tex，第 10 行

未定义的控制序列。

< \Zlpha l.10 写作时的拼写错误 $$\alpha$$ 可能是 $\Zlpha $。错误信息第一行末尾的控制序列从未被 \def'ed。如果你把它拼错了（例如 \`\hobx'），请输入 \`I' 和正确拼写（例如 \`I\hbox'）。否则就继续，我会忘记所有未定义的内容。 \[1

人类很容易发现这些错误，但它们会让 LaTeX 搞不清到底要执行什么。

**忘记加载宏包：**

此类错误的另一个原因是，使用某个命令需要特定的宏包，但在导言区里不小心忘记加载了。一个例子是

```latex
我想在单词 \LaTeX\xspace 后面加一个空格，但我忘记加载 xspace 宏包了。
```

在这个例子中，文档将无法编译，因为 LaTeX 无法识别 **`\xspace`** 命令。这不是拼写错误，因为 **`\xspace`** 是一个完全正常的命令。问题在于你忘记包含 **`\usepackage{xspace}`** 在导言区中。加入这一行后，错误信息就会消失，因为 LaTeX 现在知道如何解释 **`\xspace`** 该命令。

**反斜杠使用位置错误：**

另一个导致 *未定义的控制序列* 错误的原因是不恰当地使用了反斜杠。这种情况尤其会在编写文件链接时发生，如下所示。

```latex
如果你将文件路径写成

C:\Users\Files
```

问题在于，当 LaTeX 看到反斜杠 **`\`**&#x65F6;，它会将后面的内容解释为命令。这里并没有 \Users 这样的命令，所以你会得到一个 *未定义的控制序列* 错误。为避免这种情况，在写文本时，你应该将反斜杠写成 **`\backslash`**。对于较长的文件路径和网址，有时使用 **`url`** 宏包会比每次都手动写 **`\backslash`** 更方便。


---

# 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://ayakaleaf-pro.ayaka.space/latex/zh-cn/latex-cuo-wu/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.
