Math fonts

You switched the body text to Times or Palatino — but the equations are still Computer Modern, and the mismatch shows. Avoiding that clash is what this page is about. In LaTeX the text font and the math font are chosen separately, so you must deliberately pick a math font for the whole document and harmonize it with the text. We cover both the legacy packages of the pdfLaTeX era — mathptmx, mathpazo, newtxmath — and the modern way on XeLaTeX and LuaLaTeX, unicode-math with \setmathfont, each with a working example. The per-symbol math-alphabet commands such as \mathbb and \mathcal belong to a separate page (Math fonts, in the math area) and are not repeated here.

Text and math are chosen separately

Start with the principle. In LaTeX the font for body text and the font for math mode are managed as two independent systems. Replacing the text font does not automatically carry the math along, so you get a mismatch: “I made the body Times with \usepackage{...}, yet the x and \sum in my equations are still the old face.” Good typesetting requires aligning the two on purpose — so that the variables and symbols inside a formula are set with the same weight and the same feel as the surrounding prose.

The default math font is Computer Modern math — the typeface Knuth designed alongside TeX. With pdfLaTeX and no font choices, both text and math are set in Computer Modern, and because they were designed as a single suite they harmonize naturally. Loading the lmodern package swaps in Latin Modern (its smoother-outlined descendant) for text and the matching Latin Modern Math for mathematics (the latter is used mainly through unicode-math). In other words, doing nothing already gives you a matched text-and-math starting point.

From here, the moment you want a different text face, your options fork. On pdfLaTeX, the legacy route loads a dedicated package per math font; on XeLaTeX and LuaLaTeX, the modern route names **a single OpenType math font via unicode-math.** The next sections take each in turn.

The legacy way (pdfLaTeX / Type1)

On pdfLaTeX you switch the whole document’s math font with a math-font package. Most are built to pair with a text font, so loading them together with the text-side package sets both body and math in the same family. The table below collects the common ones.

PackageText / matching faceNotes
mathptmxTimesTimes-like math (built from Times, Symbol & CM); easy but somewhat dated
mathpazoPalatinoPalatino math, accompanied by the Pazo Math alphabets
newtxmathTimes (with newtxtext)Modern Times-style math; options like [libertine]/[utopia] match other text faces
newpxmathPalatino (with newpxtext)Palatino-style math (requires TeX Gyre Pagella)
fourierUtopiaSets Utopia text plus Fourier math together
kpfontsIts own text & math suiteA comprehensive package providing both text and math
mathdesignGaramond / Charter / UtopiaMath to match a chosen text face (garamond/charter/utopia)
eulervm(any text face)The Euler math alphabet; pairs with text fonts that lack their own math

The typical pattern is to load the text-side and math-side packages together. mathpazo, for example, sets up Palatino text and Pazo math in one stroke. The easiest recommendation today is the **newtx family:** writing \usepackage{newtxtext,newtxmath} gives Times-style text and matching modern Times-style math. newtxmath is rich in options — add [libertine] for math that matches Libertine (libertinus) text, or [utopia] (with the Erewhon fonts) for math that matches a Utopia text face.

document.tex
% --- Palatino 本文+数式 / Palatino text & math ---
\usepackage{mathpazo}            % Palatino + Pazo math

% --- Times 本文+数式(おすすめ) / Times text & math (recommended) ---
\usepackage{newtxtext}           % 本文 / text
\usepackage{newtxmath}           % 数式 / math

% --- Libertine 本文に数式を合わせる / match math to Libertine text ---
% \usepackage{libertine}
% \usepackage[libertine]{newtxmath}

The thing to watch: specifying text and math through separate packages makes it easy to pick a clashing combination. Mixing non-paired pieces — newtxtext with newpxmath (Times text, Palatino math), say — manufactures exactly the mismatch this page is trying to avoid. Load order matters too: put the math-font package after the text-font package. The rule is simple — choose text and math as a matched pair.

The modern way — unicode-math (XeLaTeX & LuaLaTeX)

On XeLaTeX or LuaLaTeX you can sweep away the legacy package soup. The **unicode-math package sets the whole of mathematics from a single OpenType math font,** named with \setmathfont{…}. Switch the body to an OpenType text font with fontspec, switch math to the matching OpenType math font with \setmathfont, and those two lines align text and math. unicode-math **loads fontspec for you and requires the XeTeX or LuaTeX engine** (it does not run on pdfLaTeX). It also builds on amsmath, so load amsmath first.

The usable OpenType math fonts include a good free selection: Latin Modern Math (in the Computer Modern lineage), STIX Two Math (broad coverage of scientific symbols), the TeX Gyre family — Termes (Times-like), Pagella (Palatino-like), Bonum, Schola — each in a Math variant, Libertinus Math (successor to Libertine / Linux Libertine), plus XITS (derived from STIX), Asana Math, and Fira Math. If you name no math font before \begin{document}, Latin Modern Math is loaded by default.

OpenType math fontLineage / characterPairs with text
Latin Modern MathComputer Modern lineage; the defaultLatin Modern
TeX Gyre Termes MathTimes-likeTeX Gyre Termes / Times
TeX Gyre Pagella MathPalatino-likeTeX Gyre Pagella / Palatino
STIX Two MathTimes-like, very broad symbol setSTIX Two Text / Times
Libertinus MathSuccessor to LibertineLibertinus Serif
XITS / Asana / Fira MathSTIX-based / its own / sans-styleas appropriate

Here is a minimal example. Load amsmath, then unicode-math, and name the math font with \setmathfont. No per-font package like mathptmx or mathpazo is needed — this one line takes over all of mathematics. To match the body too, set the corresponding text font with fontspec’s \setmainfont (you can skip loading fontspec itself, since unicode-math pulls it in).

document.tex
% コンパイルは xelatex または lualatex / compile with xelatex or lualatex
\documentclass{article}
\usepackage{amsmath}
\usepackage{unicode-math}
\setmainfont{TeX Gyre Termes}       % 本文(fontspec)/ text
\setmathfont{TeX Gyre Termes Math} % 数式(対の OpenType フォント)/ matching math
\begin{document}
\[
  f(x) = \int_{-\infty}^{\infty} \hat f(\xi)\, e^{2\pi i x \xi}\, d\xi.
\]
\end{document}

Here the body is TeX Gyre Termes (Times-like) and the math its matching TeX Gyre Termes Math, so integrals, subscripts, and variables all share the body’s feel. When one math font is not enough, the **range= option** to \setmathfont lets you take part of the math alphabet from another font (see the Math fonts page). On the whole, if you are on a Unicode engine, **unicode-math with \setmathfont is today’s standard** — far simpler to configure than the legacy packages.

Which to choose — pair text with math

In the end the key advice is single: choose the text font and the math font as a pair. On pdfLaTeX, use combinations designed to go together — newtxtext + newtxmath (Times) or mathpazo (Palatino). On XeLaTeX or LuaLaTeX, match the families with \setmainfont{...} and \setmathfont{...} — Libertinus text with Libertinus Math, TeX Gyre Pagella text with its Math, and so on.

  • Doing nothing: Computer Modern (pdfLaTeX) or Latin Modern Math (the unicode-math default) — text and math already match.
  • Changing the text on pdfLaTeX: use a paired package — Times via newtxtext+newtxmath, Palatino via mathpazo/newpxmath, Utopia via fourier or mathdesign.
  • On XeLaTeX/LuaLaTeX: load amsmath then unicode-math, and name matching OpenType text and math with \setmainfont and \setmathfont.
  • What not to do: mix an unpaired text and math (e.g. Times text with Palatino math).

Note that commands which set only certain letters inside a formula in a different face — \mathbb, \mathcal, \mathfrak — are a separate topic from choosing the document-wide math font discussed here; those live on the “Math fonts” page in the math area. For the text faces themselves see “Western font families,” for naming text fonts on a Unicode engine see “fontspec,” and for the underlying machinery (NFSS) see “Font system.”