Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LaTeX input: add support for bm package #1219

Closed
pkra opened this issue Jul 27, 2015 · 17 comments
Closed

LaTeX input: add support for bm package #1219

pkra opened this issue Jul 27, 2015 · 17 comments

Comments

@pkra
Copy link
Contributor

@pkra pkra commented Jul 27, 2015

Tracking a feature request from elsewhere.

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

@pkra pkra added this to the A future release milestone Jul 27, 2015
@pkra pkra removed this from the A future release milestone Apr 20, 2016
@dancju
Copy link

@dancju dancju commented Apr 14, 2017

so bm will not be supported?

@pkra
Copy link
Contributor Author

@pkra pkra commented Apr 14, 2017

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.)

@bfirsh
Copy link

@bfirsh bfirsh commented Aug 31, 2017

This in your config seems to work as a workaround:

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

@pkra
Copy link
Contributor Author

@pkra pkra commented Aug 31, 2017

NOTE 2017-11-01 this is not how \bm works (see #1219 (comment) 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.

bfirsh added a commit to arxiv-vanity/engrafo that referenced this issue Aug 31, 2017
@davidcarlisle
Copy link

@davidcarlisle davidcarlisle commented Nov 1, 2017

\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!

@pkra
Copy link
Contributor Author

@pkra pkra commented Nov 1, 2017

Thanks so much for the correction, @davidcarlisle!

@pkra
Copy link
Contributor Author

@pkra pkra commented Nov 1, 2017

@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).

@pkra
Copy link
Contributor Author

@pkra pkra commented Nov 1, 2017

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

@davidcarlisle
Copy link

@davidcarlisle davidcarlisle commented Nov 1, 2017

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.

@dpvc
Copy link
Member

@dpvc dpvc commented Nov 2, 2017

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.

@pkra
Copy link
Contributor Author

@pkra pkra commented Nov 2, 2017

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?

@dpvc
Copy link
Member

@dpvc dpvc commented Nov 2, 2017

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.

@msc94
Copy link

@msc94 msc94 commented Apr 14, 2021

Why was this issue closed? Has it been implemented?

@pkra
Copy link
Contributor Author

@pkra pkra commented Apr 14, 2021

Why was this issue closed?

Because there hasn't been interest after six years.

Has it been implemented?

#1219 (comment) gives a very reasonable, 1-line implementation.

@msc94
Copy link

@msc94 msc94 commented Apr 14, 2021

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

@funnym0nk3y
Copy link

@funnym0nk3y funnym0nk3y commented Apr 25, 2021

Is it possible to extend the 1-line implementation #1219 (comment) to make the symbols italic? When using \boldsymbol in mathjax instead of \bm in KaTeX a \Lambda gets renderd upright whereas it gets rendered italic in KaTeX.

@dpvc
Copy link
Member

@dpvc dpvc commented Apr 25, 2021

@funnym0nk3y, \Lambda is rendered upright by \boldsymbol in MathJax as well. If you are using version 3 of MathJax, the recent 3.1.3 update added \mathbfit that will produce a bold italic \Lambda. Perhaps that is a better replacement for \bm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
7 participants