or
Meta decision-problem parsing
Jack Douglas
We've got MathJax (sort of) working on Code Golf, but I hadn't quite anticipated what a huge and complex library it is.

We can stick with it, but if something simpler like KaTeX would suit just as well or very nearly as well, we should probably use that instead. I have no idea whether it would though, but presumably you do!

---

* Update 26 Jan 2020: we have swapped out MathJax for KaTeX
* Update 28 Jan 2020: upgrading the KaTeX library to the latest release has fixed some of the issues [pointed out by](/codegolf?q=621#a691) @Bubbler
I had a look at KaTeX and I'm convinced that it is *plenty* powerful for our needs. The improved rendering speed is nice too.
Bubbler
I tried out some math expressions from my own SE posts. It looks like ~~some of the features are not correctly working,~~ and some are visually not pleasing to read.

* ~~\begin{gathered} ... \end{gathered} isn't working~~ (using aligned instead makes all lines aligned to the right.)

$$\begin{gathered} \text{byte count before zilde} + \text{byte count of single zilde} \times \text{length of zilde chain} \\ = 52 + 3 \times (72x^{12} + 101x^{11} + 108x^{10} + 108x^9 + 111x^8 + \\ 44x^7 + 32x^6 + 87x^5 + 111x^4 + 114x^3 + 108x^2 + 100x + 33) \end{gathered}$$

\begin{aligned} \text{byte count before zilde} + \text{byte count of single zilde} \times \text{length of zilde chain} \\ = 52 + 3 \times (72x^{12} + 101x^{11} + 108x^{10} + 108x^9 + 111x^8 + \\ 44x^7 + 32x^6 + 87x^5 + 111x^4 + 114x^3 + 108x^2 + 100x + 33) \end{aligned}

* Using lots of fractions/binomials inside a container (cases or matrix) makes them look cramped. **Edit:** Changed \tfrac and \tbinom to plain \frac and \binom. Looks like they're now correctly rendered small inside containers, but the cramped issue is still there.

\begin{aligned} X & = \text{uniform random value in } (0,1) \\ Y & = \begin{cases} X + \frac12, \quad X < \frac12 \\ X - \frac12, \quad X \geq \frac12 \end{cases} \\ Z & = \frac32 - (X + Y) \end{aligned}

$$\begin{bmatrix} \binom{1}{1} & \binom{1}{2} & \cdots & \binom{1}{n+m} \\ \binom{2}{1} & \binom{2}{2} & \cdots & \binom{2}{n+m} \\ \vdots & \vdots & \ddots & \vdots \\ \binom{n+m}{1} & \binom{n+m}{2} & \cdots & \binom{n+m}{n+m} \end{bmatrix} \begin{bmatrix} a_1 \\ a_2 \\ \vdots \\ a_{n+m} \end{bmatrix} = \begin{bmatrix} \binom{1}{n} \binom{1}{m} \\ \binom{2}{n} \binom{2}{m} \\ \vdots \\ \binom{n+m}{n} \binom{n+m}{m} \end{bmatrix} \Leftrightarrow Ba = v$$

**Edit:** The KaTeX [Commen Issues](https://katex.org/docs/issues.html) page says:

> When displaying fractions one above another in these vertical layouts there may not be enough space between rows for people who are used to MathJax's rendering.

Their recommended solution is:

> The distance between rows can be adjusted by using \\[0.1em] instead of the standard line separator distance.

The math below uses \\[0.2em] instead to emphasise the difference:

$$\begin{bmatrix} \binom{1}{1} & \binom{1}{2} & \cdots & \binom{1}{n+m} \\[0.2em] \binom{2}{1} & \binom{2}{2} & \cdots & \binom{2}{n+m} \\[0.2em] \vdots & \vdots & \ddots & \vdots \\[0.2em] \binom{n+m}{1} & \binom{n+m}{2} & \cdots & \binom{n+m}{n+m} \end{bmatrix} \begin{bmatrix} a_1 \\ a_2 \\ \vdots \\ a_{n+m} \end{bmatrix} = \begin{bmatrix} \binom{1}{n} \binom{1}{m} \\[0.2em] \binom{2}{n} \binom{2}{m} \\[0.2em] \vdots \\ \binom{n+m}{n} \binom{n+m}{m} \end{bmatrix} \Leftrightarrow Ba = v$$

* ~~\implies symbol isn't working.~~

$$M = \begin{pmatrix} a & b \\ c & d \end{pmatrix} \implies S^{-1}M = \begin{pmatrix} c & d \\ -a & -b \end{pmatrix}, T^{-1}M = \begin{pmatrix} a-c & b-d \\ c & d \end{pmatrix}$$

$$M = \begin{pmatrix} a & b \\ c & d \end{pmatrix} \Rightarrow S^{-1}M = \begin{pmatrix} c & d \\ -a & -b \end{pmatrix}, T^{-1}M = \begin{pmatrix} a-c & b-d \\ c & d \end{pmatrix}$$
MathJax or KaTeX?
Jack Douglas replying to Bubbler
very useful, thanks — work's correctly on FireFox but we have repro'd on Chrome and are looking into it!
Bubbler replying to Jack Douglas
It did happen to me on desktop. I use Chrome on Windows.
Jack Douglas replying to xnor
Am I right you are on mobile? I get that on my iPhone SE but not on desktop. cc @Bubbler
Bubbler replying to xnor
It's more like the entire screen showing with offset in y direction. I experienced it several times - when I asked a new question and edited a post. (Don't remember which one though.) The offsets also seemed to be random. cc @Jack
xnor
When I click on an answer to this question from the question page, the header containing the site dropdown doesn't appear, even if I scroll back up to the top. This doesn't seem to happen with other questions.
Bubbler replying to Jack Douglas
Great :)
Jack Douglas replying to Bubbler
I found some reference to this issue on the KaTeX site and updated the answer here.
Bubbler replying to Jack Douglas
Maybe open an issue on the KaTeX repo?
Jack Douglas
@Bubbler I think we have fixed 2 out of 3 of those issues by switching to the newest KaTeX release. Not yet sure what to do about the cramped matrices