> 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/41-step-5-latex-font-weights-and-named-instances-of-variable-fonts.md).

# 步骤 5：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 的标准字重对应。

请确保打开在第4步中配置的教程项目。

## 设置设计轴值的两种方式

Google 的字体测试页面提供了两种设置可变字体设计轴值的方法：使用滑块，或使用包含名称和值的下拉列表。该 [Noto Serif 的测试页面](https://fonts.google.com/noto/specimen/Noto+Serif/tester) 提供一个范围从 100 到 900 的字重轴滑块，以及一个代表不同字重的命名实例列表。

![图片展示设置设计轴值的两种方式：使用滑块或命名实例](/files/8d8d744d8a981fb096401fbe8d2f3d183b912e0b)

### 什么是可变字体的“实例”？

一个 *实例* 可变字体的实例是一组特定的轴值，用于创建众多可能样式变体中的一种。为一组轴值命名就定义了一个命名实例。命名实例的数据存储在可变字体文件中。

## LaTeX 的字重名称

如第2步所述，LaTeX 定义了九种标准字重，每种都有一个简短标识符和一个较长的描述性名称：

|                 |                |
| --------------- | -------------- |
| **LaTeX 字重标识符** | **LaTeX 字重名称** |
| ul              | 超轻             |
| el              | 特轻             |
| l               | 细体             |
| sl              | 半细             |
| m               | 中等（常规）         |
| sb              | 半粗体            |
| b               | 粗体             |
| eb              | 特粗体            |
| ub              | 超粗体            |

Noto Serif 的字重轴值范围为 100 到 900，恰好以 100 为增量提供了九个命名实例值。每个命名实例都可以对应到 LaTeX 的九种标准字重之一，如下表所示。

|              |              |       |        |
| ------------ | ------------ | ----- | ------ |
| **LaTeX 字重** | **可变字体命名实例** |       |        |
| *LaTeX 标识符*  | *名称*         | *字重值* | *实例名称* |
| ul           | 超轻           | 100   | 细体     |
| el           | 特轻           | 200   | 特细     |
| l            | 细体           | 300   | 细体     |
| sl           | 半细           | 400   | 常规     |
| m            | 中等（常规）       | 500   | 中等     |
| sb           | 半粗体          | 600   | 半粗体    |
| b            | 粗体           | 700   | 粗体     |
| eb           | 特粗体          | 800   | 特粗体    |
| ub           | 超粗体          | 900   | 黑体     |

## 为 LaTeX 的“中等”（常规）字重选择一个值

在 LaTeX 中，“中等”和“常规”字重是同一个意思：也就是文档正文所使用的字重。这与 Noto Serif 的命名实例不同，其中 Regular 字重为 400，而 Medium 字重为 500。为 LaTeX 的中等字重选择哪个值由我们决定。我们先试试 400；如果效果不好（不够美观），也可以很容易地切换到其他值——这就是可变字体在排版控制上的优势。

### 将中等字重设置为 400

在添加粗体字体之前，我们应该为项目中使用的 Noto Serif 字体的 LaTeX 中等（常规）字重设置一个值。

fontspec 提供了两个用于设置字重轴值的功能：

* Weight = ⟨value⟩ 将字重轴设置为任何受支持的 ⟨value⟩
* Instance = ⟨named instance⟩ 将字重设置为由 ⟨named instance⟩ 设置定义的值

### 将中等字重设置为 400

要将中等字重设置为 400，请将当前项目的 \setmainfont 命令编辑为以下内容

```
\setmainfont{NotoSerif-VariableFont-wdth-wght.ttf}[
Weight=400,
% Or we can replace Weight=400 with
% Instance=Regular,
ItalicFont=NotoSerif-Italic-VariableFont-wdth-wght.ttf
]
```

斜体字体的字重轴值也将为 400。

如果在重新编译文档后你不喜欢排版结果，可以尝试以下方法：

* 为字重轴使用不同的值
* 使用以下内容尝试字号和行距： `\fontsize` 命令；例如，尝试写：

```
\fontsize{9}{11}\selectfont
```

紧接在 `\begin{document}`

## 在下一步中

在下一步中，我们将配置可变字体以提供粗体和粗斜体字体。


---

# 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/41-step-5-latex-font-weights-and-named-instances-of-variable-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.
