> 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-tw/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 看到反斜線 **`\\`**，它會將其後內容解讀為指令。這裡並沒有名為 \\\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://overleaf-pro.ayaka.space/latex/zh-tw/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.
