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

# LaTeX 錯誤：\mathrm 只能在數學模式中使用

當我們在文字模式中使用一種只允許在數學模式中使用的字型時，會出現此錯誤。使用這類字型時，請確保將它們置於美元符號內，例如 `$...$`。若想進一步了解數學字型，歡迎查看我們的 [說明文件](/latex/zh-tw/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://overleaf-pro.ayaka.space/latex/zh-tw/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.
