[Tex/LaTex] Best practice – how can I get the whole document (including math) to only use font X with LuaLaTeX and fontspec

best practicesfontsfontspecluatex

Considering one uses math symbols in a document, it is desirable to have them all displayed in the serif font one is using for text, or in basically any font x one would like to use for this sort of thing.

So for one who just started looking into using LuaLaTeX, the amount of information on how to properly typeset a document with only one font (or good combination of at least 2 fonts) is a bit overwhelming. There are easily hundreds of questions on fontspec, Lua(La)TeX, mathspec and the resulting options to use a font, some of which are 4 years old.

Maybe some of the more experienced (and especially more successful) users, who have done this kind of thing before, could share their code for some of the most popular fonts (or their clones and variants)?

  • Times New Roman

  • Helvetica/Arial

  • Palatino

  • Minion Pro

  • Garamond

  • Georgia

… and more

Best Answer

I'm not sure I qualify as experienced and/or more successful :-). But here's an example of the setup I used for my thesis. Adobe Garamond Pro was used as the text font. Sadly, I needed bold to appease the thesis arbiters at my university, so I used BoldFont=AGaramondPro-Semibold as it looks slightly less out of place than the standard bold weight.

For mathematics, I used the mathdesign package with option adobe-garamond. This provided all math symbols I needed for my document, with glyph shapes appropriate for Garamond as a text font. For this to be successful, you must copy the .otf font files to a specific TDS directory, as detailed in the mathdesign README file.

I also have shown some additional typographical enhancements in my sample below, which you may be interested in. microtype allows for more pleasing color on the page. The selnolig package breaks ligatures which would otherwise span morpheme boundaries. Of course, only German and English are supported out of the box, so it won't do much for the Latin text in my example below.

Here's an example using the blindtext package to produce a sample mathematics paper, with explanations in the comments for each font option. I've set this in a two-column layout just so that all the math samples fit on one page for the screenshot.

Sample Code

%% compile with LuaLaTeX
\documentclass[twocolumn]{article}
\usepackage{blindtext} % just for the sample math paper

% here are the font specifications
\usepackage[adobe-garamond]{mathdesign} % use the mathdesign package with Garamond
\usepackage[no-math]{fontspec} % load fontspec without modifying maths fonts
\setmainfont[
  Ligatures=TeX, % make ---, --, etc function as in traditional (La)TeX
  Kerning=Uppercase, % slight tracking adjustment for all-caps material
  BoldFont={AGaramondPro-Semibold}, % this is a bit of a faux pas, but it was required by my thesis office :(
  Numbers=Proportional, % I also had some code to switch to lining numbers in tabular matter
]{Adobe Garamond Pro}
\setmathrm{Adobe Garamond Pro} % for operators and other text in math

% some additional (optional) typographic enhancements
\usepackage{microtype}
\usepackage[english]{selnolig} % of course, this won't do much for latin lipsum text :-)

\begin{document}
\blindmathpaper
\end{document}

Sample Output

enter image description here

Close-up

enter image description here