> 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/ja/xiang-xi-ji-shi/39-step-3-replacing-latex-s-default-fonts-with-variable-fonts.md).

# ステップ 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)

このステップでは、fontspecパッケージの3つのコマンドを紹介します。これらは、LaTeXの既定フォントを可変フォントに置き換えるために使います。

## fontspec を使って LaTeX の既定フォントを変更する

次の fontspec パッケージのコマンドを使って、LaTeX の既定フォントを好みの可変フォントに置き換えます：

* `\setmainfont{⟨font⟩}[⟨font features⟩]` 本文で使用するフォントを設定します。
* `\setsansfont{⟨font⟩}[⟨font features⟩]` サンセリフ体フォントを設定します。
* `\setmonofont{⟨font⟩}[⟨font features⟩]` 等幅フォントを設定します。

これらのコマンドはそれぞれ2つの要素から成ります：

* `⟨font⟩`：波括弧で囲まれた必須引数 `{...}`。使用したいフォントを指定し、フォント名またはフォントファイル名として与えます。
* `⟨font features⟩`：角括弧で囲まれた省略可能引数 `[...]`。可変フォントの設定を含む、フォント固有の機能を有効にするために使います。

これらのコマンドについては、チュートリアルの後半でさらに詳しく説明します。

## チュートリアルプロジェクトの可変フォントを有効にする方法

次の手順に従って、プロジェクトの可変フォントを有効化して使用します。

1. 初期のチュートリアルプロジェクトを開き、次のコードを文書のプリアンブルに貼り付けて更新します。—次の行の後に貼り付けてください `\usepackage{fontspec}`.

```latex
% 文書ファミリの本文フォント
\setmainfont{NotoSerif-VariableFont-wdth-wght.ttf}
% 文書ファミリーのサンセリフフォント
\setsansfont{NotoSans-VariableFont-wdth-wght.ttf}
% 文書ファミリーの等幅フォント
\setmonofont{RobotoMono-VariableFont-wght.ttf}
```

![文書のプリアンブルに LaTeX コードを貼り付ける場所を示した画像](/files/dfc030b1353e59f3dd01e95e90965ee5cdee10ca)

4. 更新したプロジェクトを再コンパイルし、可変フォントで組版します。次の問題に気づくはずです：

* 組版された文書には、太字や斜体のテキストがなくなっています。
* 「未定義のフォントシェイプ」の警告が3件表示されます：

![LaTeX のフォント不足警告を示した画像。](/files/e413eb44550f683cb91ee4722c1c74d0aa402ae3)

## なぜ「未定義のシェイプ」の警告が表示されるのですか？

可変フォントの初期設定は *非常に* 基本的なもので、立体の中間ウェイトのフォントしか有効になっていません。その結果、LaTeX は「未定義のシェイプ」警告を出し、文書で使われている太字、太字斜体、標準斜体の組版に必要なフォントにもうアクセスできないことを知らせます。

## LaTeX の「未定義のシェイプ」警告を理解する

ステップ2で説明したように、LaTeX は各テキストフォントを encoding、family、series、shape、size の5つの属性で分類します。encoding、family、series、shape の組み合わせが既知の「実際の」フォントに対応しないフォントを使おうとすると、LaTeX は「シェイプが見つからない」警告を出します。これらの警告は、必要な属性を備えたフォントを設定することで防げます。

### これらの警告の構成

各警告は次の形式になります

``フォントシェイプ `*encoding/family name/series/shape*' が未定義です``

。以下の図に示すとおりです：

![LaTeX のシェイプ不足警告の構成を示した画像](/files/58b03d36c2b9359214a959854aa5e0b895c39fd1)

### これらの警告は何を示しているのでしょうか？

以下の各警告について、下で説明します。

![LaTeX のフォント不足警告を示した画像。](/files/e413eb44550f683cb91ee4722c1c74d0aa402ae3)

1. **``フォントシェイプ `TU/NotoSerif-VariableFont-wdth-wght.ttf(0)/b/n' が未定義です``**

LaTeX は次の属性の組み合わせを持つフォントにアクセスできません：

* *エンコーディング*: **`TU`** （Unicode）
* *のファミリ*: `**NotoSerif-VariableFont-wdth-wght.ttf(0)**`—これは、\setmainfont コマンドを使ったときに fontspec パッケージが作成した長い family 名です。family 名については連載の後半で扱います。
* *シリーズ*: **`b`** → **b**ボールド *重さ*, **m**ミディアム *width* （the **m** は省略されます）。
* shape: **`n`** → **n**ノーマル（upright） *シェイプ。*

LaTeX には **b**ボールドウェイト、 **m**ミディアム幅（series）、および **n**ノーマル（upright）シェイプのフォントが、次の `NotoSerif-VariableFont-wdth-wght.ttf(0)` family。

4. **``フォントシェイプ `TU/NotoSerif-VariableFont-wdth-wght.ttf(0)/b/it' が未定義です``**

LaTeX は次の属性の組み合わせを持つフォントにアクセスできません：

* *エンコーディング*: **`TU`** （Unicode）
* *のファミリ*: `**NotoSerif-VariableFont-wdth-wght.ttf(0)**`*.*
* *シリーズ*: `**b**` → **b**ボールドウェイト、 **m**ミディアム幅（the **m** は省略されます）。
* *シェイプ*：it → 斜体シェイプ。

LaTeX には **b**ボールドウェイト、 **m**ミディアム幅（series） **it**イタリック（shape）のフォントが、次の `NotoSerif-VariableFont-wdth-wght.ttf(0)` family。

8. ``**フォントシェイプ `TU/NotoSerif-VariableFont-wdth-wght.ttf(0)/m/it' が未定義です**``

LaTeX は次のパラメータの組み合わせを持つフォントにアクセスできません：

* encoding: TU（Unicode）
* family: NotoSerif-VariableFont-wdth-wght.ttf(0)
* series: m → 中間ウェイト、中間幅（m が1文字だけ使われていることに注意）
* shape: it → 斜体シェイプ

LaTeX には、NotoSerif-VariableFont-wdth-wght.ttf(0) family に中間ウェイト・中間幅（series）の斜体（shape）フォントがありません。

## 次のステップで

ステップ4〜6では、可変フォントを設定して不足しているフォントシェイプを提供することで、これらの警告を解消します。

[はじめに](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/ja/xiang-xi-ji-shi/39-step-3-replacing-latex-s-default-fonts-with-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.
