> 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/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/804dfcb28b681fece079c0a7e8ae90bebb39dfde)

如果你不在导言区包含 **`\usepackage{amsmath}`** ，就会生成一条错误信息。

**你把这个环境的拼写写错了：**

当环境的拼写本身是正确的时候，也会出现这种错误。下面展示了一个这样的错误示例：

```latex
\begin{lisQ}
    \item This is a list item
    \item This is another list item
\end{lisQ}
```

此处会出现错误，因为 **`list`** 环境被误写成了 **`lisQ`**。要修复这一点，只需在调用特定环境时检查拼写即可。

**不存在的环境**

此错误的另一种出现方式是，你试图使用一个不存在的环境。要了解 LaTeX 中允许使用的环境，以及如何创建自己的环境，请查看我们的 [文档](/latex/zh-cn/ming-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://ayakaleaf-pro.ayaka.space/latex/zh-cn/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.
