Mathjax: LaTeX input: add support for bm package

Created on 27 Jul 2015  路  15Comments  路  Source: mathjax/MathJax

Tracking a feature request from elsewhere.

Package info: http://ctan.org/pkg/bm

Feature Request good first contribution

Most helpful comment

This in your config seems to work as a workaround:

TeX: {
  Macros: {
    bm: ["{\\boldsymbol #1}",1],
  }
}

All 15 comments

so bm will not be supported?

so bm will not be supported?

The team was not planning on implementing it but contributions are always welcome.

I don't know the package but it seems to be equivalent to setting mathvariant='bold' in MathML (which would be very easy to implement). Maybe @davidcarlisle can chime in.

There might also be a font limitations (missing glyphs).

(I also never noticed the amount of :+1 -- no idea how to get notify by GitHub about these.)

This in your config seems to work as a workaround:

TeX: {
  Macros: {
    bm: ["{\\boldsymbol #1}",1],
  }
}

NOTE 2017-11-01 this is not how \bm works (see https://github.com/mathjax/MathJax/issues/1219#issuecomment-341052831 below); I'll leave it as it is perhaps interesting in terms of writing a switch.

This in your config seems to work as a workaround:

This wouldn't quite be sufficient since \boldsymbol is not a switch; e.g., { \bm aa} should have both a in bold.

Here's an example that @dpvc recently created:

MathJax.Hub.Config({
  TeX: {
    extensions: ["boldsymbol.js"],
    Augment: {
      Definitions: {macros: {
        bm: 'myBoldSwitch'
      }},
      Parse: {prototype: {
        myBoldSwitch: function (name) {
          this.stack.env.boldsymbol = true;
        }
      }}
    }
  }
});

Note: I have not checked if its behavior will match the bm package (as far as it's appropriate to ask that question anyway); @davidcarlisle would know best, of course.

\bm takes an argument In latex, {\bm aa} is the same as {\bm{a}a} with only the first a bold (and a spurious group around the outside. Please don't implement \bm as a switch making it incompatible with latex usage!

Thanks so much for the correction, @davidcarlisle!

@davidcarlisle so just

 Macros: {
      bm: ["\\boldsymbol{#1}",1]
    }

is better -- but not quite compatible as it won't use poor man's bold when needed (IIUC that would require changes in the font fallback behavior which might be doable in v3).

I've also added a note to my earlier comment.

yes the difference between boldsymbol and bm is mainly one of spacing, bm takes far more care to get the same math classes so if foo makes a binary operator or a an opening delimiter or a relation or whatever, then bm{foo} makes the same (if it can) but boldsymbol is (more or less) just hbox{boldmath$...$} so in most cases (apart from some special case relations) loses the distinction. But probably that's rather tex-implementation distinction that is less relevant here.

Just FYI, because \boldsymbol in MathJax simply adds the proper mathvariant to the internal MathML generated from the TeX, the spacing will be the same as without \boldsymbol since the spacing is based on the elements (and their content in the case of <mo>) not the variant.

Also, MathJax sets bold via CSS when falling back to system fonts.

@dpvc is there's ever a "font-internal" fallback case where MathJax would fall back to a non-bold alternative?

is there's ever a "font-internal" fallback case where MathJax would fall back to a non-bold alternative?

Yes. If there is a character not in the bold variant but in the normal variant, \boldsymbol{} will still produce the normal variant. E.g., \boldsymbol{\boxplus} is the same as \boxplus in the MathJax TeX fonts. For the most part, this will be characters in the MathJax_AMS-Regular font that are not in the MathJax_Main-Bold font.

Why was this issue closed? Has it been implemented?

Why was this issue closed?

Because there hasn't been interest after six years.

Has it been implemented?

https://github.com/mathjax/MathJax/issues/1219#issuecomment-341059843 gives a very reasonable, 1-line implementation.

Ok, just wanted to make sure that it wasn't closed because it was implemented without me noticing.
Thanks for the info!

Was this page helpful?
0 / 5 - 0 ratings