> 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/29-how-to-use-opentype-variable-fonts-with-latex.md).

# 如何在 LaTeX 中使用 OpenType 可變字型

[簡介](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 中安裝、設定與使用 OpenType 可變字型，重點放在 LuaLaTeX 與 [fontspec 套件](https://ctan.org/pkg/fontspec?lang=en)。透過一個導引式的 [Overleaf 專案](https://www.overleaf.com/8438931911svtqtnmfvsrp#28008d)，你將循序完成逐步指示，涵蓋實作技巧與必要背景知識，確保你能自信地在 LaTeX 文件中使用可變字型。一路上，你也會建立對 LaTeX 字型更廣泛的理解，包括如何透過設定適當的可變字型來解決「未定義的字型形狀」警告。

可變字型在 LaTeX 文件設計中提供無可比擬的彈性，讓你可以調整字重與字寬等字型屬性，進而提升文字呈現與可讀性。它們也有助於解決排版問題，例如在給定空間中排入更多文字。請注意，本系列僅聚焦於文字字型，因為用於數學排版的可變字型目前尚不可用。

### 教學內容

* 可變字型簡介（本文）
* [步驟 1：設定一個可使用可變字型的 Overleaf 專案](/latex/zh-tw/shen-ru-wen-zhang/37-step-1-setting-up-an-overleaf-project-to-use-variable-fonts.md)
* [步驟 2：LaTeX 字型簡介](/latex/zh-tw/shen-ru-wen-zhang/38-step-2-an-introduction-to-latex-fonts.md)
* [步驟 3：以可變字型取代 LaTeX 的預設字型](/latex/zh-tw/shen-ru-wen-zhang/39-step-3-replacing-latex-s-default-fonts-with-variable-fonts.md)
* [步驟 4：如何使用 fontspec 設定斜體可變字型](/latex/zh-tw/shen-ru-wen-zhang/40-step-4-how-to-configure-an-italic-variable-font-using-fontspec.md)
* [步驟 5：LaTeX 字型字重與可變字型的命名實例](/latex/zh-tw/shen-ru-wen-zhang/41-step-5-latex-font-weights-and-named-instances-of-variable-fonts.md)
* [步驟 6：使用可變字型為 Overleaf 專案加入粗體字型](/latex/zh-tw/shen-ru-wen-zhang/42-step-6-using-variable-fonts-to-add-bold-fonts-to-an-overleaf-project.md)
* [步驟 7：在 LaTeX 中使用 Noto Sans 與 Roboto Mono 可變字型](/latex/zh-tw/shen-ru-wen-zhang/43-step-7-using-noto-sans-and-roboto-mono-variable-fonts-with-latex.md)
* [步驟 8：如何建立一個簡單的 LaTeX 套件來設定你的可變字型](/latex/zh-tw/shen-ru-wen-zhang/44-step-8-how-to-create-a-simple-latex-package-to-configure-your-variable-fonts.md)
* [5 個展示如何在 LaTeX 中使用可變字型的 Overleaf 專案](/latex/zh-tw/shen-ru-wen-zhang/35-overleaf-projects-showing-how-to-use-variable-fonts-with-latex.md)

### 可變字型簡介

對於排版師、設計師與字型愛好者而言，2016 年 9 月 14 日是值得記住的一天。就在那天，Microsoft、 [Google](https://opensource.googleblog.com/2016/09/introducing-opentype-font-variations.html), [Adobe](https://blog.typekit.com/2016/09/14/variable-fonts-a-new-kind-of-font-for-flexible-design/)，和 Apple [公開宣布](https://youtu.be/6kizDePhcFU?feature=shared\&t=250) 一種名為 [OpenType Font Variations](https://medium.com/variable-fonts/https-medium-com-tiro-introducing-opentype-variable-fonts-12ba6cd2369)的新字型格式， *更常被稱為* 或簡稱 *可變字型*.

傳統上，每種字型樣式，例如 regular、bold、semi-bold、extra bold、condensed、bold-condensed 等，都需要獨立的字型檔，但如今已不再需要。OpenType 可變字型是一項令人印象深刻的技術，允許單一字型檔透過調整內建參數的值來產生多種字型樣式，這些參數稱為 *設計軸*。以下影片使用 Google 的 [Noto Serif 可變字型](https://fonts.google.com/noto/specimen/Noto+Serif/tester).

{% embed url="<https://videos.ctfassets.net/nrgyaltdicpt/3OhDBHA95DciCRVRgrF4wp/18f8c3f6d15109bf307c48bde9d7c879/VariableFonts.mp4>" %}

Google 的 Noto Serif 有兩個設計軸：字寬與字重，但其他字型可能只有一個軸或多個軸——例如，一款名為 [Recursive](https://fonts.google.com/specimen/Recursive/tester) 的可變字型有五個軸， [有些甚至更多](https://www.axis-praxis.org/specimens/decovar)。字型開發者會決定軸的數量及其設計效果。

### 關於設計軸的一些註記

若要在 LaTeX（具體來說是 fontspec 與 LuaLaTeX）中使用可變字型，你需要了解以下內容。

* 每個設計軸都以一個四個字元的簡短「標記」以及一個更長、較具描述性的名稱來識別。
* OpenType 可變字型規格提供了 [五個已註冊（「標準」）的軸](https://learn.microsoft.com/en-us/typography/opentype/spec/dvaraxisreg#registered-axis-tags):

|      |      |
| ---- | ---- |
| 標記   | 名稱   |
| ital | 斜體   |
| opsz | 視覺尺寸 |
| slnt | 傾斜   |
| wdth | 寬度   |
| wght | 字重   |

* 從 [版本 2.9a](https://github.com/latex3/fontspec/releases/tag/v2.9a)中使用時， [fontspec 套件](https://ctan.org/pkg/fontspec?lang=en) 開始，可以使用名稱來設定標準軸的值，例如 `Weight=400`.
* 字型建立者可自由建立並命名額外的設計軸。fontspec 提供了使用其四字元標記來設定任何設計軸值的功能。
* 設計軸的值範圍從最小值到最大值，而步長由字型的建立者決定。若要在 LaTeX（LuaLaTeX）中使用可變字型，你需要知道它的各個軸，以及其最小值、最大值與增量（步長）值。
* 目前，可變字型僅能用於文件的文字內容——尚沒有可變數學字型。
* Google 維護了一份 [設計軸清單](https://fonts.google.com/variablefonts#axis-definitions) ，列出其提供字型目前使用的設計軸，包括四字母設計標記、完整名稱，以及該軸作用的定義。

### 可變字型需要 LuaLaTeX 與 fontspec 套件

截至 2024 年 8 月，只有 LuaLaTeX [編譯器](/latex/zh-tw/zhi-shi-ku/026-changing-compiler.md) 支援 OpenType 可變字型——pdfLaTeX 與 XeLaTeX 不支援。

在 LuaLaTeX 中使用 OpenType 字型需要 fontspec 套件，它提供使用者層級的命令，以存取一套較低層、較技術性的字型載入系統，稱為 [luaotfload](https://ctan.org/pkg/luaotfload?lang=en)。雖然直接使用 luaotfload 的功能完全可行，但大多數人偏好 fontspec 的簡便與易用。

[TeX Live 2024](https://www.overleaf.com/blog/tex-live-2024-is-now-available) 包含於 2024 年 2 月 13 日發布的 fontspec 2.9a 版，增加了額外功能，使使用可變字型更加容易。

### 我可以在哪裡找到並探索一些可變字型？

造訪 Google Fonts 是絕佳的起點——尤其是 [列出字型家族及其設計軸的頁面](https://fonts.google.com/variablefonts)。一旦找到感興趣的字型，請前往其 *Type tester* 頁面，並使用提供的控制項調整其設計軸。

該 [Axis-Praxis 網站](https://www.axis-praxis.org) 可讓你試驗眾多可變字型，其中一些展示了有趣的設計可能性——包括 [Decovar](https://www.axis-praxis.org/specimens/decovar)，這是一款具有 12 個設計軸的實驗性字型。你也可以將可變字型上傳到 Axis-Praxis，並使用此平台自動產生的控制項來測試它們，以變更設計軸值。

另一個有幫助的網站是 <https://v-fonts.com/>，其對自身目的的描述是：「一個用來尋找與試用可變字型的簡單資源。」

[簡介](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-tw/shen-ru-wen-zhang/29-how-to-use-opentype-variable-fonts-with-latex.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.
