> 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/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 定义过。如果你把它拼错了（例如 \`\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，有时使用 **`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://overleaf-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.
