# Which Latex / MathJax features do we need or want to have supported on the site?

As we've started discussing, Stack Exchange is planning to redo the editor for all questions and answers across all their sites. As articulated by Emilio Pisanty, these changes will have significant implications for MathJax.

In the initial discussion, I thought the possibility that these implications might even include not fully supporting MathJax seemed like a worst-case scenario, which we would only even mention to confirm that everyone agreed it was not a real option. But it now seems that among the options Stack Exchange has suggested so far, the most reasonable one would entail exactly that, as it would involve switching to some different Latex-like framework.

If we go down that road, then we're going to have to get even more involved with things: we will need to think about which Latex / MathJax features we need to have supported on the site. Because if you leave it to the developers to decide which Latex features are worth supporting, then you end up with something like the Microsoft Equation Editor, a sort of caricature of what it means to support mathematical typesetting.

Though this would be a large task, it also presents an opportunity. If we were to switch away from MathJax, whatever new solution replaces it might be an improvement in certain respects.

So perhaps I'm jumping the gun, but I think it may be worth getting started on this task. We're still in the early stages, so there's no way we will come to a definitive or comprehensive answer right now, but we may start to get some ideas. Up to now, I've never had to dialog with a non-mathematician about what I need in Latex, so I'm not really sure what their preconceptions are about what we need. Some things I might guess they don't anticipate include user-defined macros and commutative diagrams, but there are probably much more basic things they'll need to have explained. On the flip side, my impressions of what they will find difficult or easy to implement are just as ill-informed as their impressions of what we will need. So the question is:

Question: Which Latex features are important to have supported on this site? Which ones, if not strictly necessary, would be very nice to have supported?

It's worth considering both features which are currently supported by MathJax, and ones which are not.

• I'd like this question to be CW, but I'm realizing that it's been years since I converted a question rather than an answer to CW and I don't see how to do it. Is it something that stopped being supported at some point? I'm also not familiar enough with the meta tags to do them justice. – Tim Campion Feb 1 at 18:37
• This feels premature to me at this stage. If the devs do want to switch the backend then this will definitely need to be done, but it's a lot of community work so I'd say let's do that only if it's clear that it's required. – Emilio Pisanty Feb 1 at 18:44
• On a more strategic level, it feels to me that a more effective strategy is to look at the proposed backend (be it KaTeX or anything else), find what its differences are with MathJax, and look for where they overlap with existing posts, and then work from there. But then again you're right that this might not be assertive enough, if non-back-compatible options are on the table. – Emilio Pisanty Feb 1 at 18:46
• @EmilioPisanty You may well be right. For me, commutative diagram support is an essential requirement which I'm certain will need to be explicitly explained to the developers. But I don't want to go around saying "the main thing to look for in a new Latex-like framework is commutative diagram support" before soliciting input from others who may well have specific needs that are just as clear. For example, on the internet I generally don't really use many user-defined macros, but I know that some folks do. Do they find them essential, or just convenient? I don't know. – Tim Campion Feb 1 at 18:57
• This reminded me of an older discussion (about MathJax) on Mathematics Meta: Poll for MathJax macros that should be automatically loaded. – Martin Sleziak Feb 1 at 19:01
• Whatever is suggested, I would like to make sure we absolutely veto the (old?) Wikipedia-style images of rendered equations/expressions. Also, the oft-used WP hack of formatted text as a stand-in for variables (just putting it in italics is not enough!) – theHigherGeometer Feb 2 at 6:53
• Better diagram support would be nice, since AMScd doesn't really do non-diagonal arrows. I don't know what to suggest in its place that SE would actually consider, though. – theHigherGeometer Feb 2 at 6:55
• Since @DavidRoberts mentioned commutative diagrams, I'll add links to some previous discussions on this meta: Diagrams in MathJax via xypic.js, Is it possible to use tikzcd code in MO posts?, Triangle commutative diagram does not work here at MO. Commutative diagrams were mentioned also here: Big list of feature requests and suggestions for a fantasy MO 3.0. – Martin Sleziak Feb 2 at 8:03
• Perhaps its worth pointing out that SE views these changes as a chance to make things better. It's probably counterproductive not to at least try to get on board with their optimism. So maybe we should also put more emphasis on thinking about what Latex features are not supported by MathJax, but would be nice to add. Coming back to commutative diagrams, as others have also pointed out there's significant room for improvement. – Tim Campion Feb 2 at 14:14
• It occurs to me that someone who knows how to do some basic scripting should be able to download the last few years of MO and extract some statistics on which LaTeX features are used how often. This would probably be more useful than asking individual people's opinion. – David E Speyer Feb 3 at 15:05
• @DavidESpeyer I'll add that the data dumps (in form of an xml-file) of Stack Exchange sites - including MO - are publicly available: archive.org/details/stackexchange (I think they are updated quarterly.) So if somebody wants to analyze data, they can be obtained from there. – Martin Sleziak Feb 3 at 17:41
• @DavidESpeyer And, of course, one could also use SEDE or built-in-search. I have tried to expand on this a bit in the MathOverflow chatroom. – Martin Sleziak Feb 4 at 6:53
• As a non-programmer, how is something like backwards compatibility implemented (or is it not?). Presumably any huge overhaul like this will wreak havoc on old posts, no matter how careful the translation from one system to another is done. Is it inevitable that we would be spending years finding incompatibilities in the future and having to fix them by hand? – Dan Rust Feb 4 at 17:30
• @DanRust In my opinion, it's a bit premature to expect that some changes similar the ones described in the question are actually going to happen. Let's wait and see whether something like that is actually confirmed. OTOH, the MathOverflow community does not seem to be that bothered about rendering old posts - at least, there was no reaction when I brought up some broken posts here: Problem with posts and comments relying on macros defined elsewhere. – Martin Sleziak Feb 4 at 20:40
• @DavidESpeyer Although there is a bit of difference (you asked about LaTeX features and this is about commands used in the post), but still, the SEDE query posted by Glorfindel on Mathematics Meta might be of interest in connection with your inquiry: What Mathjax commands are most often used on this site? – Martin Sleziak Feb 23 at 14:37

This is not an answer expressing a preference, but one giving some resources for people to consider.

• Intmath.com made a Speed Comparison Test between KaTeX and MathJax. MathOverflow is currently running MathJax 2.7.5; the new version that is MathJax 3 runs significantly faster. KaTeX does run even faster still.

• There are some breaking changes between MathJax 2.7 and MathJax 3. Though I don't think they are major enough to prevent us from upgrading.

• MathJax 3 is fairly easy to install, and if you use the autoload extension you (meaning StackExchange) don't need to configure precisely the list of extensions to be loaded.

• The list of all supported macros: MathJax 3; KaTeX. As you can see the two are pretty close to feature parity; there are some odd commands here and there that KaTeX doesn't support. The most prominent difference that may be important for MathOverflow is the support for commutative diagrams. MathJax supports amscd style diagrams which has no counterpart in KaTeX.

• Strange that mbox is missing. Since they have textrm, it wouldn't be such a big deal in the future, but mbox is a little nicer and is what I usually use. – David E Speyer Feb 3 at 22:10
• MathJax3 handles configuration options in a significantly different way from MathJax2.7, and the mechanism for reprocessing content that has changed is also different. This causes pain in contexts where MathJax is embedded in some other large framework. That applies to Moodle, for example. I don't know whether it applies to the StackExchange framework. – Neil Strickland Feb 3 at 22:56
• @DavidESpeyer: This is off-topic, but let me mention that for setting part of an equation in 'text' font, one should typically use \text{}, \textrm{}, \mathrm{} or AMS \OperatorName{} rather than \mbox{}. See this answer on TeX.SE for a detailed discussion. – Mateusz Kwaśnicki Feb 4 at 9:03
• The usual thing I am using these commands for is things like $\{ n : n \ \mbox{squarefree and divisible by at least$3$primes} \}$, where I want to use normal text mode spacing inside the box. – David E Speyer Feb 4 at 12:13
• Or $(1+1/n)^n = \exp(n (1+1/n-1/(2n^2) + (\mbox{lower order terms})))$. – David E Speyer Feb 4 at 12:16
• Looks like I might just want \text, I'll play with that. – David E Speyer Feb 4 at 12:26
• @DavidESpeyer afaik you may put any kind of TeX code inside \text – მამუკა ჯიბლაძე Feb 9 at 19:37
• As for amscd, this is something that has been added do KaTeX recently, I don't know when it will be officially released but it works on this preview page: deploy-preview-2396--katex.netlify.app – Sil Feb 12 at 19:32
• Also one of the breaking changes for switching to MathJax 3 was line breaking which is still not supported there... that should be critical to SE sites, see Davide Cervone's comments here math.meta.stackexchange.com/questions/30901/… – Sil Feb 12 at 19:38

Need:

• Most importantly, a true preview which shows me exactly what I have written and which I can look at without affecting my LaTeX.

• Support for at least the symbols in standard LaTeX and amssymb (including amsfonts).

• At least one of array or matrix.

• Both inline and displayed math.

Currently have and very much want:

• Simple user defined macros. (I'm not saying they need to implement the full Turing complete LaTeX macro language, just that I should be able to write $\def\RR{\mathbb{R}}$ and then have $\RR$ turn into $$\mathbb{R}$$.)

• array, matrix, bmatrix, pmatrix and smallmatrix.

• cases

• overbrace and underbrace

• mbox

Would be nice

• xymatrix

• tikz

• My impression is that tikz is super-complicated. When you say it would be nice, how much of that power do you have in mind? Is it mostly tikzcd stuff? (I don't know if that would make a difference.) – Tim Campion Feb 3 at 17:46
• I don't think I know enough about tikz to answer this. I generally use it when xymatrix won't do the job, so I am already filtering for hard cases. – David E Speyer Feb 3 at 17:53
• Yeah, I suppose the reason that tikzcd is more powerful than xymatrix to begin with is probably closely tied up with the fact that there's this huge infrastructure behind it. But at least it sounds like you'd want it primarily for commutative diagrams rather than drawing pictures. – Tim Campion Feb 3 at 17:57
• cases is also rather important, I guess. Also underbrace. – Martin Rubey Feb 3 at 19:13
• I wonder if I should have made each response a separate answer so votes could be more meaningful. Martin Rubey's are all things I would put in the middle category; I'll add them. – David E Speyer Feb 3 at 21:54
• One interesting missing item here is \begin{align}. If nothing else, there's ~4k posts with it on MO. – Emilio Pisanty Feb 4 at 0:05
• @EmilioPisanty I considered adding that, since it is an obvious companion to matrix and array, but I almost never use it myself. I think what this is showing is that the answer format I chose isn't really a good one. – David E Speyer Feb 4 at 2:09
• Davide Cervone left a comment concerning diagonal arrows, xypic, MathML in a discussion on Mathematics Meta. (Although that was back in 2013.) – Martin Sleziak Feb 4 at 11:55
• Implementing Tikz in Mathjax looks like a programmer's worst dream. That package contains everything but the kitchen sink. – Federico Poloni Feb 14 at 18:42

Personally I have never used anything very complicated. I use inline maths, displayed equations and aligned sets of equations, sometimes with matrices. I can't remember whether I have ever used fancier aspects of the array environment, but it's not hard to imagine doing so. Sometimes I use commutative diagrams, but the current arrangements for that are poor. I have never used macros on MathOverflow, but perhaps I should have done.

I have not investigated KaTeX's claim to be faster than MathJax, but that would be somewhat beneficial if it were true.

Sorry if this is not interest of you. I don't know whether it is possible or not but I'd like MathJax have autocomplete feature like tex editors for common commands. e.g. \over---> \overline or \overbrace etc.

This is not so bad but text mode inside math mode is a bit deferent from main text that I think it should be like main text as $$\LaTeX$$ is. e.g. $$a^2+b^2=c^2\quad \text{this text is bold and RomanMath} \quad \sqrt{a^2+b^2}=c.$$

• This seem more like a feature of a specific editor than a feature of MathJax. Perhaps it is worth mentioning that Overleaf has some kind of autocompletion. (You reminded me of this post on Mathematics Meta: Some suggestion for MathJax. The post is now deleted - so 10k+ link.) – Martin Sleziak Mar 17 at 23:12
• This question does not ask for a list of feature requests for MathJax, but for a list of nontrvivial features already implemented in MathJax that are used often enough so that we need them preserved in the event that MathJax is replaced with a different TeX renderer. – Emil Jeřábek Mar 18 at 7:46