> 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/shu-xue/12-mathematical-fonts.md).

# 數學字型

## 簡介

某些數學元素需要使用包含特定樣式字元／符號的字型來排版；例如，通常會以黑板粗體字型表示實數（例如 $$\mathbb{R}$$），或以書法體字型表示拓撲空間（例如（$$\mathcal{T}$$）。本文展示在數學排版時如何使用不同的字型樣式，以下列範例開始：

```latex
令 \( \mathcal{T} \) 為一個拓撲空間，其基底定義為
\[
 \mathcal{B} = \{B_{\alpha} \in \mathcal{T}\, |\,  U = \bigcup B_{\alpha} \forall U \in \mathcal{T} \}
\]
```

[在 Overleaf 中開啟這個範例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Maths+typeface+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0ALet+%5C%28+%5Cmathcal%7BT%7D+%5C%29+be+a+topological+space%2C+a+basis+is+defined+as%0A%5C%5B%0A+%5Cmathcal%7BB%7D+%3D+%5C%7BB_%7B%5Calpha%7D+%5Cin+%5Cmathcal%7BT%7D%5C%2C+%7C%5C%2C++U+%3D+%5Cbigcup+B_%7B%5Calpha%7D+%5Cforall+U+%5Cin+%5Cmathcal%7BT%7D+%5C%7D%0A%5C%5D%0A%5Cend%7Bdocument%7D)

此範例會產生以下輸出：

![數學字型範例](/files/d7056bc65991e93f3f0e519b7d6663159ce22b4d)

使用某些數學字型樣式需要在 `\usepackage{amssymb}` 加入文件前言：請參見 [`amsfonts` 套件](https://ctan.org/pkg/amsfonts) 以取得更多資訊。

## 僅大寫字母字型

有些字型只支援有限數量的字元；這些字型通常表示某些特殊集合。例如，要以黑板粗體字體顯示 R，可以使用 `\(\mathbb{R}\)` 來產生 $$\mathbb{R}$$。下列範例展示書法體、哥德體與黑板粗體字型：

```latex
\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\begin{document}
\begin{align*}
RQSZ \\
\mathcal{RQSZ} \\
\mathfrak{RQSZ} \\
\mathbb{RQSZ}
\end{align*}
\end{document}
```

[在 Overleaf 中開啟這個範例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Using+different+math+fonts\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bamsmath%7D%0A%5Cusepackage%7Bamssymb%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cbegin%7Balign%2A%7D%0ARQSZ+%5C%5C%0A%5Cmathcal%7BRQSZ%7D+%5C%5C%0A%5Cmathfrak%7BRQSZ%7D+%5C%5C%0A%5Cmathbb%7BRQSZ%7D%0A%5Cend%7Balign%2A%7D%0A%5Cend%7Bdocument%7D)

此範例會產生以下輸出：

![排版數學時變更字型](/files/3b726dee65aa6c0f2d8c4c23bb9dc255d29017e7)

## 其他數學字型

可以為整個數學表達式設定不同的字型族：

```latex
\begin{align*}
3x^2 \in R \subset Q \\
\mathnormal{3x^2 \in R \subset Q} \\
\mathrm{3x^2 \in R \subset Q} \\
\mathit{3x^2 \in R \subset Q} \\
\mathbf{3x^2 \in R \subset Q} \\
\mathsf{3x^2 \in R \subset Q} \\
\mathtt{3x^2 \in R \subset Q}
\end{align*}
```

[在 Overleaf 中開啟這個範例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Using+a+font+family+for+mathematical+expressions\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bamsmath%7D%0A%5Cusepackage%7Bamssymb%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cbegin%7Balign%2A%7D%0A3x%5E2+%5Cin+R+%5Csubset+Q+%5C%5C%0A%5Cmathnormal%7B3x%5E2+%5Cin+R+%5Csubset+Q%7D+%5C%5C%0A%5Cmathrm%7B3x%5E2+%5Cin+R+%5Csubset+Q%7D+%5C%5C%0A%5Cmathit%7B3x%5E2+%5Cin+R+%5Csubset+Q%7D+%5C%5C%0A%5Cmathbf%7B3x%5E2+%5Cin+R+%5Csubset+Q%7D+%5C%5C%0A%5Cmathsf%7B3x%5E2+%5Cin+R+%5Csubset+Q%7D+%5C%5C%0A%5Cmathtt%7B3x%5E2+%5Cin+R+%5Csubset+Q%7D%0A%5Cend%7Balign%2A%7D%0A%5Cend%7Bdocument%7D)

此範例會產生以下輸出：

![排版數學時變更字型](/files/603bef0a2f19a0577da1bdb21b4466f8939ade6d)

在這種情況下，不僅字母，所有字元都會改變外觀；例如， `$\mathit{3x^2}$` 會將整個表達式斜體化，產生 $$\mathit{3x^2}$$.

## 延伸閱讀

更多資訊請參見

* [`amsfonts` 套件說明文件](https://ctan.org/pkg/amsfonts)
* [數學表達式](/latex/zh-tw/shu-xue/01-mathematical-expressions.md)
* [下標與上標](/latex/zh-tw/shu-xue/02-subscripts-and-superscripts.md)
* [粗體、斜體與底線](/latex/zh-tw/latex-ji-chu/03-bold-italics-and-underlining.md)
* [字型大小、字族與樣式](/latex/zh-tw/zi-xing/01-font-sizes-families-and-styles.md)
* [字型字體](/latex/zh-tw/zi-xing/02-font-typefaces.md)
* [文字對齊](/latex/zh-tw/ge-shi-hua/06-text-alignment.md)
* [LaTeX2ε 不那麼簡短的入門介紹](http://www.ctan.org/tex-archive/info/lshort/)


---

# 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/shu-xue/12-mathematical-fonts.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.
