> 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/in-depth-articles/35-overleaf-projects-showing-how-to-use-variable-fonts-with-latex.md).

# Overleaf projects showing how to use variable fonts with LaTeX

[Introduction](https://www.overleaf.com/learn/latex/Articles/How_to_use_OpenType_variable_fonts_with_LaTeX?preview=true) [Step 1](https://www.overleaf.com/learn/latex/Articles/Step_1:_Setting_up_an_Overleaf_project_to_use_variable_fonts?preview=true) [Step 2](https://www.overleaf.com/learn/latex/Articles/Step_2:_An_introduction_to_LaTeX_fonts?preview=true) [Step 3](https://www.overleaf.com/learn/latex/Articles/Step_3:_Replacing_LaTeX’s_default_fonts_with_variable_fonts?preview=true) [Step 4](https://www.overleaf.com/learn/latex/Articles/Step_4:_How_to_configure_an_italic_variable_font_using_fontspec?preview=true) [Step 5](https://www.overleaf.com/learn/latex/Articles/Step_5:_LaTeX_font_weights_and_named_instances_of_variable_fonts?preview=true) [Step 6](https://www.overleaf.com/learn/latex/Articles/Step_6:_Using_variable_fonts_to_add_bold_fonts_to_an_Overleaf_project?preview=true) [Step 7](https://www.overleaf.com/learn/latex/Articles/Step_7:_Using_Noto_Sans_and_Roboto_Mono_variable_fonts_with_LaTeX?preview=true) [Step 8](https://www.overleaf.com/learn/latex/Articles/Step_8:_How_to_create_a_simple_LaTeX_package_to_configure_your_variable_fonts?preview=true) [Examples and projects](https://www.overleaf.com/learn/latex/Articles/Overleaf_projects_showing_how_to_use_variable_fonts_with_LaTeX?preview=true)

This final tutorial installment lists five projects created by Overleaf to showcase the use of OpenType variable fonts. All projects contain the necessary variable font files and a `latexmkrc` file used to make those font files available to LaTeX.

Users on a free plan are advised that some of these projects have extended initial-compilation times, reflecting their use of LuaLaTeX and OpenType variable fonts.

## Project 1: A ready-to-use project configured with OpenType variable fonts

* Open the Overleaf project <https://www.overleaf.com/1311295292wvdkgcbnfxsw#94292d>

This project is configured to use Noto Serif, Noto Sans, and Roboto Mono. Section headings, figure and table captions, and even footnotes are configured to use specific variable font settings—see the project file `myvariablefonts.sty` for further details.

## Project 2: Using variable fonts to demonstrate LaTeX’s font-selection commands

* Open the Overleaf project: <https://www.overleaf.com/1941895198cqjzyhzvxhwz#794ae2>

This project configures numerous combinations of LaTeX’s font widths, weights and shapes for Noto Serif, Noto Sans and Roboto Mono. It shows you how to use these fonts with LaTeX’s font-selection commands `\fontseries`, `\fontshape` and `\fontfamily`.

![Image showing LaTeX's \fontseries command being used to typeset variable fonts](/files/Cg42MWqIdoImgrmAyDMk)

## Project 3: Using variable fonts to typeset Arabic and English with the babel package

* Open the Overleaf project <https://www.overleaf.com/3933144323kswvxhnqkbcw#097c77>

This project shows you how to configure OpenType variable fonts for use with the [babel package](https://ctan.org/pkg/babel?lang=en). It includes examples of typesetting a mixture of English and Arabic using several Arabic-script OpenType variable fonts:

* [Noto Naskh Arabic](https://fonts.google.com/noto/specimen/Noto+Naskh+Arabic/tester)
* [Noto Nastaliq](https://fonts.google.com/noto/specimen/Noto+Nastaliq+Urdu/tester)
* [Noto Sans Arabic](https://fonts.google.com/noto/specimen/Noto+Sans+Arabic/tester)

This project shows how fontspec’s `\addfontfeatures` command can be used to make temporary changes to OpenType variable fonts, including the Arabic variable fonts used in this project.

![Image showing a paragraph of Arabic and English text typeset using LaTeX with OpenType variable fonts](/files/Ww3aRJN6tmz2eNuEy4dq)

**Disclaimer**: All non-English text and associated translations were generated using ChatGPT.

## Project 4: A variety of examples showcasing variable fonts

* Open the Overleaf project <https://www.overleaf.com/2858462957mvthxfmtgxsc#11aac1>

This project contains several examples that show how to use fontspec’s `\addfontfeatures` command to make temporary adjustments to variable fonts; for example, temporarily changing a font’s width or weight to adjust the space required to typeset some text. The following sections outline the examples and provide background information to help you make the most of each one.

### Example: Changing font width to fit more text in a given space

This example uses fontspec’s `\addfontfeatures` command to demonstrate that small, barely noticeable reductions in a variable font’s width can fit more text into a given space. Two minipages containing the same text are typeset side-by-side, comparing non-condensed Noto Serif with one whose width axis value is reduced by 4%.

![Image showing variable font width reduction can fit more text in a given space](/files/R6ufo2zpJYO1nsdPmdTf)

### Example: Using variable fonts with the fancyvrb package

Using fontspec’s `\newfontfamily` command, this example demonstrates how to use a variable font of your choice to typeset program code in a `Verbatim` environment provided by the [`fancyvrb` package](https://ctan.org/pkg/fancyvrb?lang=en). It also shows how to apply formatting to the typeset code using LaTeX's `\fontseries` command.

![Image showing verbatim text typeset using variable onts](/files/geW4w5jtbt50emDF9Tt9)

#### Some notes on the Verbatim environment

The `Verbatim` environment has the following form

```latex
\begin{Verbatim}[⟨settings⟩]
⟨input⟩
\end{Verbatim}
```

where

* the `[⟨settings⟩]` part is optional. `⟨settings⟩` can contain parameters (key–value pairs) that allow you to configure the behavior of this specific `Verbatim` environment
* `⟨input⟩` is the text you want to typeset

A `Verbatim` environment disables LaTeX’s default text processing so that the `⟨input⟩` text can be typeset exactly as it is—including spaces, LaTeX commands, special characters, and line breaks.

To format the `⟨input⟩` text, such as applying bold or italic, use the `commandchars` key in the `⟨settings⟩` section. `commandchars` designates three “special” characters which can be used in the `⟨input⟩` to call LaTeX macros instead of being typeset. To avoid errors and conflicts, choose three characters that won't appear elsewhere within the regular `⟨input⟩` text.

As an example, writing

```latex
\begin{Verbatim}[commandchars=|()]
⟨input⟩
\end{Verbatim}
```

tells the `Verbatim` environment to treat the characters `|`, `(`, and `)` as command characters. If they appear within the `⟨input⟩` LaTeX will process them as follows:

* `|` is used to introduce a LaTeX command—replacing the usual `\` character.
* `(` and `)` are used to delimit the LaTeX command arguments—instead of the usual `{` and `}`

For example, to typeset some of the `⟨input⟩` text in bold you would write `|textbf(some text)` instead of writing `\textbf{some text}`.

### Example: Typesetting numbers using different styles

This example uses fontspec’s `\addfontfeatures` command to temporarily change the style used to typeset the characters 0, 1, 2, ... 9, commonly known as “digits” or “numbers.” Typographers and designers refer to these characters as “figures,” a term used in this example.

#### Some notes on typography and figure styles

Over time, different styles for typesetting figures have been developed for various document elements, such as within tables, the main text, or document headings. Those styles are defined according to three properties of figures: their width, height, and alignment relative to the baseline.

Two styles are based on figure widths:

* **proportional**: the width of each figure varies according to its design.
* **tabular**: each figure has the same width.

Two styles are based on figure height and alignment:

* **lining**: figures sit on the baseline, and their design features don’t dip below it. All figures are the same height.
* **oldstyle**: figure heights vary, and part of a figure’s design may appear below the baseline.

Combining these results in the four typesetting styles as shown in the following graphic:

![](/files/tIW1X4r7L2rPcCJgTBYm)

An [article published by Monotype](https://www.monotype.com/resources/expertise/how-use-figure-styles-illustrator) discusses how to use these figure styles.

#### How to access these figure styles

The availability of these figure styles depends on the variable or non-variable OpenType fonts used to typeset your document. Fortunately, Noto Serif supports all four figure styles, so we can demonstrate them using `\addfontfeatures` to apply different figure styles using fontspec’s `Numbers` key—note the capitalization of `OldStyle`. The following table is one of the examples provided:

![A table showing the four styles used to typeset numbers: tabular oldstyle, proportional oldstyle, tabular lining, and proportional lining.](/files/QuhqePZp19fMn97sQM0w)

* Open the Overleaf project <https://www.overleaf.com/2858462957mvthxfmtgxsc#11aac1>

## Project 5: Using variable fonts to demonstrate LaTeX’s “virtual” font shapes

* Open the Overleaf project <https://www.overleaf.com/4719455662kydjkfvdwjpn#2ea0f1>

LaTeX’s “virtual” font shapes don’t represent physical fonts; instead, they are intended for use with the `\fontshape` to change the current shape. The project examples show how to use the commands `\fontshape`, `\textup`, `\textulc`, `\upshape`, and `\ulcshape`.


---

# 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/in-depth-articles/35-overleaf-projects-showing-how-to-use-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.
