The unicode-math package

Sets formulas in an OpenType math font chosen with \setmathfont and accepts Unicode characters such as α, ∑ and ≤ in the source. Needs LuaLaTeX or XeLaTeX.

This package needs LuaLaTeX or XeLaTeX. The editor compiles with pdfLaTeX, so the package does not work there.

Loading the package

\usepackage{unicode-math}

The package does not work with pdfLaTeX; there it stops with "Cannot be run with pdftex!". Compile the document with LuaLaTeX or XeLaTeX.

With pdfLaTeX, every math font needs its own package, and symbols are spread over several font files. An OpenType math font holds all symbols and alphabets in one file. \setmathfont{STIX Two Math} switches the whole of math to that font, in the way \setmainfont from fontspec switches the text font.

unicode-math loads fontspec and amsmath. For single bold, blackboard or calligraphic symbols it adds the commands \symbf, \symbb, \symcal and others; \mathbf and \mathrm are kept for words in formulas.

Main commands

\setmathfont{Latin Modern Math}Selects the math font by its name. Latin Modern Math is the default.
\symbf{v}Bold symbol, also for Greek letters: \symbf{\alpha}.
\symbb{R}Blackboard bold letter.
\symup{e}Upright symbol, for example for the constants e and i.
\symcal{L}, \symfrak{g}Calligraphic and Fraktur letters.
\usepackage[math-style=ISO]{unicode-math}Sets all Greek letters italic, capitals included; bold-style=ISO makes \symbf bold italic.

Complete example

\documentclass{article}
\usepackage{unicode-math}
\setmathfont{Latin Modern Math}
\begin{document}
For all $x ∈ \symbb{R}$ and $n ≥ 1$:
\[
  \symbf{v} = α \symbf{a} + β \symbf{b}, \qquad
  ∑_{k=1}^{n} k = \frac{n(n+1)}{2}, \qquad
  \symup{e}^{\symup{i}π} = -1
\]
\end{document}
Result
The compiled example

Compiled with LuaLaTeX from TeX Live 2023.

Pitfalls

Related pages