Math fonts

Letters in math mode are math italic by default, but many fields call for a specific math alphabet: the blackboard-bold ℝ of set theory, the script letters used for functors, the ornate Fraktur used for Lie algebras. This page sorts out the math-alphabet commands such as \mathbf and \mathbb, the package each one needs, and the difference between \boldsymbol and \bm for bolding vectors and symbols. It closes with unicode-math, the modern way to use OpenType math fonts on XeLaTeX and LuaLaTeX.

What a math alphabet is

A letter in math mode is taken to be a variable and set in math italic — that is the default math alphabet. Wrapping it in a command such as \mathbf{v} switches just that span to a different typeface. LaTeX provides these switches under \math… names, paralleling the text-mode \textbf, \textsf, and so on.

A point to watch: a math-alphabet command re-sets its argument as a run of individual mathematical symbols, not as text. So \mathbf{fit} is the product of three bold symbols f, i, t — not the word “fit.” When you want an actual word set upright inside a formula, use \text{…} (from amsmath) instead.

Seven basic commands are available with no package at all. The table below covers the ones built into LaTeX (\mathnormal simply names the default math italic explicitly).

CommandLookNotes
\mathnormalThe default math italicBuilt in; the default look of a variable
\mathrmUpright romanBuilt in; for upright constants and abbreviations
\mathbfUpright boldBuilt in; upright, so poor for variables (see below)
\mathsfSans serifBuilt in; for tensors, category names, etc.
\mathttMonospace (typewriter)Built in; e.g. for code-like tokens in math
\mathitText italicBuilt in; multi-letter words slanted (text spacing)
\mathcalCalligraphic; uppercase onlyBuilt in; for families of sets, categories, etc.

A word on the easily confused \mathit vs \mathnormal: \mathnormal (the default) sets each letter as a variable, with the wider inter-variable spacing, whereas \mathit is the text italic and suits a multi-letter word set as one slanted unit, as in \mathit{diff}.

Blackboard, calligraphic, Fraktur & script

The next four are the typefaces mathematics leans on most, but — apart from the built-in \mathcal — each requires loading a package. They differ in look, in typical use, and in which package they need.

\mathbb (blackboard bold)** is a distinctive bold whose strokes are doubled — it imitates how one writes boldface on a blackboard by drawing a stroke twice. It needs amssymb (or amsfonts) and covers uppercase letters only. Its use is all but fixed: the number sets — the reals ℝ, complex ℂ, integers ℤ, rationals ℚ, naturals ℕ. Writing \mathbb{R} gives a “blackboard-bold R” with a doubled vertical stroke.

\mathcal (calligraphic) gives flowing, ornamented capitals; it is built in and uppercase only**. It is used for families of sets 𝒜, the Fourier transform ℱ, the names of categories and sheaves, and the like. \mathcal{F} yields an “ornate F.”

\mathscr (script)** is an even more flowing, handwritten-looking face than \mathcal. The usual source is the **mathrsfs package** (which loads Ralph Smith’s Formal Script); the euscript package (Euler Script) offers a different script as well. It is handy when you need two distinct ornamental alphabets alongside \mathcal (and, in practice, for uppercase).

\mathfrak (Fraktur)** is an angular, ornate face descended from old German type, used for Lie algebras 𝔤 and ideals 𝔭, 𝔮. It needs amssymb (or amsfonts, which pulls in eufrak) and, unlike \mathbb and \mathcal, covers both upper- and lowercase.

document.tex
\usepackage{amssymb}   % \mathbb と \mathfrak
\usepackage{mathrsfs}  % \mathscr
% ...
\[
  \mathbb{R} \subset \mathbb{C}, \qquad
  \mathcal{F}(f) = \hat{f}, \qquad
  \mathscr{L}(f) = F, \qquad
  \mathfrak{g} = \operatorname{Lie}(G).
\]

Here \mathbb{R} and \mathbb{C} come out blackboard bold, \mathcal{F} calligraphic, \mathscr{L} in a more flowing script, and \mathfrak{g} as an angular Fraktur lowercase. The table below sums up the package and letter coverage of each.

CommandPackage neededCoverage & typical use
\mathbbamssymb (or amsfonts)Uppercase only; number sets ℝ ℂ ℤ ℚ ℕ
\mathcalBuilt in (none)Uppercase only; set families, categories, transforms
\mathscrmathrsfs (or euscript)Uppercase in practice; a more flowing script
\mathfrakamssymb / amsfonts (eufrak)Upper- and lowercase; Lie algebras, ideals

A shared and important limitation: these ornamental alphabets cover only a limited set of characters. \mathbb and \mathcal are essentially the capitals A–Z; digits, Greek letters, and lowercase are generally not provided (in the standard fonts). A wish like “blackboard-bold 2 via \mathbb{2}” cannot be met as standard — it calls for a separate font package (such as mathalpha/mathalfa, bbm, or dsfont) or for unicode-math, covered below.

Making math bold

You will often want bold math — bold vectors and matrices, say — but there is a trap. The \mathbf above is an upright bold, meant for bold constants or abbreviations that should be upright. Set a vector with it, \mathbf{v}, and you get bold but upright type, breaking the convention that variables are slanted. Worse, \mathbf has no effect on symbols or Greek letters (\mathbf{\alpha} does not bold α).

The first choice for bolding while keeping the slant is **\boldsymbol. Provided by amsmath** (its amsbsy), it bolds not only variables but Greek letters and symbols too, preserving the original shape (the slant and so on). \boldsymbol{\beta} gives a “bold italic β.”

And the most recommended, robust way today is **\bm from the bm package**. \bm{…} is designed to add only weight, preserving the slant and everything else of its argument, and it handles variables, Greek, and symbols — even complicated input — almost transparently. Its spacing is also better than \boldsymbol’s. bm redefines \boldsymbol as an alias for \bm, and adds \hm (\heavysymbol) for an extra-heavy weight.

document.tex
\usepackage{amsmath}   % \boldsymbol
\usepackage{bm}        % \bm(推奨)
% ...
\[
  \mathbf{v} \neq \bm{v}, \qquad
  \bm{\beta} = (\beta_1, \dots, \beta_n), \qquad
  \nabla \bm{F} = \bm{0}.
\]

Here \mathbf{v} is an upright bold v while \bm{v} is a bold v that stays italic, making the difference plain. \bm{\beta} is a bold italic β and \bm{0} a bold zero (the zero vector). As a rule: **use \bm for bold variables, vectors, and symbols**, and \mathbf for constants or abbreviations that should be upright.

  • \mathbf** — upright bold; built in, but poor for variables that should slant, and it does not affect symbols or Greek.
  • \boldsymbol** — from amsmath (amsbsy); keeps the slant and can bold Greek and symbols.
  • \bm — from the bm package; recommended**. Adds only weight, preserving shape and spacing; the most robust and broadest in reach.

unicode-math (XeLaTeX & LuaLaTeX)

So far we have added each typeface one package at a time — the traditional approach. On the modern XeLaTeX and LuaLaTeX engines, the unicode-math package lets you set the whole of mathematics from a single OpenType math font. You switch math typefaces much as you switch a text font, and it supersedes the legacy approach of adding \mathbb and friends piecemeal (the two approaches cannot be mixed in one document).

The heart of it is **\setmathfont{…}**. Load amsmath, then unicode-math (after any other font-related packages), and name an OpenType math font with \setmathfont. Common fonts include Latin Modern Math (in the Computer Modern lineage), STIX Two Math, and the TeX Gyre family (Termes/Pagella/Bonum/Schola Math). If you set no math font before \begin{document}, Latin Modern Math is loaded by default.

document.tex
% コンパイルは xelatex または lualatex
\usepackage{amsmath}
\usepackage{unicode-math}
\setmathfont{STIX Two Math}   % OpenType 数式フォント
% ...
\[
  \symbb{R} \subset \symbb{C}, \qquad
  \symcal{F}, \quad \symscr{L}, \quad \symfrak{g}, \qquad
  \symbf{v} = \symbf{0}.
\]

The manual recommends the **\sym… commands** in place of the legacy \math… ones. The mapping is direct: \symbf (bold), \symbb (blackboard), \symcal (calligraphic), \symscr (script), \symfrak (Fraktur), \symup (upright), \symit (italic), \symsf (sans serif), and so on. Because these map to the corresponding Unicode mathematical-alphanumeric characters, copying a glyph out of the PDF keeps its meaning. The old names like \mathbb remain for backward compatibility, but \sym… is preferred for new documents.

When one math font cannot cover every character, the **range= option** to \setmathfont lets you take only part of the math alphabet from a different font. range= accepts a Unicode range (a form like "1D538-"1D56B"), a single symbol such as range=\int, or an alphabet style such as range=\symbb (or range=bb). So you can, for instance, take the blackboard-bold letters — or only the lower- and uppercase Greek — from another font. Note that you must load a main math font in the usual way before using range=.

document.tex
\usepackage{amsmath}
\usepackage{unicode-math}
\setmathfont{Latin Modern Math}                       % 主たる数式フォント
\setmathfont{STIX Two Math}[range=\symbb]            % 黒板太字だけ別フォント
\setmathfont{TeX Gyre Termes Math}[range=bfit/{greek,Greek}]  % 太字斜体のギリシャだけ

Here the body of the math is Latin Modern Math, while the blackboard-bold letters (\symbb) come from STIX Two Math and only the bold-italic Greek from TeX Gyre Termes Math. For efficiency, unicode-math loads a range= font only for the slots it needs. On the whole, if you are on XeLaTeX or LuaLaTeX, unicode-math with \setmathfont is today’s standard approach, rather than adding a package per typeface.