> 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/shen-ru-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 Moder](https://en.wikipedia.org/wiki/Computer_Modern)n 系列（用于 pdfLaTeX）或 [Latin Modern](https://tug.org/FontCatalogue/latinmodernroman/) 系列（用于 XeLaTeX 和 LuaLaTeX）的字体。

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

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

下面是这五个参数的摘要。

* **编码**：文本文件中存储的整数（字符代码）值与它们所代表字符之间的映射。LuaLaTeX 和可变字体使用 Unicode 编码，LaTeX 将其记作“TU”。
* **族**：赋予一套共享设计的字体的名称。我们将在使用 fontspec 配置可变字体时探讨字体族。
* **系列**：系列值用于标识字体的字重（粗细）和宽度（压缩程度）。每个 LaTeX 字体系列值都定义为 `⟨字重⟩⟨字宽⟩` 的组合，取自下表， *除了* 当字重和字宽都为中等时会省略 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

回想一下，每个系列标识符都定义为一个 `⟨字重⟩⟨字宽⟩` 对，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://overleaf-pro.ayaka.space/latex/zh-cn/shen-ru-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.
