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}Compiled with LuaLaTeX from TeX Live 2023.
Pitfalls
- Do not load
amssymborbmafterunicode-math.amssymbstops because\ethis already defined, and\bmfails inside the formula. The math font already contains most of the symbols, and\symbfreplaces\bm. - A few names from
amssymbare missing:\squareand\blacksquareare undefined. - The font has to be installed as an OpenType font with a math table. TeX Live contains, among others, Latin Modern Math, STIX Two Math, XITS Math and Libertinus Math.
Related pages
- How-to Math fonts in LaTeX
- How-to Bold math symbols in LaTeX
- Package
fontspec - Package
amssymb - Error Missing character: There is no L in font nullfont!