> 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/shen-ru-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/87ca7e0d4431adc1c3e55fea47b170afae8aba07)

### 什麼是可變字型的「實例」？

一個 *實例* 可變字型中的一組特定軸值，用來建立眾多可能樣式變化中的一種。為一組軸值命名，就定義了一個具名實例。具名實例的資料會儲存在可變字型檔案中。

## 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，但如果它不管用（看起來不好看），那就可以很容易地改成其他值——這就是排版控制，這正是可變字型的優點。

### 設定中等字重的可變字型值

在加入粗體字型之前，我們應先為專案中使用的 Noto Serif 字型設定 LaTeX 中等（常規）字重的值。

fontspec 提供兩個功能來設定字重軸的值：

* Weight = ⟨value⟩ 會將字重軸設為任何支援的 ⟨value⟩
* Instance = ⟨named instance⟩ 會將字重設為 ⟨named instance⟩ 設定所定義的值

### 將中等字重設為 400

要將中等字重設為 400，請將目前專案的 \setmainfont 指令編輯為以下內容

```
\setmainfont{NotoSerif-VariableFont-wdth-wght.ttf}[
Weight=400,
% 或者我們也可以用以下內容取代 Weight=400
% Instance=Regular,
ItalicFont=NotoSerif-Italic-VariableFont-wdth-wght.ttf
]
```

斜體字型的字重軸值也會是 400。

如果重新編譯文件之後，你不喜歡排版結果，可以試試以下做法：

* 為 Weight 軸使用不同的值
* 使用 `\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://overleaf-pro.ayaka.space/latex/zh-tw/shen-ru-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.
