Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Support\text
inmathtext
#22173
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Support\text
inmathtext
#22173
Uh oh!
There was an error while loading.Please reload this page.
Conversation
lib/matplotlib/_mathtext.py Outdated
@@ -2294,6 +2301,18 @@ def non_math(self, s, loc, toks): | |||
self.get_state().font = mpl.rcParams['mathtext.default'] | |||
return [hlist] | |||
def text(self, s, loc, toks): | |||
self.pop_state() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This won't work with something liker"$\mathbf{\text{hello, world!}}$"
(popping out of the mathbf puts you in italic mode, and setting back to italic at exit isn't correct either; instead I think you just need to push a new state for the\text
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Ahh, OK! I'll look into the state things. Almost looked a bit too easy to solve it...
I can't repro the kerning issue? Usually you can try blowing up text size (e.g. fontsize=42) to make it easier to check them; otherwise it may just be pixellation. One major comment, but otherwise the approach looks good to me. (Just needs a test as well.) |
This is updated (although I only pushed, not commented), if you have time@anntzer ... |
Uh oh!
There was an error while loading.Please reload this page.
anntzer commentedMar 28, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Just one minor point left, I think. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
PR Summary
Closes#18520
gives

However, the kerning is still from math, see
where the spacing between the e and the r in where differs.
However, it is not the case for e.g.
r"where $\text{where}$"
so not really clear to me why and where this happens.Again, a bit doubtful (see#22171) if I can generate correct test images, so tests must be added.
It is not really clear how things will work with special symbols etc. Right now
\{
,\}
and\$
can be dealt with, but one can probably break it if one tries (as for LaTeX itself).PR Checklist
Tests and Styling
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).