You have several options here.
In the Modern Toolchain
Although you tagged your question with pdftex
, my advice is to use LuaLaTeX and unicode-math
when you can, and legacy 8-bit fonts when you have to. You can use the OpenType Garamond Math font with
\usepackage{unicode-math}
\setmainfont{EB Garamond}
\setmathfont{Garamond-Math.otf}[StylisticSet={8,9}]
% If you want a script-style \mathscr in addition to
% the calligraphic-style \mathcal, add:
\setmathfont{Garamond-Math.otf}[range={scr,bfscr}]
You can check the documentation of Garamond Math for more information about the stylistic sets available. For example, stylistic set 9 fixes the tildes in math mode.
A simpler way to load unicode-math
with EB Garamond and Garamond Math is:
\usepackage[ebgaramond]{fontsetup}
With ebgaramond-maths
According to the documentation, the correct usage is:
\usepackage[cmintegrals,cmbraces]{newtxmath}
\usepackage{ebgaramond-maths}
With newtx
Based on the example preamble in section 18.4 of the newtx
manual:
\usepackage[lining,semibold,scaled=1.05]{ebgaramond}% Latex BOLD renders with ebgaramond semibold
\usepackage[T1]{fontenc} % best for Western European languages
\usepackage[varqu,varl]{inconsolata}% a typewriter font must be defined
\usepackage{amsmath,amsthm}% must be loaded before newtxmath
\usepackage[ebgaramond,vvarbb,subscriptcorrection]{newtxmath} % STIX Bbb
\usepackage{bm}% load after all math to give access to bold math
There is also a garamondx
option if you have installed that package.
On modern installations, you should no longer need \usepackage{textcomp}
or \usepackage[utf8]{inputenc}
, but on older ones you might. If you consider it necessary to define a typewriter font, you probably also want to pick a sans-serif one.
With mathdesign
You can download the “expert” URW Garamond Type-1 fonts with the getnonfreefonts
script from TUG and write
\usepackage[garamond]{mathdesign}
\usepackage{garamondx}
However, URW Garamond has a restrictive license. Loading Cormorant Garamond or EB Garamond instead should also work. If mathdesign
breaks small caps, the easiest fix is to load fontaxes
.
With Another Math Package in XeTeX
In XeTeX (and only XeTeX), you can use the EB Garamond OpenType font with a legacy math package by loading mathspec
after the other package:
\usepackage{mathspec}
\setmainfont{EB Garamond}
\setmathsfont(Digits,Latin,Greek)[Uppercase=Italic, Lowercase=Italic]{EB Garamond}
In my tests, this doesn’t always give correct spacing when you mix letters with some math symbols.
With Another Math Package
There are at least three different Garamond legacy math alphabets. The math design one is especially handy because it includes both Latin and Greek in upright, as well as italic, shape. It is therefore the only legacy version of Garamond that comes with upright lowercase Greek letters, such as \mathrm{\pi}
.
The family name of this math alphabet is mdugm
, and isomath
has an interface to load it for \mathrm
, \mathit
, \mathbf
and \mathbfit
. You can attempt this with
\usepackage[OMLmathrm, rmdefault=mdugm]{isomath}
Or by redefining the math alphabets with commands such as:
\DeclareMathAlphabet{\mathit}{OML}{mdugm}{m}{it}
\SetMathAlphabet{\mathit}{bold}{OML}{mdugm}{mb}{it}
ebgaramond
font has a corresponding math font with theebgaramond-maths
package, and even an open type math font withgaramond-math
?ebgaramond
is the one of the best suggestion, alsomathastext
package helps too....