[Tex/LaTex] Selecting main math font in LuaTeX

fontsfontspecluatexmath-mode

I’d to set some fairly simple maths in Minion Pro (and potentially other system fonts), using LuaTeX.  I’d hoped that something like the following should work:

\documentclass{minimal}

\usepackage{fontspec}
\setmainfont{Minion Pro}

\begin{document}
Here’s some text.  Now some math: $x^2 + y^2 = z^2$.
\end{document}

However, the x^2 + y^2 + z^2 is set in Computer Modern.  Material in \mathit, \mathrm etc. appears in Minion as hoped, and can be further controlled by \setmathrm and so on, but is there any way to control the main math font?

I don’t have Minion Math, and trying to use ordinary Minion Pro as the math font via unicode-math doesn’t help—indeed, it puts \mathit material back into CM! MnSymbol also doesn’t help. But in any case, I’d prefer a solution that generalises to other fonts, if possible.

Alternatively, changing to XeLaTeX, the mathspec package does the trick, using \setmathfont(Digits,Latin){Minion Pro}. But I’d be sad to give up microtype and the rest of the power of LuaTeX!

Best Answer

Simply setting \usemathfont{Minion Pro} with unicode-math will not work since it expects an OpenType math font, but you can use range option to use normal text fonts for certain math alphabets (or any math symbol), check documentation for details.

\documentclass{minimal}

\usepackage{fontspec}
\usepackage{unicode-math}
\setmainfont{Minion Pro}
\setmathfont{Asana Math} % for math symbols, can be any other OpenType math font
\setmathfont[range=\mathup]  {Minion Pro}
\setmathfont[range=\mathbfup]{Minion Pro Bold}
\setmathfont[range=\mathbfit]{Minion Pro Bold Italic}
\setmathfont[range=\mathit]  {Minion Pro Italic}

\begin{document}
Here’s some text.  Now some math: $x^2 + y^2 = z^2$, $\mathrm{x^2 + y^2 = z^2}$, $\mathbfit{x^2 + y^2 = z^2}$, $\mathbf{x^2 + y^2 = z^2}$.
\end{document}