Use a single math symbol, in medium and bold, from Latin Modern

fontssymbols

I use newtx and newtxmath in pdflatex with TeXLive, but I would like to use the \mathcal{O} symbol from Latin Modern. Following this answer, I am able to access the medium-series version. In the preamble, I add

 \DeclareSymbolFont{LMletters}{OMS}{lmsy}{m}{n}
 \DeclareMathSymbol{\lmO}{\mathbin}{LMletters}{79}

And then in the document, I can use e.g. $\lmO (N^{2})$.

But I would also like to use the boldface version of that symbol. Preferably it should work automatically with \bm, but if that is too hard, I wouldn't mind having simply a macro for it, e.g. \lmBO. However, the following attempt

  \DeclareSymbolFont{LMBletters}{OMS}{lmbsy}{b}{n}

returns the warning

   LaTeX Font Warning: Font shape `OMS/lmbsy/b/n' undefined
   (Font)              using `OMS/cmsy/m/n' instead on input line 30.

Note that \fonttable{lmbsy10} does print out, on my system, all the expected symbols, including the boldfaced mathcal O.

How do I access the boldfaced mathcal O from Latin Modern (while usingnewtxmath for all other math)? If possible, how to make this Latim Modern mathcal O work with \bm?

Best Answer

Use \SetSymbolFont to declare the font for math version bold.

\documentclass{article}
\usepackage{amsmath}
\usepackage{newtxtext, newtxmath}

\DeclareSymbolFont{LMletters}{OMS}{lmsy}{m}{n}
\SetSymbolFont{LMletters}{bold}{OMS}{lmsy}{b}{n}
\DeclareMathSymbol{\mscrO}{\mathalpha}{LMletters}{79}

\begin{document}
\[ O \quad \mathcal{O} \quad \mscrO \quad \boldsymbol{\mscrO}
\]
\end{document}

Latin Modern + NewTx sample

You might also declare \newcommand\mbfscrO{\boldsymbol{\mscrO}} for convenience and compatibility. I’m not sure whether giving this symbol the spacing of a binary operator was intentional, but if it was, you can easily change it back. You can optionally \usepackage{bm} after all your other math commands.

In unicode-math, you can override this symbol for both \mathcal and \mathbfcal with the range= option of \setmathfont, so:

\setmathfont{TeX Gyre Termes Math}[Scale=MatchUppercase]
\setmathfont{Latin Modern Math}[Scale=MatchUppercase,
                                range={\mscrO,\mbfscrO}]

You can then use \mbfscrO, \mathbfcal{O}, and a few other synonyms.