mathjax / MathJax

Beautiful and accessible math in all browsers
http://www.mathjax.org/
Apache License 2.0
10.18k stars 1.16k forks source link

TeX Inline Wrapping #3297

Open JustTheCoolest opened 1 week ago

JustTheCoolest commented 1 week ago

Issue Summary

When inline MathJax is getting rendered and has to wrap, it's wrapping only the MathJax portion of it, and not the surrounding normal text

Steps to Reproduce:

(Note this $(inline * aaaaaaaaaaaa * aaaaaaaaaaaaaaaaaaa)$)

Screenshot_20241013-183413

This is incredibly misleading especially when dealing with brackets in mathematics

Technical details:

MathJax.js v2.7.5
TeX Input Jax v2.7.5
HTML-CSS Output Jax v2.7.5
PreviewHTML Output Jax v2.7.5
mml Element Jax v2.7.5
AssistiveMML Extension v2.7.5
MathEvents Extension v2.7.5
MathMenu Extension v2.7.5
MathZoom Extension v2.7.5
TeX/AMSmath Extension v2.7.5
TeX/AMSsymbols Extension v2.7.5
TeX/begingroup Extension v2.7.5
TeX/noErrors Extension v2.7.5
TeX/noUndefined Extension v2.7.5
accessibility-menu Extension v1.5.0
fast-preview Extension v2.7.5
tex2jax Extension v2.7.5
Safari v7.0 — woff or otf fonts
dpvc commented 1 week ago

Well, version 2.7.5 used by StackExchange sites is pretty old (over six years old now). The current release is 3.2.2, and they have recently added an opt-in preference for using that instead of v2. but v3 doesn't support automatic line breaks. That is available in v4 (currently in beta release).

The issue you are seeing is due to the fact that when an inline formula is wider than the container, MathJax will break it, but it is in a box of its own, and in HTML-CSS output, that box is only as wide as the broken math rather than as wide as the whole container. If you switch to CommonHTML output (which is faster and less fragile), that should work better for you.

The issue was fixed in a later version of v2, though I don't remember which. In version 2.7.9 (the highest v2 version) HTML-CSS works like CommonHTML, making the box as wide as the container. That puts the broken inline math on lines separate from the preceding and following text, which is better but not idea. The in-line breaking in v4 is much better, and would put the first part of the math at the end of the same line with the preceding text, and the remainder of the math at the beginning of the next line of text, as you would expect.

When v4 is released, I expect StackExchange will move to that, though it may still be opt-in for the initial testing.

dpvc commented 1 week ago

I'm marking as "expected behavior", as that is how MathJax works in v2, and that is not likely to change.