# Fontspec isn't changing digits in math mode

I had been using the following in my preamble:

\documentclass{article}[12pt]
\usepackage[lite,subscriptcorrection,zswash,slantedGreek,nofontinfo]{mtpro2}
\usepackage{fontspec}
\setmainfont[Ligatures={TeX,Rare}]{Times New Roman}
\begin{document}
This is a 123 test $123$.
\end{document}


until I noticed that this produced the following ugly result with the wrong digits font: I have come up with a temporary solution using mathspec:

\documentclass{article}[12pt]
\usepackage[lite,subscriptcorrection,zswash,slantedGreek,nofontinfo]{mtpro2}
\usepackage{mathspec}
\setallmainfonts(Digits,Latin)[Ligatures={TeX,Rare}]{Times New Roman}
\begin{document}
This is a 123 test $123$.
\end{document}


and this indeed fixes the problem: The issue is that mathspec requires me to use XeTeX, which is incompatible with my current workflow—I need to use LuaTex. Is there a way to fix this issue without invoking mathspec?

• fontspec doesn't change the math setup at all, you could use unicode-math rather than mathspec, but more directly I think the question is the same as tex.stackexchange.com/questions/279463/… – David Carlisle Mar 23 at 21:06
• @DavidCarlisle Carlisle I think I understand what you're saying. Your suggestion to use unicode-math differs from the post you linked though - any reason to choose either method? – occamsrazor Mar 23 at 21:35
• unicode-math will (in general) change all the math setup to use opentype math fonts instead of the classic tex math layout, that was more of a general comment on how to affect math in unicode engines. the second one was a result of specifically searching this site for a duplicate answer, it just specifically addresses the digits and operator fonts. – David Carlisle Mar 23 at 21:38
• @DavidCarlisle I briefly looked at unicode-math's documentation and I couldn't understand what the purpose of package was. The solution in the linked question is easy enough to understand - but could you point me to something that explains what unicode-math is to someone unfamiliar with the landscape? I'd like to evaluate which solution is more appropriate in my use case. – occamsrazor Mar 23 at 22:00
• unicode-math is essentially the math support for fontspec (by the same author) it sets up luatex or xetex to use math specific opentype fonts with an opentype MATH table. – David Carlisle Mar 23 at 22:13

With unicode-math you can use the TeX Gyre Termes Math font. TeX Gyre Termes is a times clone and so will fit to your text font:

\documentclass{article}[12pt]
\usepackage{unicode-math}
\setmathfont{TeX Gyre Termes Math}
\usepackage{fontspec}
\setmainfont[Ligatures={TeX,Rare}]{Times New Roman}
\begin{document}
This is a 123 test $123$.
\end{document}


## Edit

I tested your first example. In texlive 2019 there is no problem, the output is as wanted:

In texlive 2017 I get like you the "wrong" font, there it helps to use

 \usepackage[no-math]{fontspec}

• This is a nice alternative, but it does not solve my problem; I am partial to mtpro2. – occamsrazor Mar 23 at 22:19
• Then why do you complain about the math digits it uses? – Ulrike Fischer Mar 23 at 22:20
• mtpro2 uses the already set math font to define the digits. For some reason it thinks the font is still computer modern (although according to the above discussion this is because fontspec does not change math fonts at all) – occamsrazor Mar 23 at 22:23
• no the digits are from mt2mit.pfb, you only need to look in the log. – Ulrike Fischer Mar 23 at 22:27
• I added an edit for a work-around in tl17. – Ulrike Fischer Mar 24 at 10:18