> 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/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 脚本体。                                                              |

**以上数学字体的文本等价形式：**

| 数学模式字体           | 文本等价形式        |
| ---------------- | ------------- |
| \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://overleaf-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.
