-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
sub/superscripts should be moved further from the baseline following large delimiters #18086
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
Comments
I tried my hand at this, but really couldn't really gain a foothold. In the process, I found some things. Maybe these are already known to some people, but I thought I'd document them here for someone else who might consider working on this issue. The main problem is that the amount by which the subscript is shifted down and that by which the superscript is shifted up are not dependent on the height of the nucleus (the expression the sub- and superscript are attached to)--they are calculated only from some font constants, as this example indicates. Notice that the sub- and superscript are shifted by the same amounts, irrespective of whether the nucleus is
In theory, this should be easy to fix. If the nucleus is a fraction, move the subscript down by More specifically, for I initially tried to store the height and depth of each nucleus encountered in a new class variable--fairly sure that new nuclei are created here. That fixed the above example, but broke things like If somebody has any good ideas ... |
Thank you for investigating this. It may be worth trying to figure out in the TeXbook the exact algorithm used by TeX (similarly to what was done in #18389 (comment))? |
From a quick reading of some relevant parts of the book (sections 687, 690, 696 and 742), it looks like the algorithms do indeed use the nucleus in some way to correctly position the subscripts and superscripts. Section 751 details the calculation of The |
Doesn't it? I see a matplotlib/lib/matplotlib/_mathtext.py Line 2572 in 9d73164
|
Exactly. When the nucleus is a fraction, this function is called multiple times. Once with an ETA I see now; I said that wrong. What I meant was: The subsuper function does not receive the nucleus along with the subscript and superscript when the nucleus is a fraction. |
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! |
@devRD pinging you here, just in case this may be of interest for you :) |
This is still a problem. I didn't notice the very old report of it here, and duplicated it in #28149, which I subsequently closed, since this is the same. |
@mendenmh I gave this a shot in #22852. Even got a working solution. But couldn't fix the tests in a satisfactory way! For one, it is extremely hard to review all image comparison tests. Not to mention the fact that the hinting mysteriously changed between tests and normal runs. You're welcome to try if you have any ideas! |
Very nice! It works. For now, I will just use it, rather than poke at issues related to hinting.
Marcus
… On May 5, 2024, at 1:34 AM, Vishal Pankaj Chandratreya ***@***.***> wrote:
@mendenmh I gave this a shot in #22852. Even got a working solution. But couldn't fix the tests in a satisfactory way! For one, it is extremely hard to review all image comparison tests. Not to mention the fact that the hinting mysteriously changed between tests and normal runs. You're welcome to try if you have any ideas!
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Bug report
Bug summary
Matplotlib's mathtext appears not to take the size of the preceding glyph into account when positioning sub/superscripts.
Code for reproduction
Actual outcome
Note that the baseline of the
2
is even lower than the baseline of thex
in the mathtext case.Expected outcome
Something approaching the usetex case.
Matplotlib version
print(matplotlib.get_backend())
): qt5aggThe text was updated successfully, but these errors were encountered: