-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Bug with rendering $\hat$ with superscripts #712
Comments
Thanks for the report. I can confirm this across browsers. |
And while the bug was observed on mathim.com, I was able to reproduce it on cstheory.stackexchange.com (a Stackexchange site that also uses mathjax) |
The natural MathML translation of
That means the base of the power is the f with the hat. Superscripts are placed in relation to the height of the base, and that height includes the hat in this case, so the p is placed higher than it is when the f doesn't have the hat. (This is complicated by the fact that the OP has the STIX fonts, and it appears that the wrong hat is being used -- when used as an accent, the U+005E should be replaced by one of the smaller versions intended for accents -- so the height is even larger than usual; it looks better with the MathJax fonts, though still higher than for a plain f.) To get the same output as TeX, the layout for superscripts would have to ignore the height of the accent, and just use the height of the f. That would be possible, but would require making special cases in the treatment of Finally, note that native MathML in Firefox currently treats the |
Thanks, I suspected as much. I'll ask David Carlisle for some thoughts. |
A TeX example is
as Davide commented neither TeX nor MathML really offers any user-level control over this, TeX just has some heuristics in appendix G that tweak the superscript position in some simple cases (basically if the base is a single letter and the accent is a single glyph placed with the \accent primitive, even adding I don't think the high p is wrong, it's "just" a quality of rendering issue, similar to font specific kerning or ligatures. It would be nice (and conformant) if renderers could use similar special cases to TeX but I don't think it is strictly a bug if they don't (or if different MathJax back ends end up with different design choices here) I suppose if you really wanted to force the low p you could use mpadded to hide the height of the accent, but that would require the generated markup knowing the size of the accent (or base) and seems rather fragile in general (although I would guess mathjax has that information to hand?) |
@davidcarlisle, thanks for your comments on this, as always.
I think this is correct, except that there is one more restriction, which is that the class of the base has to be ORD. For example, In terms of using
where we make the height of the hat 0), but this would not be appropriate for all uses of
Actually, the TeX input processor has no idea about the size of the output (intentionally), and so it could not be done at the time
I agree, and am not sure it is worth trying to make it match the TeX output in this case. I suspect that it would be difficult to get it to handle exactly the situations that TeX does. |
By coincidence the W3C Math WG was having a telecon as this came up, and the consensus was as above that while in some cases it would be nice to have the superscripts aligned that at the mathml level there are no plans to add functionality for this. Patrick commented that he (in TeX) often changes fontdimen16/17 to change (raise) the default height of superscripts so that you do get more even superscript position over more varied base constructs in MathML this would amount to setting the superscriptshift length attribute on the unaccemted base so that the superscript was raised by a minimum amount that accounted for accented letters. |
Thanks for bringing it up. I wasn't expecting that MathML would add anything to accommodate this. You are right that I guess it will be up to the renderers how they want to treat this situation. I'm going to mark this as a feature request for now. |
yes it is no msup. sorry I meant use it on the expression with the |
Ah, yes, now I see what you meant. Sorry for the confusion. |
This will (finally) be resolved in v3 by PR mathjax/MathJax-src#618. |
Handle accents more like TeX does (better sizes and placement) (mathjax/MathJax#712, mathjax/MathJax#2474)
Consider the form$\hat{f}^p$ . Mathjax renders it in HTML-CSS mode with the superscript p above f, rather than to the right, as you'd get with $f^p$ .
The text was updated successfully, but these errors were encountered: