[Tex/LaTex] Bold italic math with unicode-math

bolditalicmath-modeunicode-math

How can I get the output I get without unicode-math using unicode-math, preferably (not necessarily) using the same code (\boldmath)? I would like the solution to work with at least the XITS and Latin Modern fonts, both of which have no build-in bold math font..

edit: I can see attention is fading away. Of course it is not possible to make non-bold fonts 'truly bold', but the output Word produces when you make formulae bold is acceptable, and Cambria Math also doesn't have a bold font. You can even make XITS and Latin Modern bold in math just by pressing CTRL+B. I accept any answer that makes LaTeX behave like Word in this.

Without unicode-math

\documentclass{article}
\begin{document}
  This should be entirely bold: {\boldmath$O(\log n)$} \\
  This should not be bold: $O(\log n)$
\end{document}

I get nice-looking output:

Output without unicode-math.

With unicode-math, the code

\documentclass{article}
\usepackage{unicode-math}
\setmainfont{XITS}
\setmathfont{XITS Math}
\begin{document}
This should be entirely bold: {\boldmath$O(\log n)$} \\
This should not be bold: $O(\log n)$
\end{document}

gives

With unicode-math 1.

I already tried a bunch of things, for example the following code.

\documentclass{article}
\usepackage{unicode-math}
\setmainfont{XITS}
\setmathfont{XITS Math}
\setmathfont[range=\mathup/{greek,Greek,latin,Latin,num}]{XITS}
\setmathfont[range=\mathit/{greek,Greek,latin,Latin,num}]{XITS Italic}
\setmathfont[range=\mathbfup/{greek,Greek,latin,Latin,num}]{XITS Bold}
\setmathfont[range=\mathbfit/{greek,Greek,latin,Latin,num}]{XITS Bold Italic}
\begin{document}
This should be entirely bold: {\boldmath$O(\log n)$} \\
This should not be bold: $O(\log n)$
\end{document}

Which unfortunately gives me this:

With unicode-math 2.

Word output looks like this:

enter image description here.

Best Answer

A "poor person's \boldmath can be obtained by

\documentclass{article}
\usepackage{unicode-math}
\setmainfont{XITS}
\setmathfont{XITS Math}
\setmathfont[version=bold,FakeBold=3.5]{XITS Math}

\begin{document}
This should be entirely bold: {\boldmath$O(\log n)$} \\
This should not be bold: $O(\log n)$
\end{document}

I presume that this is how word processors fake bold for fonts not having a real one.

enter image description here

Note: choosing XITS "non math" for math symbols may have adverse effects.

Related Question