-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Slightly better positioning of subscripts and superscripts of fractions #21850
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
Conversation
This looks like really good work, bt I feel un-able to properly review it. Who is our resident expert in mathtext? |
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.
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.
Shortcuts I took for the algorithm
|
Closing. Superseded by #22852. |
PR Summary
Tries to improve the positioning of sub- and superscripts attached to fractions (fix #18086).
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).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_up
andshift_down
.I hate magic constants (
0.4
and1.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_up
andshift_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.