Skip to content

Support \boldsymbol. (Feature request.) #1366

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

Closed
smithsp opened this issue Oct 11, 2012 · 16 comments · Fixed by #25661
Closed

Support \boldsymbol. (Feature request.) #1366

smithsp opened this issue Oct 11, 2012 · 16 comments · Fixed by #25661

Comments

@smithsp
Copy link
Contributor

smithsp commented Oct 11, 2012

While I understand that it is possible to use

text.usetex = True

along with the appropriate declarations for text.latex.preamble to be able to use \boldsymbol, it would be nice to be able to keep

text.usetex = False

with something like

title(r'$\boldsymbol\psi_N$=0.95')

to achieve bold symbols.

Even better would be to detect whether the current font is bold, and automatically substitute in a \boldsymbol command.

(As always, I'm appreciative of the work that matplotlib developers have contributed, but I also know that the squeaky wheel gets the grease.)

@pelson
Copy link
Member

pelson commented Oct 12, 2012

As always, I'm appreciative of the work that matplotlib developers have contributed, but I also know that the squeaky wheel gets the grease.

Love it! Thanks for the squeak! :-)

@mdboom
Copy link
Member

mdboom commented Oct 12, 2012

There's two problems with doing this.

One is that \boldsymbol is actually an extension provided by the amssymb/amsmath packages. mathtext generally just supports things in the TeX core (though some concessions have been made to features from popular third-party packages and the ams stuff certainly qualifies as popular).

The other problem is really one of font availability. The computer modern truetype fonts that ship with matplotlib (the "Bakoma" fonts), simply don't contain those symbols. We would need to find another computer modern truetype distribution that had more stuff. And chances are it will have a different encoding, so the character map in _mathtext_data.py would have to be updated.

However, the STIX fonts do have a lot of the Greek symbols in bold, so you can set the rcParam 'mathtext.fontset' to 'stix' and then do:

$\mathbf{ \psi }$

(Of course, if you really want to use Computer Modern to match the rest of your paper, this is less than ideal.).

@pwuertz
Copy link
Contributor

pwuertz commented Oct 12, 2012

I recently came across the "Latin Modern Math" project when I was looking for math fonts with unicode support:
http://www.gust.org.pl/projects/e-foundry/lm-math

It is a modernized math font for the Computer Modern family in the OpenType format. I already used it in XeLaTeX but I guess one could use it for matplotlib mathtext as well..

@pelson
Copy link
Member

pelson commented Mar 25, 2013

@pwuertz - sounds interesting. Can you think of any drawbacks to this?

@mdboom
Copy link
Member

mdboom commented Mar 25, 2013

On first glance (I just opened it up in fontforge) it seems that Latin Modern follows the Unicode mapping, which would be nice because we could drop our Bakoma-specific mapping and share the Unicode mapping that's already used for the STIX fonts. This should, if nothing else, be less code to maintain.

@pelson
Copy link
Member

pelson commented Mar 26, 2013

@mdboom - showing my naïvety here, but is there a font which could render the text inside a mathtex block (wrapped by \mathrm{}) the same as text outside of a mathtex block?

@mdboom
Copy link
Member

mdboom commented Mar 26, 2013

The font used in the \mathrm{} section can be configured using the mathtext.rm rcParam. So you can set that to the same value as font.family if you want them to match. By default, it chooses the font designed to work with the rest of the math content, so Computer Modern Roman when mathtext.fontset is set to cm.

@mdboom
Copy link
Member

mdboom commented Mar 26, 2013

I mispoke -- mathtext.rm only gets used if mathtext.fontset is custom... So I'm not sure that works in conjunction with the Bakoma/Computer Modern fonts. I may want to add that as a bug that I can tackle when I tackle other things related to our math fonts.

@pelson
Copy link
Member

pelson commented Mar 27, 2013

Thanks Mike that helped me along the way, to match the mathtex font to the normal text font (in my case at least):

    ...
    matplotlib.rcParams['mathtext.rm'] = 'Bitstream Vera Sans'
    matplotlib.rcParams['mathtext.fontset'] = 'custom'
    matplotlib.rcParams['mathtext.cal'] = 'Bitstream Vera Sans'
    ...
    ax.xaxis.label.set_text(r'$\mathrm{Foobar}\ /\ wibble\ bar^{-1}$')

There is so much font capability in mpl that isn't really documented - are fonts your forte? Are there improvements to the font systems that you would like to see implemented before we write a font chapter in the documentation?

@petehuang
Copy link
Contributor

Seems like there are really two issues here: one for the original \boldsymbol request and one for a broader font documentation request

The latter certainly stands, but where do we stand on \boldsymbol? Is this a can't fix (i.e., what's our gut sense on whether or not a suitable font exists?)?

@mojca
Copy link

mojca commented Jan 1, 2017

The XITS fonts (derived work from STIX that did not deliver for years and years and years) contains both a regular and a bold variant.

The Polish TeX user group GUST is working on a number of free Unicode math fonts and some of them come or will come in a bold variant. Even the non-bold fonts contain a number of bold symbols inside the "bold" Unicode slots. Supporting "bold mathematical ..." is certainly worth looking into.

There are also some commercial fonts like Lucida with a special bold font.

What I don't know is how much effort is needed to get the OpenType Math working in matplotlib.

@QuLogic
Copy link
Member

QuLogic commented Jan 2, 2017

We no longer use Vera + CM fonts, but DejaVu fonts in all cases (by default.) These fonts contain bold-italic symbols here:
screenshot from 2017-01-01 19-40-17
so there is no need for extra fonts.

@mojca
Copy link

mojca commented Jan 2, 2017

There is also http://www.gust.org.pl/projects/e-foundry/tex-gyre-dejavu-math. If bold symbols from the Unicode math repertoire is going to be used, it should be pretty straightforward to switch to a different Unicode Math OTF font.

@tacaswell tacaswell modified the milestones: 2.1 (next point release), 2.2 (next next feature release) Sep 24, 2017
@github-actions
Copy link

This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label Feb 27, 2023
@mojca
Copy link

mojca commented Feb 27, 2023

The request is still valid/wanted.

@rcomer rcomer removed the status: inactive Marked by the “Stale” Github Action label Feb 27, 2023
@QuLogic QuLogic modified the milestones: future releases, v3.8.0 Jul 11, 2023
@egnerney
Copy link

\perp won't go bold for me using this and when I use Latex then nothing will go bold and the font looks worse/inconsistent with other plots. Please help.

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

Successfully merging a pull request may close this issue.