> 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/shen-du-wen-zhang/38-step-2-an-introduction-to-latex-fonts.md).

# 步骤 2：LaTeX 字体简介

[引言](https://www.overleaf.com/learn/latex/Articles/How_to_use_OpenType_variable_fonts_with_LaTeX?preview=true) [第1步](https://www.overleaf.com/learn/latex/Articles/Step_1:_Setting_up_an_Overleaf_project_to_use_variable_fonts?preview=true) [第2步](https://www.overleaf.com/learn/latex/Articles/Step_2:_An_introduction_to_LaTeX_fonts?preview=true) [第3步](https://www.overleaf.com/learn/latex/Articles/Step_3:_Replacing_LaTeX’s_default_fonts_with_variable_fonts?preview=true) [第4步](https://www.overleaf.com/learn/latex/Articles/Step_4:_How_to_configure_an_italic_variable_font_using_fontspec?preview=true) [第5步](https://www.overleaf.com/learn/latex/Articles/Step_5:_LaTeX_font_weights_and_named_instances_of_variable_fonts?preview=true) [第6步](https://www.overleaf.com/learn/latex/Articles/Step_6:_Using_variable_fonts_to_add_bold_fonts_to_an_Overleaf_project?preview=true) [第7步](https://www.overleaf.com/learn/latex/Articles/Step_7:_Using_Noto_Sans_and_Roboto_Mono_variable_fonts_with_LaTeX?preview=true) [第8步](https://www.overleaf.com/learn/latex/Articles/Step_8:_How_to_create_a_simple_LaTeX_package_to_configure_your_variable_fonts?preview=true) [示例和项目](https://www.overleaf.com/learn/latex/Articles/Overleaf_projects_showing_how_to_use_variable_fonts_with_LaTeX?preview=true)

本步骤介绍 LaTeX 的默认字体，并总结 LaTeX 用于对字体属性进行分类并定义“字体形状”的字体选择方案。本文讨论的主题将在本教程的其余部分中引用。花几分钟阅读本页将帮助你充分利用本教程系列。

### LaTeX 的默认文档正文字体

LaTeX 使用三组字体来排版任何文档的文本。这些字体集也称为 *文档字体族*；每个字体族由一套具有共同设计特征的字体组成：

* **正文家族**：用于文档正文的字体，通常采用 [衬线设计](https://en.wikipedia.org/wiki/Serif).
* [**无衬线体**](https://en.wikipedia.org/wiki/Sans-serif) **族**：常用于排版章节标题和其他醒目文本的字体。
* [**等宽**](https://en.wikipedia.org/wiki/Monospaced_font) **族**：通常用于排版计算机代码及类似内容的字体。

默认情况下，LaTeX 使用来自 [Computer Modern](https://en.wikipedia.org/wiki/Computer_Modern)系列（用于 pdfLaTeX）或 [Latin Modern](https://tug.org/FontCatalogue/latinmodernroman/) 系列（用于 XeLaTeX 和 LuaLaTeX）。

### LaTeX 如何对其字体进行分类（组织）

可用于文本排版的字体选择极其丰富，设计风格多样，旨在满足特定的排版目标。为了驾驭这种多样性，任何灵活而合理的字体选择过程都需要一个结构良好、可根据设计特征对字体进行组织和分类的系统。LaTeX 通过其新字体选择方案（New Font Selection Scheme，现称 NFSS2）来应对这一挑战，它根据五个参数对每种文本字体进行分类： *编码*, *族*, *系列*, *形状*，以及 *字号*.

下面是这五个参数的概述。

* **编码**：文本文件中存储的整数（字符代码）值与它们所表示字符之间的映射。LuaLaTeX 和可变字体使用 Unicode 编码，LaTeX 将其表示为“TU”。
* **族**：用于表示一套共享设计的字体的名称。我们将在使用 fontspec 配置可变字体时探讨字体族。
* **系列**：系列值用于标识字体的字重（粗细）和字宽（压缩程度）。每个 LaTeX 字体系列值都定义为一个 `⟨weight⟩⟨width⟩` 由下表中的组合构成， *只是* 当字重和字宽都为中等时，m 才会被省略，在这种情况下会使用单个 `m` 。

下表列出了 LaTeX 的标准字宽和字重标识符。

|             |        |             |      |                          |
| ----------- | ------ | ----------- | ---- | ------------------------ |
| **字重**      | **字宽** |             |      |                          |
| *LaTeX 标识符* | *名称*   | *LaTeX 标识符* | *名称* | *“正常”字宽的百分比*<sup>†</sup> |
| ul          | 超轻     | uc          | 极度压缩 | 50%                      |
| el          | 特轻     | ec          | 超压缩  | 62.5%                    |
| l           | 细体     | c           | 压缩   | 75%                      |
| sl          | 半细     | sc          | 半压缩  | 87.5%                    |
| m           | 中等（常规） | m           | 中等   | 100%                     |
| sb          | 半粗体    | sx          | 半扩展  | 112.5%                   |
| b           | 粗体     | x           | 扩展   | 125%                     |
| eb          | 特粗体    | ex          | 超扩展  | 150%                     |
| ub          | 超粗体    | ux          | 极度扩展 | 200%                     |

<sup>†</sup>正如 LaTeX 官方文档所建议的那样（见 `[fntguide.pdf](https://ctan.org/pkg/fntguide?lang=en)`).

下面是一些字体系列示例：

* **m**：中等字重和中等字宽。
* **b**：粗字重和中等字宽——它“应该”写作 **bm** 但 **m** （表示中等字宽的）会被省略。
* **c**：中等字重、压缩字宽——它“应该”写作 **mc** 但 **m** （表示中等字重的）会被省略。
* **sb**：半粗字重、中等字宽——它“应该”写作 **sbm** 但 **m** （表示中等字宽的）会被省略。
* **bx**：结合了字重 **b** （粗体）和字宽 **x** （扩展）。它用于选择当前字体族的粗扩展字体（如果该字体存在）。
* **sbc**：结合了字重 **sb** （半粗）和字宽 **c** （压缩）。它用于选择当前字体族的半粗压缩字体（如果该字体存在）。
* **形状**：此参数用于选择字体形式（形状），如斜体、倾斜体、小型大写和花体大写。LaTeX 定义了一组标准形状：

|           |               |
| --------- | ------------- |
| **形状标识符** | **形状名称**      |
| n         | 正常形状（直立）      |
| it        | 斜体形状          |
| sl        | 倾斜（斜向）形状      |
| sw        | 花体字形          |
| ui        | 直立斜体形状（罕见/少见） |
| sc        | 小型大写形状        |
| scit      | 斜体小型大写形状      |
| scsl      | 倾斜小型大写形状      |

* **字号**：使用字体时的字号。LaTeX 有若干预定义的字号命令，例如 `\tiny`, `\small`, `\normalsize`, `\large`, `\Large`，等等。你也可以使用 `\fontsize{size}{baselineskip}` 其中 `字号` 表示字体大小，而 `baselineskip` 是行距。

### （可选阅读）特殊系列和形状

首次阅读时可以跳过本节。Overleaf 创建了一个 [演示这些特殊系列和形状的项目](https://www.overleaf.com/1941895198cqjzyhzvxhwz#794ae2) （见排版文档第 6 节）。

#### 系列标识符：m? 和 ?m

回想一下，每个系列标识符都定义为一个 `⟨weight⟩⟨width⟩` 对，LaTeX 还提供了两个用于选择字体字重和字宽的附加标识符：

* `m?` 表示选择中等字重，但保持当前字宽设置不变。
* `?m` 表示保持当前字重不变，但选择中等字宽。

#### “虚拟”形状

LaTeX 支持两种所谓的“虚拟”形状。“虚拟”一词表示它们仅打算作为 `\fontshape` 命令的参数——这些形状并不是实际存在的字体。

| **虚拟形状标识符** | **操作**      | **命令**          | **声明**      | **说明**                                                                               |
| ----------- | ----------- | --------------- | ----------- | ------------------------------------------------------------------------------------ |
| `up`        | 返回到直立形状。    | `\textup{...}`  | `\upshape`  | 它会将形状改为直立，但会保留小型大写形状。例如，up 会将 `scit` 形状改为 `sc`。特殊情况：如果当前形状是 `sc` 那么 up 会改为正常形状（`n`). |
| `ucl`       | 返回到大小写字母形状。 | `\textulc{...}` | `\uclshape` | 将字体形状改为大小写字母形状，但不会改变斜体、倾斜或花体形状。                                                      |

## 在下一步中

第 3 步将展示如何用可变字体替换 LaTeX 的默认字体。

[引言](https://www.overleaf.com/learn/latex/Articles/How_to_use_OpenType_variable_fonts_with_LaTeX?preview=true) [第1步](https://www.overleaf.com/learn/latex/Articles/Step_1:_Setting_up_an_Overleaf_project_to_use_variable_fonts?preview=true) [第2步](https://www.overleaf.com/learn/latex/Articles/Step_2:_An_introduction_to_LaTeX_fonts?preview=true) [第3步](https://www.overleaf.com/learn/latex/Articles/Step_3:_Replacing_LaTeX’s_default_fonts_with_variable_fonts?preview=true) [第4步](https://www.overleaf.com/learn/latex/Articles/Step_4:_How_to_configure_an_italic_variable_font_using_fontspec?preview=true) [第5步](https://www.overleaf.com/learn/latex/Articles/Step_5:_LaTeX_font_weights_and_named_instances_of_variable_fonts?preview=true) [第6步](https://www.overleaf.com/learn/latex/Articles/Step_6:_Using_variable_fonts_to_add_bold_fonts_to_an_Overleaf_project?preview=true) [第7步](https://www.overleaf.com/learn/latex/Articles/Step_7:_Using_Noto_Sans_and_Roboto_Mono_variable_fonts_with_LaTeX?preview=true) [第8步](https://www.overleaf.com/learn/latex/Articles/Step_8:_How_to_create_a_simple_LaTeX_package_to_configure_your_variable_fonts?preview=true) [示例和项目](https://www.overleaf.com/learn/latex/Articles/Overleaf_projects_showing_how_to_use_variable_fonts_with_LaTeX?preview=true)


---

# 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/shen-du-wen-zhang/38-step-2-an-introduction-to-latex-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.
