> 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/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 这是一个列表项
    \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://overleaf-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.
