> 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/zi-ti/02-font-typefaces.md).

# 字体字形

## 引言

默认情况下，LaTeX 使用以下字体族来排版文档 $$\text{Computer Modern}$$ 字体族，但你可以根据需要或偏好使用 LaTeX 宏包来使用不同的字体。

## 更改文档的默认字体

例如，添加 `\usepackage{tgbonum}` 到文档导言区，LaTeX 将使用 TEX Gyre Bonum 字体族来排版你的文档：

```latex
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{tgbonum}

\begin{document}
本文档是一个用于测试字体的示例文档
字体族和字体字形。

这段文字使用了不同的字体字形
\end{document}
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Change+LaTeX+fonts\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%5BT1%5D%7Bfontenc%7D%0A%5Cusepackage%7Btgbonum%7D%0A%0A%5Cbegin%7Bdocument%7D%0AThis+document+is+a+sample+document+to+test+font+%0Afamilies+and+font+typefaces.%0A%0AThis+text+uses+a+different+font+typeface%0A%5Cend%7Bdocument%7D)

下图显示了上面示例生成的输出：

![FontTypefacesEx1OLV2.png](/files/aeaefcf794c427f9dac3cd7d6d0c72cd4c47a1a1)

## 更改默认字体字形

也可以为文档中的特定元素更改字体。

```latex
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{tgbonum}

\begin{document}
本文档是一个用于
测试字体族和字体字形的示例文档。

{\fontfamily{qcr}\selectfont
这段文字使用了不同的字体字形
}
\end{document}
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Change+LaTeX+fonts\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%5BT1%5D%7Bfontenc%7D%0A%5Cusepackage%7Btgbonum%7D%0A%0A%5Cbegin%7Bdocument%7D%0AThis+document+is+a+sample+document+to+%0Atest+font+families+and+font+typefaces.%0A%0A%7B%5Cfontfamily%7Bqcr%7D%5Cselectfont%0AThis+text+uses+a+different+font+typeface%0A%7D%0A%5Cend%7Bdocument%7D)

下图显示了上面示例生成的输出：

![FontTypefacesEx2.png](/files/b784285e18cc2935d97a5500e6f1d962a0accbbd)

命令 `\fontfamily{qcr}\selectfont` 将设置 *TeX Gyre Cursor* 字体字形，其字体代码为 `qcr`，用于花括号内的文本。还有更多可用的 LaTeX 字体字形，参见 [参考指南](#reference-guide).

常用的 LaTeX 字体字形源自四个字体族：

* *Computer Modern* （标准 LaTeX 类中的默认字体）：CM Roman、CM Sans Serif、CM Typewriter
* *Latin Modern*：LM Roman、LM Sans Serif、LM Typewriter、LM Dunhill
* *Post Script Fonts*：Times、Utopia/Fourier、Palatino、Bookman、Helvetica、Courier
* *TeX Gyre*

## 参考指南

**罗马体、无衬线体和打字机体字形**

| 字体                           | “字体宏包名称”             | “字体代码” | 示例                                                                    |
| ---------------------------- | -------------------- | ------ | --------------------------------------------------------------------- |
| Computer Modern Roman        |                      | `cmr`  | ![Typeface-cmr.png](/files/17354bb40426f23200de9b8f5a7be1fb142224eb)  |
| Latin Modern Roman           | `lmodern`            | `lmr`  | ![Typeface-lmr.png](/files/e0141a67eb1f079ba3efc12507dc0ea23dd94e11)  |
| Latin Modern Dunhill         | `lmodern`            | `lmdh` | ![Typeface-lmdh.png](/files/700c279f249cad0587628762d42dfc17465fe140) |
| TeX Gyre Termes              | `tgtermes`           | `qtm`  | ![Typeface-qtm.png](/files/9fa80b58d80f573e3f4bbe4db2acec7dd2f27dec)  |
| TeX Gyre Pagella             | `tgpagella`          | `qpl`  | ![Typeface-qpl.png](/files/a918d84144293c9a244c0b066977ecc3d255a15d)  |
| TeX Gyre Bonum               | `tgbonum`            | `qbk`  | ![Typeface-qbk.png](/files/3f379e9811f6aad9df07096793ad408178454ea2)  |
| TeX Gyre Schola              | `tgschola`           | `qcs`  | ![Typeface-qsc.png](/files/bf368f6b6d80864a020c73a6010a024024f05074)  |
| Times                        | `mathptmx`           | `ptm`  | ![Typeface-ptm.png](/files/154fd747c1b1bb7e2a69d6fd482cccc740d3f63a)  |
| Utopia / Fourier             | `utopia` / `fourier` | `put`  | ![Typeface-put.png](/files/af082b31a58efe2b8eb2c3e0c52ff3b91afa8983)  |
| Palatino                     | `palatino`           | `ppl`  | ![Typeface-ppl.png](/files/fa88c27e0c84d0ceee16b86bf80cbed491d92ea2)  |
| Bookman                      | `bookman`            | `pbk`  | ![Typeface-pbk.png](/files/bb7aff36f01a13ebb86347db12d2d9be0a11fa22)  |
| Charter                      | `charter`            | `bch`  | ![Typeface-bch.png](/files/20061da81ed69b201cb48c3f1369a55b761c634a)  |
| Computer Modern Sans Serif   |                      | `cmss` | ![Typeface-cmss.png](/files/25ccb6de181b5db386bd3cef0f697379c1f22978) |
| Latin Modern Sans Serif      | `lmodern`            | `lmss` | ![Typeface-lmss.png](/files/9d824f93e3b848b9320fafacf47e0b214e14b8d7) |
| TeX Gyre Adventor            | `tgadventor`         | `qag`  | ![Typeface-qag.png](/files/80856665e486c3d43f823bec377cef4719a0d905)  |
| TeX Gyre Heros               | `tgheros`            | `qhv`  | ![Typeface-qhv.png](/files/ca5993ac75339b27547fb511255653f993f6e0cc)  |
| Helvetica                    | `helvet`             | `phv`  | ![Typeface-phv.png](/files/c0a3d0fe489b515a253a28896065f3591e40b89c)  |
| Computer Modern Typewriter   |                      | `cmtt` | ![Typeface-cmtt.png](/files/107e671b677b606e7b0e3895c915c5dc17bc5b27) |
| Latin Modern Sans Typewriter | `lmodern`            | `lmtt` | ![Typeface-lmtt.png](/files/bd2ed592b2bb9ec4678e70880cfd82d571385302) |
| TeX Gyre Cursor              | `tgcursor`           | `qcr`  | ![Typeface-qcr.png](/files/ff50ce55353c1acd47d3cd28f8023f8c2c8ff281)  |
| Courier                      | `courier`            | `pcr`  | ![Typeface-pcr.png](/files/c7cf852e8191e9f0a238b140597f76d6cbb3f298)  |

另请参见 [LaTeX 字体目录](https://tug.org/FontCatalogue/)，不过请注意，目录中列出的并非所有字体都以允许作为 TeX Live 一部分分发的许可发布，因此并非所有这些字体都可在 Overleaf 上使用。

## 进一步阅读

更多信息请参见：

* [LaTeX 字体目录](https://tug.org/FontCatalogue/).
* [粗体、斜体和下划线](/latex/zh-cn/latex-ji-chu/03-bold-italics-and-underlining.md)
* [字体大小、字体族和样式](/latex/zh-cn/zi-ti/01-font-sizes-families-and-styles.md)
* [使用 XeLaTeX 支持现代字体](/latex/zh-cn/zi-ti/03-xelatex.md)
* [段落格式设置](/latex/zh-cn/ge-shi-hua/04-articles-how-to-change-paragraph-spacing-in-latex.md)
* [换行和空格](/latex/zh-cn/ge-shi-hua/05-line-breaks-and-blank-spaces.md)
* [多栏排版](/latex/zh-cn/ge-shi-hua/09-multiple-columns.md)
* [单面和双面文档](/latex/zh-cn/ge-shi-hua/08-single-sided-and-double-sided-documents.md)
* [大型项目中的管理](/latex/zh-cn/wen-dang-jie-gou/07-management-in-a-large-project.md)
* [多文件 LaTeX 项目](/latex/zh-cn/wen-dang-jie-gou/08-multi-file-latex-projects.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://ayakaleaf-pro.ayaka.space/latex/zh-cn/zi-ti/02-font-typefaces.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.
