# fontspec no-math option changes the math bold alphabet

I have a setup that works well with pdflatex and that I would like to carry it over to xelatex or lualatex, but fontspec seems to be changing the math-bold alphabet -- even if called with the [no-math] option. Consider the file:

% To be run with pdflatex
\documentclass{report}

\usepackage[lite]{mtpro2}

\begin{document}
$abcdefg....$

$\mathbf{abcdefg...}$

$\mbf{abcdefg...}$
\end{document}


which produces:

Now moving over to xelatex the equivalent should be:

% To be run with xe-lua-latex
\documentclass{report}

\usepackage[no-math]{fontspec}
\setmainfont{Times New Roman}

\usepackage[lite]{mtpro2}

\begin{document}
$abcdefg...$

$\mathbf{abcdefg...}$

$\mbf{abcdefg...}$
\end{document}


The option [no-math] here is required to keep fontspec from using CM fonts inside math-mode...but then if one use it, the results are:

that is, the \mathbold alphabet is changed - the mid-line uses a different weight.

I am well aware of the question Fontspec changes the bold math and tried everything there and it does not seem to apply.

• mtpro2 defines \mathbf etc by using \encodingdefault and \rmdefault. As \encodingdefault is TU with the unicode engines and \rmdefault is different too this gives quite different fonts. – Ulrike Fischer Feb 23 at 18:52
• @Ulrike, can this be fixed by mimicking what has been done for \mbf -- which seems to work fine in xe-lua-latex? – Paulo Ney Feb 23 at 19:15
• Sure, you can always redefine \mathbf to whatever you want. – Ulrike Fischer Feb 23 at 19:19
• I am looking at the code, all written by Walter A. Schmidt, who I believe has a lot of experience writing code for font usage in TeX. It seems that he specified all math-alphabets in a very portable way that carried nicely into XeTeX and LuaTeX, but NOT this particular one -- \mathbf. I was wondering if there are any reasons for that. – Paulo Ney Feb 24 at 12:48
• All mathalphabets in mt2pro are defined so that they follow the text font. If you switch to times or palatino in pdftex, mathbf will be using times or palatino too (correct loading order assumed). The same happens with luatex, so behaviour is quite consistent. The only problem is that mt2pro uses b instead of bx as series. – Ulrike Fischer Feb 24 at 13:33

You have made some misunderstood claims here: 1) \mathbf does not give you lite-bold; 2) \mbf does not give you heavy-bold. I’d like to first correct some misconceptions and then present a solution.

In your examples you are using the \mathbf alphabet, not the \mathbold alphabet. In fact, mtpro2 declares the latter by

\DeclareMathAlphabet{\mathbold}{LMP1}{mtt}{b}{it}


which means that the \mathbold alphabet is bold and italic. You must purchase the complete version of mtpro2 to get this alphabet. So your lite examples have nothing to do with \mathbold. The \mbf alphabet, however, does exist with the lite version, and \mbf is indeed a separately designed bold upright math font. All heavy math fonts are available only with the complete version.

Under the NFSS (New Font Selection Scheme) of LaTeX2e, the commands \mathrm, \mathbf, \mathit, \mathsf, \mathtt, etc., switch to text fonts in math mode. So when you type

$\mathbf{a-b}$


The a and the b will be printed in bold upright face of the text font, while the hyphen - behaves like the minus sign because you are in math mode. The \mathXX commands only affect what’s called the \mathalpha class (usually includes all digits, lower and upper Latin letters).

\documentclass{article}
\usepackage{fontspec}% no-math' is no longer needed since v2.7b (2019/02/12)
%\setmainfont{Times New Roman}
\setmainfont{Comic Sans MS}% For illustration purpose
\usepackage[lite]{mtpro2}
\begin{document}
$012abcdefg$, no-math' is no longer needed, digits stay as MathT\i me\par
$\mathbf{012abcdefg}$, text font in math mode\par
$\mbf{012abcdefg}$, real bold upright math alphabet
\end{document}


See? The \mathbf command switches to text font (Comic Sans MS) here.

If you look closely in your pdfLaTeX example, then you should realize that \mathbf switches to Computer Modern Bold, which seems to be “semi-bold” because the default is Computer Modern Bold Extended. Maybe this is why you think \mbf is heavy: It isn’t.

# Solution

You have Times New Roman for Windows, Times for MacOS, Nimbus Roman No. 9 L for Linux. These are all Times-like digitization of the same/similar metal types. In the TeX world, you have TeX Gyre Termes. For cross-platform considerations, I would suggests TeX Gyre Termes (IMHO, it has better support in, of course, TeX).

Unfortunately mtpro2 uses fixed font attributes. This is because the legacy Times family, called ptm, has bold face in the b series. Let’s help mtpro2 to re-declare related commands by using implicit font attributes:

\documentclass{article}
\usepackage{fontspec}% no-math' is no longer needed since v2.7b (2019/02/12)
%\setmainfont{Times New Roman}
\setmainfont{TeX Gyre Termes}% For the TeX world, truly cross-platform
\setsansfont{TeX Gyre Heros}
\setmonofont{TeX Gyre Cursor}
\usepackage[lite]{mtpro2}
\DeclareSymbolFont{operators}{\encodingdefault}{\rmdefault}{\mddefault}{\updefault}
\SetSymbolFont{operators}{bold}{\encodingdefault}{\rmdefault}{\bfdefault}{\updefault}
\DeclareMathAlphabet{\mathbf}{\encodingdefault}{\rmdefault}{\bfdefault}{\updefault}
\DeclareMathAlphabet{\mathit}{\encodingdefault}{\rmdefault}{\mddefault}{\itdefault}
\DeclareMathAlphabet{\mathsf}{\encodingdefault}{\sfdefault}{\mddefault}{\updefault}
\DeclareMathAlphabet{\mathtt}{\encodingdefault}{\ttdefault}{\mddefault}{\updefault}
\SetMathAlphabet{\mathit}{bold}{\encodingdefault}{\rmdefault}{\bfdefault}{\itdefault}
\SetMathAlphabet{\mathsf}{bold}{\encodingdefault}{\sfdefault}{\bfdefault}{\updefault}
\SetMathAlphabet{\mathtt}{bold}{\encodingdefault}{\ttdefault}{\bfdefault}{\updefault}

\newcommand*\test[1]{\texttt{\string#1}: $#1{012abc}$}

\begin{document}
Normal math: $012abc$\par
\test\mbf\par
\test\mathrm, $\sin$\par
\test\mathbf\par
\test\mathit\par
\test\mathsf\par
\test\mathtt

Switch to \verb|\boldmath| now:\par
\boldmath
\test\mathrm, $\sin$\par
\test\mathbf\par
\test\mathit\par
\test\mathsf\par
\test\mathtt
\end{document}


P.S. The no-math option is no longer needed since fontspec v2.7b (2019/02/12). See this CTAN announcement.

The fontspec package allows you to set the math font with \setmathrm, and the \mathbf font with the BoldFont = option of \setmathrm. (ETA: Thanks to Ruixi Zhang. As of March 2019, this is bugged if you select [no-math].)

The example in the manual for loading a bold NFSS font as \mathbf is:

\AtBeginDocument{\DeclareMathAlphabet\mathbf{U}{eur}{b}{n}


Ruixi Zhang has a great answer that expands on this.

Other options include mathastext and, in XeLaTeX, mathspec. You could also drop the legacy 8-bit fonts entirely and use unicode-math with something like STIX Two Math.

• Hmm… \setmathrm{Times New Roman} no longer works with mtpro2, not even \setmathrm{Times New Roman}[BoldFont = Times New Roman Bold]. As I noted in my answer, since v2.7b, fontspec will automatically execute no-math when mtpro2 is detected. However, \setmathrm works only if no-math is NOT executed. So your solution is no longer valid under this new feature of fontspec. – Ruixi Zhang Mar 15 at 0:57
• @ruixi It sounds like a bug if \setmathrm is affected by [no-math]... – Will Robertson Mar 15 at 5:04
• @WillRobertson Interestingly, if I adjusted the \DeclareSymbolFont{operators}... code block, I got this result: i.stack.imgur.com/6k4HF.png – Ruixi Zhang Mar 15 at 12:40
• @RuixiZhang I’m not completely sure what MCVE is producing those results, but I’ll note that \boldmath\mathbf in fontspec would be set with the command \setboldmathrm{...}[ BoldFont = ... ]. I’m sure you knew that already, but I mention it because you point out it wasn’t doing anything by default (possibly because the default font family doesn’t come in extra-bold). – Davislor Mar 15 at 15:24
• @Davislor Apologies. The picture in my previous comment was meant to point out missing code in fontspec. See, with standard LaTeX2e, \documentclass{article} \begin{document} $abc\mathbf{abc}$ \boldmath$abc\mathbf{abc}$ \end{document} shows that \mathbf stays the same. If I then add \usepackage{fontspec} \setmathrm{TeX Gyre Termes} to the preamble, then the first \mathbf is in TeX Gyre Termes Bold, while the second is (still) in Computer Modern Bold Extended. One would expect, without the presence of “Extra Bold”, the two \mathbf` to be the same. – Ruixi Zhang Mar 16 at 1:39