1

I am currently creating a LaTeX class that my students can use for their theses. For this, I would like to use fonts that I personally find very appealing. Unfortunately, I have installed several fonts on my system over the past few months and now I am unsure which ones are included by default in LaTeX distributions.

Does anyone know which of the fonts listed below need to be installed manually?

Additionally, I would be interested to know if there is a suitable combination to my standard set "XCharter, Fira Sans, DejaVu Sans Mono" that is included by default.

Here is my MWE:

\documentclass[margin=1cm,varwidth]{standalone}

\usepackage{fontspec}

% Main font with fallback options
\IfFontExistsTF{XCharter}{
  \setmainfont{XCharter}
}{
  \IfFontExistsTF{QTPalatine}{
    \setmainfont{QTPalatine}
  }{
    \setmainfont{Latin Modern Roman}
  }
}

% Sans font with fallback options
\IfFontExistsTF{Fira Sans}{
  \setsansfont{Fira Sans}
}{
  \IfFontExistsTF{Lato}{
    \setsansfont{Lato}
  }{
    \setsansfont{Latin Modern Sans}
  }
}

% Mono font with fallback options
\IfFontExistsTF{DejaVu Sans Mono}{
  \setmonofont{DejaVu Sans Mono}[Scale=0.9]
}{
  \IfFontExistsTF{JetBrains Mono}{
    \setmonofont{JetBrains Mono}
  }{
    \IfFontExistsTF{Inconsolata}{
      \setmonofont{Inconsolata}
    }{
      \setmonofont{Latin Modern Mono}
    }
  }
}

\begin{document}

The quick brown fox jumps over the lazy dog

\textsf{The quick brown fox jumps over the lazy dog}

\texttt{The quick brown fox jumps over the lazy dog}

\end{document}
3
  • It will depend on which distribution they install and which options they choose. So if any of them use TeX Live packaged by a Linux distro, for example, they may install some subset of TL. If they install from upstream, they may have configured a more or a less complete scheme. Some distros split off the unicode compilers, for example, so your document wouldn't compile at all without installing 'additional' packages. If they all have a complete TeX Live, for example, you could just test your document on Overleaf, though there are some subtle differences in the way fonts are found and loaded.
    – cfr
    Commented Jun 30 at 16:54
  • But if you look at the log/on the terminal after compilation, you can see where the fonts used in your document are located and that will tell you whether they are in your distribution's TeX tree or outside it. (But note that MikTeX includes some things excluded from TeX Live for licensing reasons.)
    – cfr
    Commented Jun 30 at 16:59
  • Thanks a lot for this advice @cfr
    – taocp
    Commented Jun 30 at 18:52

1 Answer 1

1

Thanks to @cfr I was able to figure it out for my current TEXLive 2024 installation on Mac OS X and finally came up with this solution:

\documentclass[margin=1cm,varwidth]{standalone}

\usepackage{fontspec}

% Main font with fallback options
\IfFontExistsTF{XCharter}{
  \setmainfont{XCharter}                        % part of TEX Live
}{
  \IfFontExistsTF{QTPalatine}{
    \setmainfont{QTPalatine}                    % part of TEX Live
  }{
    \IfFontExistsTF{Noto Serif}{
      \setmainfont{Noto Serif}                  % part of TEX Live
    }{
      \setmainfont{TeX Gyre Pagella}            % part of TEX Live
    }
  }
}

% Sans font with fallback options
\IfFontExistsTF{Fira Sans}{
  \setsansfont{Fira Sans}                       % Not part of TEX Live
}{
  \IfFontExistsTF{Lato}{
    \setsansfont{Lato}                          % Not part of TEX Live
  }{
    \IfFontExistsTF{Noto Sans}{
      \setsansfont{Noto Sans}[Scale=0.95]       % part of TEX Live
    }{
      \setsansfont{TeX Gyre Heros}[Scale=0.9]   % part of TEX Live
    }
  }
}

% Mono font with fallback options
\IfFontExistsTF{DejaVu Sans Mono}{
  \setmonofont{DejaVu Sans Mono}[Scale=0.9]     % Not part of TEX Live
}{
  \IfFontExistsTF{JetBrains Mono}{
    \setmonofont{JetBrains Mono}                % Not part of TEX Live
  }{
    \IfFontExistsTF{Inconsolata}{
      \setmonofont{Inconsolata}                 % Not part of TEX Live
    }{
      \setmonofont{AnonymousPro}                % part of TEX Live
    }
  }
}

\begin{document}

The quick brown fox jumps over the lazy dog

\textsf{The quick brown fox jumps over the lazy dog}

\texttt{The quick brown fox jumps over the lazy dog}

\texttt{\itshape The quick brown fox jumps over the lazy dog}

\end{document}
1
  • Inconsolata is included in TeX Live. So is DejaVu Sans Mono. Also Fira Sans and Lato. I think the only one not included is probably JetBrains Mono.
    – cfr
    Commented Jun 30 at 22:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .