> 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/14-latex-error-environment-xxx-undefined.md).

# LaTeX 錯誤：環境 XXX 未定義

如果你嘗試使用 LaTeX 無法辨識的環境，你將會產生如下所示的錯誤訊息：

main.tex，第 5 行

LaTeX 錯誤：環境 equation\* 未定義。

請參閱 LaTeX 手冊或 LaTeX Companion 以獲得說明。輸入 H 以立即取得幫助。... l.5 \begin{equation\*} 你的指令已被忽略。輸入 I 以用另一個指令取代，或在沒有它的情況下繼續。

## 常見原因

**你忘了載入某個套件**

此錯誤的一個常見原因是，你嘗試使用的環境屬於某個特定套件，但你忘了在前言區載入該套件。這方面的一個例子是 **`align`** 環境。 **`align`** 環境是 **`amsmath`** 套件的一部分。因此，每當你使用 **`align`** 環境時，你都必須包含 **`\usepackage{amsmath}`** 在前言區，如下所示：

```latex
% 在你的前言區

\usepackage{amsmath}

% 在你的主 .tex 檔案中

\begin{align}
2x + 3y &= 7\\
5x - 2y &= 2
\end{align}
```

![Align.PNG](/files/e306b3bcee7b932828b31a53708f508c719cb3b2)

如果你沒有包含 **`\usepackage{amsmath}`** 在前言區中，你就會產生一則錯誤訊息。

**你拼錯了這個環境名稱：**

另一個常見的此錯誤範例，是在某個環境拼寫正確時。這個錯誤的範例如下所示：

```latex
\begin{lisQ}
    \item 這是一個清單項目
    \item 這是另一個清單項目
\end{lisQ}
```

這裡會出現錯誤，因為 **`清單`** 環境被誤寫成 **`lisQ`**。要修正這個問題，只要在呼叫特定環境時檢查你的拼字即可。

**環境不存在**

這個錯誤出現的另一種情況，是你嘗試使用一個不存在的環境。若要進一步了解 LaTeX 中允許的環境，以及如何建立你自己的環境，請查看我們的 [文件](/latex/zh-tw/zhi-ling/02-environments.md).


---

# 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/14-latex-error-environment-xxx-undefined.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.
