How can I declare a heavy maths version without altering spacing and symbol choice when \hm is used from the bm package?

Consider the following MWE which is modified from my answer here:

\documentclass{article}
\newcommand\gmfamily{\fontfamily{mdugm}\selectfont}

\DeclareMathVersion{varnormal}
\DeclareMathVersion{heavy}
\newcommand\mdmath{\mathversion{varnormal}}
\newcommand\mdboldmath{\mathversion{heavy}}
\newcommand\heavymath{\mathversion{heavy}}

\SetSymbolFont{letters}{varnormal}{OML}{mdugm}{m}{it}
\SetSymbolFont{letters}{heavy}{OML}{mdugm}{b}{it}
\SetSymbolFont{operators}{varnormal}{OT1}{mdugm}{m}{n}
\SetSymbolFont{operators}{heavy}{OT1}{mdugm}{b}{n}
\SetSymbolFont{symbols}{varnormal}{OMS}{mdugm}{m}{n}
\SetSymbolFont{symbols}{heavy}{OMS}{mdugm}{b}{n}
\SetSymbolFont{largesymbols}{varnormal}{OMX}{mdugm}{m}{n}
\SetSymbolFont{largesymbols}{heavy}{OMX}{mdugm}{b}{n}
\SetMathAlphabet{\mathrm}{varnormal}{OT1}{mdugm}{m}{n}
\SetMathAlphabet{\mathrm}{heavy}{OT1}{mdugm}{b}{n}

\SetMathAlphabet{\mathit}{varnormal}{OT1}{mdugm}{m}{it}
\SetMathAlphabet{\mathit}{heavy}{OT1}{mdugm}{b}{it}

\usepackage{bm}

\begin{document}

\gmfamily\mdmath
This is Garamond font. $a^2 + b^2 = c^2$. Math font
$\sum_i \int_a^b \left( \frac1{K+1} \oplus\alpha_i \right) \,\mathrm{d}x = 0$
and bold math font
{\mdboldmath$\sum_i \int_a^b \left( \frac1{K+1} \oplus\alpha_i \right) \,\mathrm{d}x = 0$}
$\hm{\sum_i \int_a^b \left( \frac1{K+1} \oplus\alpha_i \right) \,\mathrm{d}x = 0}$

\end{document}


This produces the following unexpected (to me) results:

Question: How can I modify this example so that the combination of the maths versions varnormal and heavy activated by \mdmath and \hm produce the expected results i.e. so that the (round) brackets and limits are typeset correctly?

Note that the issue is not inherent to the fonts themselves. Nor is it an effect of using bm per se. The following code works fine:

\documentclass{article}
\renewcommand\rmdefault{mdugm}

\DeclareSymbolFont{letters}{OML}{mdugm}{m}{it}
\SetSymbolFont{letters}{bold}{OML}{mdugm}{b}{it}
\DeclareSymbolFont{operators}{OT1}{mdugm}{m}{n}
\SetSymbolFont{operators}{bold}{OT1}{mdugm}{b}{n}
\DeclareSymbolFont{symbols}{OMS}{mdugm}{m}{n}
\SetSymbolFont{symbols}{bold}{OMS}{mdugm}{b}{n}
\DeclareSymbolFont{largesymbols}{OMX}{mdugm}{m}{n}
\SetSymbolFont{largesymbols}{bold}{OMX}{mdugm}{b}{n}
\DeclareMathAlphabet{\mathrm}{OT1}{mdugm}{m}{n}
\SetMathAlphabet{\mathrm}{bold}{OT1}{mdugm}{b}{n}
\DeclareMathAlphabet{\mathit}{OT1}{mdugm}{m}{it}
\SetMathAlphabet{\mathit}{bold}{OT1}{mdugm}{b}{it}

\usepackage{bm}

\begin{document}

This is Garamond font.
$a^2 + b^2 = c^2$.
Maths font
$\sum_i \int_a^b \left( \frac1{K+1} \oplus\alpha_i \right) \,\mathrm{d}x = 0$
and bold maths font
$\bm{\sum_i \int_a^b \left( \frac1{K+1} \oplus\alpha_i \right) \,\mathrm{d}x = 0}$

\end{document}


This works as expected:

Important: in my original answer, I'm using regular Garamond as the varnormal version and bold Garamond as the heavy version, with the normal and bold maths versions reserved for a different font family. So simply not declaring the heavy or varnormal maths versions is not a solution even though it would clearly be the obvious answer in the MWE.

It is possible to workaround this problem by defining a second package, varbm, such that varbm.sty is to maths version varbold what bm.sty is to maths version bold. (In that case, of course, heavy needn't be used at all.) This works fine and is what I've done in my revised answer. However, it seems overkill as it involves duplicating almost all of bm.sty. Even if it is, in fact, the best solution, I'd still like to know exactly what is going wrong in this case.

• I'm confused about the intent of the example. You've declared a heavy math version but not specified any fonts for that version? Your declarations for math fonts are just in the normal and bold versions? Aug 2 '15 at 16:22
• @DavidCarlisle Does this make any more sense? I'm not convinced it will. It is closer to the code in my original answer but still tries to be a bit more minimal.
– cfr
Aug 2 '15 at 18:48
• actually it made a bit more sense once I studied the linked question, although I think using heavy for that is wrong really it forced bm to try to squeeze three weights into 16 families. My answer (more or less) explains why you didn't get bold large brackets (no brackets were defined so it falls back to the default weight) I think I'll leave it at that today Aug 2 '15 at 19:01
• @DavidCarlisle Thanks. So the brackets is just because it has run out of font families? Why is the lower limit on the integral mis-spaced? I need to poke around more as I don't really understand what bm is doing. (The source does not mean much to me.)
– cfr
Aug 2 '15 at 19:13
• not run out just not defined at all, you had declared a heavy math version but declared no fonts for that version. Aug 2 '15 at 19:43

If you declare a heavy math version you need to define some fonts for it, here I just make them the same as the bold ones (which just means that you are more or less bound to run out of 16 math fam, but you get bold brackets)

\documentclass{article}
\DeclareMathVersion{heavy}
\renewcommand\rmdefault{mdugm}
\newcommand\heavymath{\mathversion{heavy}}

\DeclareSymbolFont{letters}{OML}{mdugm}{m}{it}
\SetSymbolFont{letters}{bold}{OML}{mdugm}{b}{it}
\SetSymbolFont{letters}{heavy}{OML}{mdugm}{b}{it}
\DeclareSymbolFont{operators}{OT1}{mdugm}{m}{n}
\SetSymbolFont{operators}{bold}{OT1}{mdugm}{b}{n}
\SetSymbolFont{operators}{heavy}{OT1}{mdugm}{b}{n}
\DeclareSymbolFont{symbols}{OMS}{mdugm}{m}{n}
\SetSymbolFont{symbols}{bold}{OMS}{mdugm}{b}{n}
\DeclareSymbolFont{largesymbols}{OMX}{mdugm}{m}{n}
\SetSymbolFont{largesymbols}{bold}{OMX}{mdugm}{b}{n}
\SetSymbolFont{largesymbols}{heavy}{OMX}{mdugm}{b}{n}
\DeclareMathAlphabet{\mathrm}{OT1}{mdugm}{m}{n}
\SetMathAlphabet{\mathrm}{bold}{OT1}{mdugm}{b}{n}
\SetMathAlphabet{\mathrm}{heavy}{OT1}{mdugm}{b}{n}
\DeclareMathAlphabet{\mathit}{OT1}{mdugm}{m}{it}
\SetMathAlphabet{\mathit}{bold}{OT1}{mdugm}{b}{it}
\SetMathAlphabet{\mathit}{heavy}{OT1}{mdugm}{b}{it}

\usepackage{bm}

\begin{document}

This is Garamond font.
$a^2 + b^2 = c^2$.
Maths font
$\sum_i \int_a^b \left( \frac1{K+1} \oplus\alpha_i \right) \,\mathrm{d}x = 0$
and bold maths font
$\bm{\sum_i \int_a^b \left( \frac1{K+1} \oplus\alpha_i \right) \,\mathrm{d}x = 0}$
and heavy maths font (which should just be bold?)
$\hm{\sum_i \int_a^b \left( \frac1{K+1} \oplus\alpha_i \right) \,\mathrm{d}x = 0}$

\end{document}

• Thanks. Probably I made my example too minimal. I'll see if I can edit it.
– cfr
Aug 2 '15 at 18:34