Skip to content

Support \boldsymbol. (Feature request.) #1366

Closed

Description

@smithsp

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

Activity

  1. pelson commented on Oct 12, 2012

    @pelson
    Member

    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! :-)

  2. mdboom commented on Oct 12, 2012

    @mdboom
    Member

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

  3. pwuertz commented on Oct 12, 2012

    @pwuertz
    Contributor

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

  4. pelson commented on Mar 25, 2013

    @pelson
    Member

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

  5. mdboom commented on Mar 25, 2013

    @mdboom
    Member

    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.

  6. pelson commented on Mar 26, 2013

    @pelson
    Member

    @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?

  7. mdboom commented on Mar 26, 2013

    @mdboom
    Member

    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.

  8. mdboom commented on Mar 26, 2013

    @mdboom
    Member

    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.

  9. pelson commented on Mar 27, 2013

    @pelson
    Member

    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?

  10. added this to the milestone on Aug 18, 2014
  11. petehuang commented on Dec 31, 2016

    @petehuang
    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?)?

  12. mojca commented on Jan 1, 2017

    @mojca

    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.

  13. QuLogic commented on Jan 2, 2017

    @QuLogic
    Member

    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.

  14. mojca commented on Jan 2, 2017

    @mojca

    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.

  15. modified the milestones: , on Sep 24, 2017
  16. github-actions commented on Feb 27, 2023

    @github-actions

    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!

  17. mojca commented on Feb 27, 2023

    @mojca

    The request is still valid/wanted.

  18. egnerney commented on Jul 21, 2024

    @egnerney

    \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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions