# Selecting main math font in LuaTeX?

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!

-
You don't show how you tried to use Minion Pro with unicode-math, so it is hard to tell why it didn't work for you (it should). – Khaled Hosny Nov 15 '11 at 1:18
@KhaledHosny: I added the lines \usepackage{unicode-math}, \setmathfont{Minion Pro} to the preamble; I tried it both before and after the fontspec / \setmainfont lines. – Peter LeFanu Lumsdaine Nov 15 '11 at 6:51

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}

-
Ah; marvellous. This works beautifully. – Peter LeFanu Lumsdaine Nov 15 '11 at 18:28
In Hosny's solution. \partial, \nabla will be lost. It seems, that Minion Pro Italic has no corresponding codepoint. Is it possible to take particular glyphs such as \partial and \nabla from Asana Math ? – Igor Kotelnikov Mar 17 '12 at 5:39
I think symbol csnames (or code points) can be use as arguments to range option, check the manual. – Khaled Hosny Mar 17 '12 at 13:51

You can use the mathastext package:

\documentclass{article}

\usepackage[no-math]{fontspec}
\setmainfont{Minion Pro}
\usepackage[italic]{mathastext}

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


-
I tried this, but wasn’t quite sure about it, since mathastext also changes several other things about how math is set. The documentation lists some of these changes and how to turn them off (eg the size of subscripts), but it wasn’t quite clear to me if the listing was exhaustive or if there might be some other changes made as well. – Peter LeFanu Lumsdaine Nov 15 '11 at 18:32
From what I know it documents all that it does. But @KhaledHosny's solution is probably a better route to take. – Alan Munn Nov 15 '11 at 19:37