MathJax icon indicating copy to clipboard operation
MathJax copied to clipboard

v4 unexpected xrightarrow stretch in align*

Open pkra opened this issue 2 months ago • 3 comments

A minimal example from a real world use case:

\begin{align*}
A \qquad B & C \\
\xrightarrow{D} & E
\end{align*}

In "real" LaTeX, this comes out something like this:

Image

on mathjax.org#demo, it comes out like this:

Image

Note how the arrow stretches the entire cell.

This bug was easily worked around by adjusting the source but perhaps it's worth fixing.

(On a related note, the arrow wouldn't show with the CSS output which I think that is due to the CSP on mathjax.org).

pkra avatar Oct 27 '25 10:10 pkra

Thanks for the report. It turns out that \xrightarrow produces an mover element that is an embellished operator based on a stretchy arrow, and so when it appears alone in an mtd cell, the arrow is supposed to stretch to match the width of the cell. The arrow has to be stretchy for the mover, so that is a bit of a conundrum, and the only solution I can think of is to make sure that the result of \xrightarrow isn't an embellished operator so that it won'd be stretched to the cell width. I have some ideas about how to do that in a way that won't interfere with with it being treated as a REL in TeX wile still getting the correct spacing if used in MathML, but I need to test it out in more detail.

As for the missing arrow, that is not due to CSP, but to the fact that the needed CSS isn't being produced in CHTML output. That is because when the \xrightarrow is first processed, it picks one of the fixed-size arrows because the "D" is small enough for that. It turns out that U+27F6 (long right arrow) is what is used. Then when it gets stretched again for the mtd, it get marked as U+27F6, while the CSS for the original U+2192 is emitted rather than the CSS for U+27F6. That means the arrow end up having no height, and the clip path prevents the characters that are actually there from being displayed.

So two separate issues in one, Huzzah!

I'll work on PRs to resolve these.

dpvc avatar Oct 27 '25 14:10 dpvc

Thanks for looking into it, Davide.

pkra avatar Oct 27 '25 15:10 pkra

Just FYI, I made PRs last week to fix both issues.

dpvc avatar Nov 04 '25 13:11 dpvc