> 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/11-latex-error-mathrm-allowed-only-in-math-mode.md).

# LaTeX 错误：\mathrm 只允许在数学模式中使用

当我们在文本模式中使用一种只允许在数学模式中使用的字体时，就会出现此错误。使用此类字体时，请确保将它们放在美元符号中，如 `$...$`。要了解更多关于数学字体的信息，请随时查看我们的 [文档](/latex/zh-cn/shu-xue/12-mathematical-fonts.md)。下面显示了这些字体及其对应宏包的列表

|                  |                                                                                                                                                                        |
| ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| \mathnormal{...} | 这是数学斜体字体中的标准斜体字体。 `$\mathnormal{Hello world}$` 将得到与 `$Hello world$`.                                                                                                   |
| \mathrm{...}     | 这是标准的文本罗马字体。                                                                                                                                                           |
| \mathbf{...}     | 这会在数学模式下生成粗体字母。                                                                                                                                                        |
| \mathcal{...}    | 这是数学模式下的一种特殊书法字体。它只能用于大写字母，例如用于表示实数。 `\mathcal{R}` 将得到 ℝ。                                                                                                              |
| \mathsf{...}     | 这会在数学模式下生成无衬线字母。                                                                                                                                                       |
| \mathit{...}     | 这会生成文本斜体字母。根据所使用的具体类，它们可能与数学斜体字母不同。                                                                                                                                    |
| \mathtt{...}     | 这会生成打字机字体中的直立字母。                                                                                                                                                       |
| \mathbb{...}     | 这为大写字母提供一种“黑板粗体”字体。该 [**`amsfonts`**](https://www.ctan.org/pkg/amsfonts?lang=en) 宏包，或者等价地 该 [**`amssymb`**](https://www.ctan.org/pkg/amssymb?lang=en) 宏包必须加载，才能使用这种字体。 |
| \mathfrak{...}   | 这提供大小写形式的哥特字母。该 [**`amsfonts`**](https://www.ctan.org/pkg/amsfonts?lang=en) 宏包，或者等价地 该 [**`amssymb`**](https://www.ctan.org/pkg/amssymb?lang=en) 宏包必须加载，才能使用这种字体。      |
| euscript         | 该 [**`euscript`**](http://tug.ctan.org/fonts/amsfonts/doc/euscript.pdf) 宏包为我们提供了另一种称为 Euler script 的书法字母表。                                                             |

**上述数学字体的文本模式等价字体：**

| 数学模式字体           | 文本等价字体        |
| ---------------- | ------------- |
| \mathnormal{...} | \textit{...}. |
| \mathrm{...}     | \text{...}    |
| \mathbf{...}     | \textbf{...}. |
| \mathcal{...}    | 没有对应的文本模式字体。  |
| \mathsf{...}     | \textsf{...}. |


---

# 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/11-latex-error-mathrm-allowed-only-in-math-mode.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.
