# How to make \bm{<number>} work with \usepackage[libertine]{newtxmath} and pdflatex?

I get bold 0 as exected when I compile the following code with lualatex. However, I get normal (not bold) 0 with pdflatex. Is there any workaround to get bold 0 with pdflatex?

\documentclass{article}
\usepackage[libertine]{newtxmath}
\usepackage{bm}

\begin{document}
0$0\bm{0}$ % OK with lualatex, but not with pdflatex
\end{document}


My environment is

pdfTeX 3.14159265-2.6-1.40.17 (TeX Live 2016)
LuaTeX, Version 0.95.0 (TeX Live 2016)
bm: 2017/01/16
newtx: 1.515 2017-01-22


When you pass libertine as an option to newtxmath it then uses the semi-bold weight in mathematics for bold characters. However, you have not loaded a text font, so the default Computer Modern fonts are being used for numbers etc. in mathematics, but there is no semi-bold weight version of the Computer Modern fonts. A work around is to add a font substitution instruction

\DeclareFontShape{OT1}{cmr}{sb}{n}{<->ssub * cmr/b/n}{}


which gives the desired result, as the document below demonstrates, by substituting the sb weight by the b weight. But really you should be loading an appropriate text font to match the mathematics, e.g. just issue

\usepackage{libertine}


before loading newtxmath instead.

\documentclass{article}

\usepackage[libertine]{newtxmath}
\usepackage{bm}
\DeclareFontShape{OT1}{cmr}{sb}{n}{<->ssub * cmr/b/n}{}

\begin{document}

Testing some mathematics $$x = y^2 = \int_0^1 2y\,dy$$.

Testing some bold symbols $$\bm{v} = (0,0,0) = \bm{0}$$.

\end{document}


Incidentally you can see exactly which characters are being printed by issuing \showoutput in your file.

• +1 I was just writing same thing:-) but what I'm not clear about is why \usepackage[libertine]{newtxmath} left the math digits using cm, that seems.. unexpected? – David Carlisle Jan 25 '17 at 10:59
• @DavidCarlisle The newtx documentation states that "it uses the text font settings to define how operators, numbers, math accents, \mathrm, \mathbf etc. are rendered." – Andrew Swann Jan 25 '17 at 11:02
• low blow that, reading documentation:-) I sort of assumed it would do that but libertine option would tell it to use libertine not cm, but I never looked at any doc:-) – David Carlisle Jan 25 '17 at 11:07