[Tex/LaTex] Making bold numbers in math mode using bm package

boldfontsmath-mode

I am having some troubles producing numbers in math mode in bold. \mathbf{} command worked with the mathptmx package, producing bold numbers that looked like numbers in math mode, but bold. Then I started using the newtxmath package alongside the bm and now they look not like I want to.

mathbf{1} produces a symbol which looks like number 1, but like a text-mode 1. While \bm{} and \boldsymbol won't work. Here is an output of

$\bm{1}$\\
$\boldsymbol{1}$\\
$\mathbf{1}$\\
\textbf{1}

ones

Am am using Georgia font with its "low" numbers, so you can definitively tell the difference between math mode and text mode.

Is there any solution for this problem?

Here is the full code (you need Lua or Xe LaTex to compile):

\documentclass[10pt]{article}

\usepackage{newtxmath}
\usepackage{bm}

\usepackage{polyglossia}    
\defaultfontfeatures{Ligatures=TeX}
\setmainfont{Georgia}
\newfontfamily\cyrillicfont{Georgia}
\setmainlanguage{russian}

\begin{document}
\noindent
$\bm{1}$\\
$\boldsymbol{1}$\\
$\mathbf{1}$\\
\textbf{1}
\end{document}

UPDATE: The thing finally worked, when I have compiled the file on another PC. Which is strange, because as I get it, TexLive updates the packages and compilers automatically, so it doesn't seem to be a matter of version.

It would be great if somebody explains me what is going on here.

Best Answer

You’re loading polyglossia, which loads fontspec, and using an OpenType font. This is not compatible with the legacy package bm.

One solution is:

\usepackage{unicode-math}
\defaultfontfeatures{ Ligatures=TeX, Scale=MatchLowercase }
\setmathfont{TeX Gyre Termes Math} % Or another math font
\setmathfont{Georgia}[range=up]
\setmathfont{Georgia Italic}[range=it]
\setmathfont{Georgia Bold}[range=bfup]
\setmathfont{Georgia Bold Italic}[range=bfit]

This will allow you to use \mathbf{1} or \symbf{1}. If you don’t ever use \mathbf for words in math mode, you might use the option \usepackage[mathbf=sym]{unicode-math}, and make \mathbf a synonym for \symbf. Theoretically, this invokes the bold alphanumeric symbols from your math font, rather than a text font, although here you’re setting them both to the same font anyway. You can still use \textbf (or, more robustly, \textnormal{\bfseries ...}) in math mode.

If you have a version of Georgia that supports lining numbers, you can additionally give the supplemental \setmathfont commands the option Numbers=Lining. Or, if you specifically want to use Georgia for letters and not numbers, you may specify range=up/{Latin,latin,Greek,greek}, etc.

You can change the \mathbf font, which is intended for words and short phrases in math mode, to something different from your main text font with \setmathrm[BoldFont={...}, BoldFeatures={...}]. Alternatively, you can call \usepackage[no-math]{fontspec} before polyglossia to prevent it from changing \mathbf, \mathrm, and so on.

The unicode-math package does support \boldsymbol, but this calls \mathversion{bold}. As of 2020, unicode-math does not support both the version=bold and range= options of \setmathfont at the same time, so you cannot reliably use \boldsymbol and also change the letters in math mode.

Other options to change the math font to Georgia are mathastext, or, in XeTeX, mathspec.