Choosing LaTeX math fonts (newtxmath, unicode-math)

You switched the text face to Times and the mathematics stayed Computer Modern — everyone meets that problem first when picking a math font in LaTeX. The nastier part comes next. Load mathptmx, assume the document is now uniformly Times, then run pdffonts over the PDF: CMEX10 is still embedded. The summation and integral signs are, to this day, still Knuth’s. This page compares the pdfLaTeX math-font packages (newtxmath, mathpazo, fourier, kpfonts and the rest) with unicode-math plus \setmathfont on XeLaTeX and LuaLaTeX, counting what actually landed in the PDF each time. The math-alphabet commands (\mathbb, \bm and friends) are a separate page; here the question is how to choose the math typeface for a whole document.

Changing the text font does not change the maths

In LaTeX the text font and the math-mode font are kept in entirely separate systems. Replace the text face with a \usepackage{...} line and the variables, operators and subscripts stay Computer Modern until you say otherwise. That is design, not neglect. A math font has to carry information a text font simply does not have — the height of the symbols and the position of the axis, the extension pieces that let radicals and brackets grow, how far subscripts drop, how thick a fraction rule is: dozens of dimensions. You cannot press an ordinary text face into service for mathematics. Changing the math typeface therefore means fetching a font built for the job.

What actually gets embedded: counting with pdffonts

Whether a math-font package really replaced Computer Modern is settled at once by counting the fonts embedded in the PDF. Hand the file to Poppler’s pdffonts (it ships in poppler-utils on most systems). Compiling one short document — a line of text plus a single display containing an integral, a sum, a lowercase Greek letter and a capital Greek letter — with pdfLaTeX on TeX Live 2024 split the results cleanly into three groups: those that replace it completely (newtx, newpx, fourier, kpfonts, mathdesign), those that leave Computer Modern behind (mathptmx, mathpazo, eulervm), and, if you do nothing at all, Computer Modern throughout.

shell
# the only honest way to check which math font you actually shipped
pdflatex paper.tex
pdffonts paper.pdf

# name                                 type              emb sub uni
# ------------------------------------ ----------------- --- --- ---
# QSPJFW+NimbusRomNo9L-Regu            Type 1            yes yes yes
# CZKGAS+CMR10                         Type 1            yes yes yes   <- still Computer Modern
# UYVLXV+CMEX10                        Type 1            yes yes yes   <- the big operators
What you loadMath fonts pdffonts reportedDoes CM survive?
(none)CMR10 CMMI10 CMSY7 CMEX10 CMMI7 CMR7All of it; the default Computer Modern math
mathptmxNimbusRomNo9L StandardSymL CMR10 CMSY10 CMMI10 CMEX10Yes. + and = come from CMR10; \sum and \int from CMEX10
mathpazoURWPalladioL PazoMath CMR10 CMSY10 CMEX10Yes; the large operators stay CMEX10
newtxmathNewTXMI txsys txmiaX txexs NewTXMI7No. On the text side you get TeXGyreTermesX-Regular
newpxmathNewPXMI pxsys pxmiaX txexsNo; the extension font is the same txexs newtx uses — the identical subset is embedded
fourierFourier-Math-Symbols / -Extension / -LettersNo; the text is Utopia. A genuine one-liner
kpfontsKp-Regular Kp-Italic Kp-Ex Kp-SyNo; text and maths are all Kp
eulervmEURM10 EUFM10 EUEX10 plus CMR10 CMR7Yes; letters, symbols and large operators become Euler, but the operators family (digits and upright roman) keeps the text font
mathdesignA full MathDesign-CH-Regular setNo; with [charter] the text is CharterBT

The legacy way: pairing text and maths under pdfLaTeX

The standard move under pdfLaTeX is to load a text package and a math package as a pair. The easiest recommendation today is the newtx family: put \usepackage{newtxtext} next to \usepackage{newtxmath} and you get Times-like text with matching maths. Despite the name, though, what newtxtext embeds is not Times itself but an extended TeX Gyre Termespdffonts reports TeXGyreTermesX-Regular. For Palatino, use mathpazo, or newpxtext with newpxmath. If you want Charter, note that there is no xcharter-math.sty: under pdfLaTeX you call it as an option, \usepackage[xcharter]{newtxmath}, and the OpenType XCharter-Math.otf is reached through the \setmathfont of the next section. The same pattern matches many other text faces — libertine, libertinus, cochineal, erewhon, stix2, noto — which is newtxmath’s real strength.

If you want one line to change text and maths together, fourier (Utopia text plus Fourier maths) and kpfonts (the Kepler family) are the safe bets; in the measurements above neither left a single Computer Modern font behind. The mistake to guard against is treating a text-only package as if it were a math package. Load libertinus under pdfLaTeX, for instance, and the mathematics stays CM: the PDF carries CMMI10, CMR10 and CMEX10 alongside LibertinusSerif-Regular. That particular measurement lives on the Western-fonts page. The other classic accident is mixing a text face with an unrelated math face. Pair newtxtext (Times-like) with newpxmath (Palatino-like) and both fonts work perfectly, yet the page looks off: the widths and the colour on the page do not agree.

document.tex
% --- Times-like text and matching math (the easy recommendation) ---
\usepackage{newtxtext}
\usepackage{newtxmath}

% --- Palatino text and math, in one package ---
% \usepackage{mathpazo}

% --- one line for both, with no Computer Modern left behind ---
% \usepackage{fourier}     % Utopia text + Fourier math
% \usepackage{kpfonts}     % the Kepler family

% --- match math to another text face through newtxmath ---
% \usepackage{libertinus}
% \usepackage[libertinus]{newtxmath}

The modern way: unicode-math and \setmathfont

On XeLaTeX or LuaLaTeX, loading unicode-math and writing a single \setmathfont{…} line lets you set all of mathematics from one OpenType math font, sweeping away the pile of packages. The engine restriction is real: write \usepackage{unicode-math} under pdfLaTeX and it stops with ! Package unicode-math Error: Cannot be run with pdftex! followed by (unicode-math) Use XeLaTeX or LuaLaTeX instead. What makes it work is OpenType’s MATH table — a standardised block inside the font file holding every dimension TeX needs to set mathematics: the thickness of the fraction rule, how far subscripts drop, the clearance above a radical, how a stretchy bracket is assembled from pieces. Because those live in the font, swapping the font swaps the typesetting parameters with it. If you name no font at all, Latin Modern Math is loaded by default.

There is one landmine in the loading order. Load amssymb after unicode-math and you get four errors of the same shape, headed by ! LaTeX Error: Command \eth already defined. and continuing with \smallsetminus, \digamma and \backepsilon (measured on TeX Live 2024). unicode-math has already defined those symbols from the Unicode side, and amssymb collides trying to redefine them. Reverse the order — amsmath, then amssymb, then unicode-math — and the same document compiles with no errors at all. Remember the rule as “unicode-math always goes after the font-related packages” and you will avoid most of the trouble.

OpenType math fontCharacter, and the text face it pairs with
Latin Modern MathIn the Computer Modern lineage; loaded by default. Pairs with Latin Modern Roman
TeX Gyre Termes MathTimes-like; pairs with TeX Gyre Termes. Pagella, Bonum, Schola and DejaVu versions exist too
STIX Two MathVery broad coverage, aimed at scientific publishing; pairs with STIX Two Text. macOS ships it
Libertinus MathThe math companion to Libertinus Serif — a pairing pdfLaTeX cannot give you
XCharter-MathThe Charter line. There is no xcharter-math.sty; reach the OTF through \setmathfont
NewCMMath-RegularThe math face of New Computer Modern; the CM look with far wider Unicode coverage
Fira MathA sans-serif math font; useful when slides or posters want maths to match the text
Asana-MathA Palatino-leaning math font; a veteran alongside XITS, the STIX derivative

The font "Latin Modern Math" cannot be found: XeLaTeX vs LuaLaTeX

The same \setmathfont{Latin Modern Math} succeeds under LuaLaTeX and fails under XeLaTeX with ! Package fontspec Error: The font "Latin Modern Math" cannot be found. — measured on macOS with TeX Live 2024. The cause is how each engine resolves a font name. LuaTeX can look a font up by name inside TeX’s own directory tree (the TDS), whereas XeTeX asks the operating system’s font database, so a font that ships with TeX Live but is not registered with the OS may simply be “not found”. In the same test only STIX Two Math also resolved under XeLaTeX — because macOS ships that font system-wide. The engine-by-engine name resolution is covered in depth on the fontspec page; here are just the remedies: give the file name (\setmathfont{latinmodern-math.otf}), add [Path=…], or move to LuaLaTeX.

document.tex
% compile with lualatex (or xelatex, but see the note on name lookup)
\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}       % must come BEFORE unicode-math
\usepackage{unicode-math}  % always after the font packages
\setmainfont{TeX Gyre Termes}       % text, via fontspec
\setmathfont{TeX Gyre Termes Math}  % the matching OpenType math font
% \setmathfont{latinmodern-math.otf} % by file name, if lookup by name fails
\begin{document}
\[ f(x) = \int_{-\infty}^{\infty} \hat f(\xi)\, e^{2\pi i x \xi}\, d\xi. \]
\end{document}

Taking only part of the maths from another font: range=

When the math font you picked lacks a character you need, the range= option to \setmathfont fills the gap from a different font. range= accepts a Unicode range, a single symbol such as range=\int, an alphabet style such as range=\symbb (which can also be written range=bb), and combinations of style and script such as range=bfit/{greek,Greek}. The effect is measurable: add \setmathfont{STIX Two Math}[range=\symbb] on top of a Latin Modern Math main font and pdffonts reports both LatinModernMath-Regular and STIXTwoMath-Regular, the latter carrying only the handful of blackboard-bold letters. Because only the requested slots are loaded, mixing fonts this way does not blow up the PDF. The one prerequisite is that a main math font must already have been set the normal way.

document.tex
\usepackage{amsmath}
\usepackage{unicode-math}
\setmathfont{Latin Modern Math}                                % the main math font
\setmathfont{STIX Two Math}[range=\symbb]                     % blackboard bold only
\setmathfont{TeX Gyre Termes Math}[range=bfit/{greek,Greek}]  % bold-italic Greek only

So which do you pick? Pair the maths with the text

The advice collapses to one rule: choose the text font and the math font as a pair. Whatever the engine, that principle does not move. Do nothing and you get Computer Modern (pdfLaTeX) or Latin Modern Math (the unicode-math default), which are handsome enough; unless a style guide names a typeface, there is no reason to change. If you do change under pdfLaTeX, pick things that were made for each other — Times with newtxtext plus newtxmath, Palatino with mathpazo or the newpx pair, Utopia with fourier, Kepler with kpfonts. Under XeLaTeX or LuaLaTeX, load amsmath, amssymb, unicode-math in that order and hand \setmainfont and \setmathfont names from the same family. Then check with pdffonts before you send the file anywhere. The font you think you shipped may not be the font you shipped — which is where this page began.

  • If you do nothing, you get Computer Modern (pdfLaTeX) or Latin Modern Math (the unicode-math default). With no style guide to satisfy, there is no need to change.
  • Changing under pdfLaTeX: use packages that come in pairs. Times is newtxtext plus newtxmath, Palatino is mathpazo; for a single line, fourier or kpfonts.
  • Under XeLaTeX or LuaLaTeX: load amsmath, amssymb, unicode-math in that order and keep \setmainfont and \setmathfont in the same family.
  • Do not mix a text face with an unrelated math face (Times text, Palatino maths). Nothing errors; the page shows it.
  • Always finish by checking the embedding with pdffonts. mathptmx and mathpazo leave CMEX10 behind.