You probably have created PDF documents using R Markdown or Quarto. The default look and feel of these documents are driven by the default typeface, Computer Modern, or its extended implementation, Latin Modern.
To me, these default typefaces work fine, but they could be “thicker” to be more legible on HiDPI and Retina displays. MLModern offers such a sturdy rendition of the Computer Modern design. It was kindly contributed by Daniel Benjamin Miller and was first published on CTAN in January 2021.
Specimen
For direct use with LaTeX, you can preview MLModern on the LaTeX Font Catalogue. As I often generate LaTeX-rendered PDF documents via R Markdown and Quarto, I created a GitHub repo at nanxstats/rmarkdown-quarto-mlmodern to store examples specifically using these publishing systems.
MLModern covers the serif, sans-serif, and monospace variants that are available in Latin Modern. As of March 2023, MLModern is available in TFM and Type 1 formats, although OpenType support is planned for the future. Someone on Reddit was able to convert the Type 1 version to TTF.
Install MLModern
MLModern is included in TeXLive >= 2021. If you did not install the full distribution, you can install the LaTeX package from CTAN:
(sudo) tlmgr install mlmodern
If you use TinyTeX, run the following in R to install the LaTeX package:
tinytex::tlmgr_install("mlmodern")
Using MLModern with R Markdown
For PDF documents rendered by the rmarkdown package and the default
pdflatex engine, use the extra_dependencies
option to
include additional LaTeX packages:
output:
pdf_document:
extra_dependencies: ["mlmodern"]
Conveniently, for PDF article templates in
rticles that use Computer Modern or
Latin Modern as the default typeface, such as arxiv_article()
and
asa_article()
, you can add the same option to the YAML header to use MLModern.
To use MLModern with R Markdown + XeLaTeX engine, it will be a bit different:
output:
pdf_document:
latex_engine: "xelatex"
header-includes:
- \usepackage{mlmodern}
- \usepackage[T1]{fontenc}
When combining XeLaTeX and the current version of MLModern, an issue encountered in my specimen repo was problematic math rendering, but I have not found a solution yet. Please let me know in the repo if you know a solution.
Although it is okay to use the mlmodern and fontenc package with XeLaTeX, it might not be the optimal choice. It is recommended to use OpenType (OTF) fonts whenever possible with XeLaTeX since they offer more advanced typographic features and are supported better by modern applications.
Using MLModern with Quarto
The Quarto LaTeX includes
syntax offers several options to use additional LaTeX packages.
For example, we can use the text
sub key under include-in-header
.
Since Quarto uses XeLaTeX by default, we can write:
format:
pdf:
include-in-header:
text: |
\usepackage{mlmodern}
\usepackage[T1]{fontenc}
Or, render with the pdflatex engine to avoid the math rendering issue:
pdf-engine: pdflatex
format:
pdf:
include-in-header:
text: |
\usepackage{mlmodern}
\usepackage[T1]{fontenc}
I hope MLModern can help improve the readability of your PDF documents.