Slightly better positioning of subscripts and superscripts of fractions#21850
Closed
tfpf wants to merge 3 commits intomatplotlib:mainfrom
Closed
Slightly better positioning of subscripts and superscripts of fractions#21850tfpf wants to merge 3 commits intomatplotlib:mainfrom
tfpf wants to merge 3 commits intomatplotlib:mainfrom
Conversation
Contributor
Author
QuLogic
reviewed
Dec 18, 2021
Member
|
This looks like really good work, bt I feel un-able to properly review it. Who is our resident expert in mathtext? |
QuLogic
reviewed
Feb 2, 2022
Member
QuLogic
left a comment
There was a problem hiding this comment.
Were you able to check this against the texbook that @anntzer suggested in the issue? I think sub/superscripts are defined around program 756 on page 280 there. This might be difficult to use though if the nucleus is not accessible.
No point running the tests if we are absolutely sure they are going to fail.
Contributor
Author
Contributor
Author
3 tasks
Contributor
Author
Shortcuts I took for the algorithm
|
Contributor
Author
|
Closing. Superseded by #22852. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




PR Summary
Tries to improve the positioning of sub- and superscripts attached to fractions (fix #18086).
PR Checklist
Tests and Styling
pytestpasses).flake8-docstringsand 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).Details
Before
After
Notes
I added a new production rule for the tokenisation of expressions containing subscripts and superscripts.
This should be considered suboptimal, but with my extremely limited knowledge of languages, grammars and parsing, this is the best idea I could come up with. This addition has the effect of making the nucleus (i.e. the expression to which a subscript and/or superscript are/is attached) available for the calculation of
shift_upandshift_down.I hate magic constants (
0.4and1.4) as much as the next person, but can't think of anything better to differentiate nuclei which are and aren't fractions. This works for Dejavu Sans, but not for Computer Modern or STIX or Dejavu Serif. So, I'll leave this as a draft. Would appreciate experts weighing in.LaTeX uses a wide assortment of font parameters (stored in
font_info, an array) to calculateshift_upandshift_down, so the results of this will not exactly match what LaTeX gives us, but it will be close. Nevertheless, this will have to be tested extensively.Needless to say, sub- and superscripts can be nested.
Another point to note is that this will be affected by #20627, so a rebase may be required later.