12
$\begingroup$

It seems we are using MathJax version 2.7.5 That is apparently 4 years out of date. Can Math.se update the MathJax it uses? Or do we have to wait for the whole SE system to do it?

$\endgroup$
10
  • 3
    $\begingroup$ See also switch to mathjax version 3. $\endgroup$ Nov 28, 2022 at 16:26
  • 3
    $\begingroup$ Yes, MathJax V2.7.5 is four years old but it's still the most recent V2 version of MathJax. It would definitely be great to see StackExchange move to V3, which is much faster and has a more modern API. I don't think it's a trivial task, though. $\endgroup$ Nov 28, 2022 at 22:00
  • 2
    $\begingroup$ @MarkMcClure The latest version in the 2.7 series is 2.7.9 according to MathJax's GitHub release page, though. $\endgroup$ Nov 29, 2022 at 1:46
  • 6
    $\begingroup$ 1. One of the reasons held back the migration to v3, IIRC, was that v3 doesn't support line-breaking. 2. MathJax v4 is in the alpha stage now (see MathJax's release page), which adds back line-breaking function and even comes with inline line-breaking, so it might be better to wait for the final release of v4 instead of migrating to v3 now. $\endgroup$ Nov 29, 2022 at 1:50
  • 2
    $\begingroup$ An alternative to updating MathJax is to use TeXZilla to convert TeX input to MathML output and to utilize browsers' native rendering. Firefox and Safari have been supported MathML for a long time, and Chrome has added (back) MathML support since 106. $\endgroup$ Nov 29, 2022 at 1:59
  • 1
    $\begingroup$ if this is about v2/v3/v4, I agree with Ѕᴀᴀᴅ; @XanderHenderson, V4.0 fingers-crossed comes out early 2023, as per this comment from MathJax dev Davide Cervone $\endgroup$ Nov 29, 2022 at 3:20
  • 2
    $\begingroup$ @CalvinKhor I am not sure why you pinged me---I only marked the post as status-review in order to make the SE developers aware of it. I don't have a stance on the issue, one way or another. $\endgroup$
    – Xander Henderson Mod
    Nov 29, 2022 at 15:36
  • 2
    $\begingroup$ @XanderHenderson Oh, I just thought it would be better to wait. I suppose SE themselves can make that decision though. $\endgroup$ Nov 30, 2022 at 8:12
  • $\begingroup$ For what it's worth, I consider the ability to use <br> to be very helpful. Further, if there is a substitute MathJax mechanism that some users employ, where these users might not know about <br>, then I don't think it is a good idea to lose a MathJax oriented line breaking mechanism. Also, although I have never employed it, a MathJax oriented line breaking mechanism does allow someone to format a single $...$ paragraph, rather than separate $...$ lines. $\endgroup$ Dec 5, 2022 at 9:02
  • 1
    $\begingroup$ Related post on MSE: Are there plans to switch to the current version of MathJax? $\endgroup$
    – V2Blast
    Jan 19, 2023 at 19:33

1 Answer 1

14
$\begingroup$

I was asked to comment on this question, so here is some information on the various MathJax versions and some issues StackExchange might want to think about.

One of the reasons that SE hasn't upgraded to version 3 is that it didn't include the automatic line-breaking support that is part of v2, as it plays an important role for many posts, particularly on mobile devices. Line breaking is included in v4, as @SAAD points out, so waiting for that is reasonable (it should be released in early 2023). He also mentioned that v4 includes in-line breaking, which is lacking in v2; it also has better breaking in tables, and included the ability to break text at whitespace. There are a number of new macros to help control line breaking, and support for more array preamble types for handling fix-width columns with line-breaking. See the v4.0-alpha release notes for more details of the changes.

Another important feature of v3 is that MathJax now has a lazy-typesetting extension where MathJax will typeset only the expressions that are in view, and will typeset others as they scroll into view. That will provide a significant speed improvement on pages that have many equations.

So there are many reasons to consider version 3 (or the upcoming v4). But I suspect the real reason SE hasn't updated to v3 is that the v3/v4 API is different from the v2 API, and that will require changes to the SE code that calls MathJax. That will affect how MathJax is loaded and configured, and how it is called from the javascript on the page. This will have a particular impact on the editor preview code that processes MathJax in the preview. This is a non-trivial change, and is not just a drop-in replacement. I wrote the original code used to update the math in the previews, and would be happy to work with SE on updating that code for v3/v4, but I no longer have contacts in the development team, so don't know how to make the offer. (SE was once a MathJax supporter, but they dropped that some time ago.)

Because these changes are significant, and would require careful development and testing, both of which take time, I would recommend starting the process now with v3 (the v4 API is substantially the same as v3), so that when v4 is out, SE will be ready to go.

As for version 2.7.5, SAAD is correct that the current v2 release is v2.7.9 (two years old), and updating to that would require no changes to the code, so that could be done quickly and easily. But most of the new features would require the more substantial update to v3/v4.


SAAD also suggested moving to something like TeXZilla. There are a number of issues to keep in mind when considering such a change. First, while native MathML support is coming for the Blink engine used in Chrome and modern versions of Edge, my understanding is that this is "MathML core", which is a limited version of MathML, and so may not be able to support all the needed features; for example, equation numbers use the <mlabeledtr>, which does not appear to be part of MathML core.

Since mathematical layout, even through native MathML, requires specialized fonts, and I'm not sure how that is being handled in the browsers theses days. Originally, Firefox required a separate font download and install, but they may come with the browser now. I'm not sure how that works on mobile devices. Variants such as double-stuck, Fraktur, script, calligraphic, etc., may not be available to all readers. Calligraphic presents a special problem in that MathML3 did not include a variant for calligraphic as separate from script, and unicode doesn't include a location for math calligraphic letters, so there is no natural way to handle \mathcal and \mathscr separately in MathML. Some fonts do include both versions, but the method of accessing them depends on the font.

Some people may also find the quality of the output to be unacceptable in some browsers. For example, Safari's (i.e., WebKit's) MathML support traditionally has been less effective than Firefox's, and I don't know if they are planning to port over the changes from Blink back to WebKit.

I don't think the native MathML implementations have the equivalent of MathJax's contextual menu (for viewing the TeX or MathML source, for example), and there is no natural way to get SVG output. Also, MathJax's expression explorer would not be available for generating speech text for screen readers. I don't think any current native MathML implementation does automatic line breaking (but I haven't looked recently, so I may not be up on their latest developments).

As for changing the TeX engine used by SE from MathJax to something else, one has to keep in mind the set of commands that are available in both programs. I am not very familiar with TeXZilla, but trying some tests on their interactive page suggests that there are important commands that are not implemented. For example, it doesn't seem to process \begin{align}...\end{align}, which will be problematic for this community. Also, \mathcal{C} and \mathscr{C} both produce the same character (though it is a different one in Firefox than in Safari). It doesn't seem to support \newcommand or a number of other common features, and there doesn't seem to be a list of the available commands.

MathJax also implements some non-standard macros, like \unicode, and \style, which are used on SE, but won't be available with TeXZilla. So switching could break a lot of existing posts, and substantial clean-up would be required.

Finally, TeXZilla doesn't seem to have been updated since 2019, so it does not seem to be currently maintained.


These are just some things to keep in mind as you consider potential updates to MathJax.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .