Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add bfit bolditalic tex cmd #25359

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

Merged
merged 1 commit into from
Apr 21, 2023
Merged

Add bfit bolditalic tex cmd #25359

merged 1 commit into from
Apr 21, 2023

Conversation

devRD
Copy link
Contributor

@devRD devRD commented Mar 1, 2023

PR Summary

Fixes #19393
Adds support for bfit command in mathtext for bold italic

PR Checklist

Documentation and Tests

  • Has pytest style unit tests (and pytest passes)
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • New plotting related features are documented with examples.

Release Notes

  • New features are marked with a .. versionadded:: directive in the docstring and documented in doc/users/next_whats_new/
  • API changes are marked with a .. versionchanged:: directive in the docstring and documented in doc/api/next_api_changes/
  • Release notes conform with instructions in next_whats_new/README.rst or next_api_changes/README.rst

@anntzer
Copy link
Contributor

anntzer commented Mar 2, 2023

Is that only implemented for stix? Do dejavu & cm also need their own thing?

@devRD
Copy link
Contributor Author

devRD commented Mar 3, 2023

Looks like dejavu and cm require their own mappings.

@@ -151,6 +151,7 @@
(['mathrm'], all),
(['mathbf'], all),
(['mathit'], all),
(['mathbfit'], all),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment just above this list says “Add new tests at the end.” Looking at the failing tests themselves, it looks like the images are numbered according to the index in the list. So I think you just need to move your new entry to the end of the list.

@devRD devRD marked this pull request as ready for review March 9, 2023 07:45
@oscargus
Copy link
Member

oscargus commented Mar 9, 2023

Thanks for this! I think it is a great addition!

Some questions:

  • Will it be clear from the documentation that this is supported? (I wasn't aware of the mathbfit command earlier so would not have guessed that was the way to obtain it.) I think a what's new note is worthwhile as well.
  • Am I right in assuming that \mathbfit{foo} is the way to obtain it and that \mathbf{\mathit{foo}} is not working? Would it be possible to make it work? It seems from the tests that e.g. \mathbf{\mathsf{bar}} works?
  • (Now, none of those works in standard LaTeX so maybe not a big thing if only one works.)
  • Should one also add an alias for \boldsymbol which basically is a way to obtain the same result and maybe more people(?) use?

Note that apart from maybe the first bullet, these are not things that must be included in this PR. Just wanted to open the discussion.

@oscargus
Copy link
Member

oscargus commented Mar 9, 2023

This is probably a good location to document it:
https://matplotlib.org/stable/tutorials/text/mathtext.html#fonts

@devRD
Copy link
Contributor Author

devRD commented Mar 10, 2023

Hi @oscargus,

Thank you for the review! I have tried replying to your comments below:

  • I have updated the \mathbfit command in the docs font section in a new commit from the link you shared. The what's new section still needs to be updated.

  • Currently, \mathbfit{bar} is the preferred way to add bold-italic font. The \mathbf{\mathit{bar}} does not apply bold-italic, just derives the innermost style to use on the text.
    At present, the \mathbfit command is deriving a stylistic change for dejavu and dejavusans fonts and the Unicode mapping for stix

  • As you mentioned making a \boldsymbol alias to \mathbfit would probably be the way to go because I found that the bm package, which provides \boldsymbol command conflicts with the Unicode-math package. It can be added in a future PR.

@oscargus
Copy link
Member

Thanks! Would it also make sense to add it here? It seems to be working for stix right? (And then also for deja vu, but there is no special section for those I guess and maybe out of scope to add one.)
image

Also, for both entries here, it says "bold italic"?
image

@devRD
Copy link
Contributor Author

devRD commented Mar 10, 2023

I am not exactly sure how to add an alias for the \mathbfit command but I'll look into it. If you have any references I would appreciate it.

And, I believe the \mathbf command stating bold italic is incorrect as it just provides the boldface font. I can update both changes in a new commit.

@oscargus
Copy link
Member

I am not exactly sure how to add an alias for the \mathbfit command but I'll look into it.

I just checked the code and I do not think that there is an easy way to do that...

Probably one will have to add a special command for this, both wrt parsing and a callback.

@anntzer
Copy link
Contributor

anntzer commented Mar 11, 2023

@oscargus Per #19393 (comment), for consistency with latex, I think we should actually make \mathfoo{\mathbar{...}} not stack the styles, but just overwrite one another, and introducing \mathbfit for the stacked version seems correct.

@devRD
Copy link
Contributor Author

devRD commented Mar 17, 2023

Hi, @rcomer @oscargus @anntzer

Could you please review this patch and let me know if there are any further modifications required?

@rcomer
Copy link
Member

rcomer commented Mar 17, 2023

I'm afraid I don't have the expertise to review this one.

@oscargus
Copy link
Member

oscargus commented Mar 17, 2023

I think that the tutorial should be updated a bit further as discussed above (at least add it to the Stix section).

I'm also wondering if #mathtext.bfit:sans is the correct default rcParam, but I do not know exactly how that works. (I'd guess something like #mathtext.bfit:sans:italic:bold?)

Code-wise it looks good AFAICT.

@@ -340,6 +340,7 @@
## settings which map a TeX font name to a fontconfig font pattern. (These
## settings are not used for other font sets.)
#mathtext.bf: sans:bold
#mathtext.bfit:sans
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#mathtext.bfit:sans
#mathtext.bfit: sans:italic:bold

This is what I think is a more correct default.

Copy link
Member

@oscargus oscargus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some minor details, but all-in-all looking good!

@@ -0,0 +1,14 @@
Bold-italic cmd ``\mathbfit``
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Bold-italic cmd ``\mathbfit``
Bold-italic mathtext command ``\mathbfit``

Bold-italic cmd ``\mathbfit``
-----------------------------------------------------

Supports use of bold-italic font style in Mathtext using the *\mathbfit{}* command:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Supports use of bold-italic font style in Mathtext using the *\mathbfit{}* command:
Supports use of bold-italic font style in mathtext using the ``\mathbfit{}`` command:

@@ -220,6 +220,7 @@
``\mathfrak{Fraktur}`` :math-stix:`\mathfrak{Fraktur}`
``\mathsf{sansserif}`` :math-stix:`\mathsf{sansserif}`
``\mathrm{\mathsf{sansserif}}`` :math-stix:`\mathrm{\mathsf{sansserif}}`
``\mathbfit{bolditalic}`` :math-stix:`\mathbfit{bolditalic}}`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
``\mathbfit{bolditalic}`` :math-stix:`\mathbfit{bolditalic}}`
``\mathbfit{bolditalic}`` :math-stix:`\mathbfit{bolditalic}`

@devRD
Copy link
Contributor Author

devRD commented Mar 23, 2023

Hi @oscargus, I have updated the PR with the suggestions. Please let me know if anything else needs to be updated.

Copy link
Member

@oscargus oscargus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

A reminder to whoever may merge this to squash the commits. (@devRD if you know how to squash, please do.)

Copy link
Contributor

@anntzer anntzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extremely minor nits, but otherwise lgtm.

@devRD
Copy link
Contributor Author

devRD commented Apr 21, 2023

Hi all!
Thank you for the reviews. I have made the changes and rebased to the current main.

@anntzer anntzer added this to the v3.8.0 milestone Apr 21, 2023
@anntzer anntzer merged commit 70e674e into matplotlib:main Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

\bf\it in mathtext
6 participants