Posted by suioir 6 days ago
https://docs.getoutline.com/s/guide/doc/formatting-kn6wBtxlQ...
What a boldly incorrect comment! It's like you didn't even read the first point in TFA!
Quoting the relevant part from that link:
  katex.min.css              23.6 kB
  katex.min.js              277.0 kB
  auto-render.min.js          3.7 kB
  KaTeX_Main-Regular.woff2   26.5 kB
  KaTeX_Main-Italic.woff2    16.7 kB
  ----------------------------------
  Total Additional          347.5 kB
Of course, if the page uses more symbols in various sizes, then a few more fonts files (.woff2) need to be pulled in which case the weight of KaTeX would increase a bit too.  Each font file weighs between 4 kB and 28 kB.Most critique of KaTeX over MathJax is reduced support for LaTeX features.
You can do this server side or client side and sadly too many people do it client side. If you do it server side, it is just one more step in your build next to transpiling and bundling.
The key issue is that the latex stack wasn't really designed to be packaged up like this. It just has a lot of moving parts that are vaguely dependent on running in a full blown unix like shell environment. So the resulting code would be a rather big blob. Running that in a browser isn't that hard if you can live with that having a fair bit of overhead. This has been done. But it's a bit overkill for publishing content on the web.
Browsers don't have native support for MathML any more for a good reason. Mozilla did support this for a while but dropped it because of limited adoption and high maintenance burden. Rendering formulas is a bit of a niche problem and the intended audience is just kind of picky when it comes to technology and generally not that into doing more advanced things with web browsers. Also, most people writing scientific articles would be writing those for publication and probably use Latex any way. So translating all their formulas to MathML is an extra step that they don't need or want.
At least that's my analysis of this. I'm not really part of the target audience here and I'm sure there are plenty of MathML fans who disagree with this.
In any case Katex makes an acceptable (to some) compromise by packaging this stuff up in a form where it can be run server side and is easy to integrate on a simple web page. A proper solution with buy-in from the scientific community (for e.g. MathML) is a much bigger/harder thing to solve.
IMHO, a light weight solution based on web assembly could be the way to go. But of course the devil is in the details because if the requirements are "do whatever latex does" it gets quite hard. And anything else might be too limited.
This seems to just be entirely untrue? https://developer.mozilla.org/en-US/docs/Web/MathML shows wide support (For Chromium/Blink-based since version 109) and if I open the example https://developer.mozilla.org/en-US/docs/Web/MathML/Guides/P... in Firefox and Edge both seem to render it correctly.
The big issue is that MathML is designed as a target language, not something directly writable. So we still need a KaTeX equivalent, which compiles either LaTeX equations or other markup languages to MathML.
Regardless, the core issue that you have mentioned is now gone (or will be in a few years even if you want more availability).
My point is that "fast" in those kinds of workarounds wouldn't be a problem for visitors of a site because all the browser gets is just native MathML.
Even if we address this problem using custom web fonts, there are numerous other edge cases (spacing within subscripts and superscripts, sizing within subscripts within subscripts, etc.) that look odd in MathML. At that point, we might as well use full KaTeX. Granted, many of these issues are minor. If they don't bother you, MathML could be a good alternative. Unfortunately, for me, these inconsistencies do bother me, so I've been using MathJax, and more recently KaTeX, since they get you closer to the typesetting quality of LaTeX compared to MathML.
Indeed! That was precisely the point of my previous comment.
I agree that switching to Latin Modern resolves some of the minor issues I mentioned earlier. However, it does not resolve all of them. In particular, it does not address the spacing concerns I mentioned earlier. For example compare the following on <https://mk12.github.io/web-math-demo/> with Latin Modern selected:
  \sum_{q \le x/d}
Or:  \sum_{d \le \sqrt{x}}
The difference in spacing is really small but it is noticeable enough to bother me. Also, this is just one of several examples where I wasn't happy with the spacing decisions in MathML rendering.  The more time I spent with MathML, the more such minor annoyances I found. Since KaTeX produces the spacing and rendering quality I am happy with, out of the box, I have continued using it.Also, my goal isn't to replicate LaTeX's spacing behaviour faithfully. I just want the rendered formulas to look good, close to what I find in print or LaTeX output, even if it's a bit different. It so happens that I find myself often bothered by some of the spacing decisions in edge cases when using MathML, so I tend to just stick with MathJax or KaTeX.
But that's just me. All of this may seem like nitpicking (and it certainly is) but when I'm spending my leisure time maintaining my personal website and blog or archiving my mathematics notes, I want the pages to look good to me first, while still looking good to others. If MathML output looks good to others with certain fonts, that's a perfectly valid reason to use it.