As I understand your question, you would like the \bm
command to always typeset its contents in slanted style, whether in ordinary, i.e., serif, math mode or in the sansmath environment. The following modified version of your MWE achieves this objective.
Relative to your code, I've made the following three changes: (a) The sansmath
package is now loaded with the T1
option; (b) the \SetMathAlphabet{\mathsfbf}...{bx}{sl}
command tells LaTeX to use a slanted font in bold-math mode; (c) the sansmath
environment is augmented so that \bm
will typeset its argument the way that \mathsfbf
does. (I say "augmented" rather than "patched" because I believe that the sansmath
package predates the bm
package. Hence, the sansmath
package couldn't make allowance for the emergence of the subsequent \bm
command, right?)
A word of caution: This quick fix lets \bm
operate, as expected, on lower- and uppercase Latin letters in the sansmath
environment. However, some of the other "magic" of the bm
package, which lets it operate on Greek letters and math symbols as well, is not preserved by this method. To set Greek letters and math symbols in bold in the sansmath environment, you'll have to use the \boldsymbol
command. (By the way, AFAIK the Latin Modern font family doesn't provide separate sans-serif math-mode Greek letters, whether regular weight or bold. Therefore, if you use Greek letters in the sansmath
environment, you'll get the ordinary math-mode Greek letters, which may look wrong in a sans-serif environment. If you must have sans-serif Greek math-mode letters in your document, you should probably use xelatex and employ a specialized math font that does provide this feature.)
\documentclass{scrartcl}
\usepackage{lmodern,bm}
\usepackage[T1]{sansmath}
\SetMathAlphabet{\mathsfbf}{sans}{\sansmathencoding}{\sfdefault}{bx}{sl}
\usepackage{etoolbox}
\AtBeginEnvironment{sansmath}{\let\bm\mathsfbf}{}{}
\begin{document}
Serif math:
$\bm{d} = (d_1, d_2)$
$\mathbf{d} = (d_1, d_2)$
\textsf{Sans-serif math:}
\begin{sansmath}
$\bm{d} = (d_1, d_2)$
$\mathbf{d} = (d_1, d_2)$
\end{sansmath}
\end{document}
I suggest you take a look at Michael Sharpe's mathalfa (the spelling "mathalpha" works too) package. In the package's user guide, the author lists five "hollowed-out" and fourteen [!] "geometric" variants of blackboard-bold fonts. (Note that not all of the underlying fonts are free.) I trust that one or more of the math blackboard board fonts listed and/or made available through the mathalfa
package will meet your needs. (I'm afraid I don't have access to German-language math textbooks.)
A big plus of using the mathalfa
package is that you can "mix and match" various math alphabets (blackboard bold, caligraphic, curly, script, fraktur, etc) with ease. Excerpting from the README file that comes with the mathalfa package:
This package provides a standard means of setting math alphabets
associated with the macros \mathcal, \mathbb, \mathfrak and \mathscr
and, where available, their bold counterparts \mathbcal, \mathbbb,
\mathbfrak and \mathbscr.
It mostly bypasses the usual fd and sty files used to load these
alphabets in order to allow each to be scaled independently and
without silently quantizing the sizes.
Best Answer
If you have the option of using
lualatex
thenunicode-math
provides access to such characters:Tex Gyre Termes Math
is quite new, an older font isTex Gyre Pagella Math
, the name has just changed fromTG Pagella Math
:Alternatively there are the
XITS
fonts, where the distinction is less clear: