Join the discussion

Write your take first — we'll ask for email only when you're ready to publish.

  • Hacker News
  • A commenter left this on another HN post [0] and I thought it was worth its own.

    [0] https://news.ycombinator.com/item?id=45701400

  • The commenter says pre-rendered/server-side-rendered mathematics (via katex) is great - I’ve found the opposite. It’s probably great if you have an article with one or two equations. On the other hand, if you have an article which uses mathematics pervasively, like many pure mathematics articles, it quickly becomes far more space efficient to render the mathematics on the client side. You can quickly get 200kB+ pages by pre-rendering.
  • KaTeX has always seemed pretty inferior to me compared with MathJax. The most significant flaw is that it is very unstable, frequently failing at rendering rendering large documents with many equations. This happens across several applications, though I suppose it could be machine-specific. It also doesn't support several basic packages that MathJax supports. Without measuring the speed difference, I've never noticed a gap anyways.
  • Outline (https://www.getoutline.com) includes the KaTeX renderer in it's documents if you're interested in trying a knowledge base that has great direct support.

    https://docs.getoutline.com/s/guide/doc/formatting-kn6wBtxlQ...

  • I use KaTeX for my blog, and indeed KaTeX was faster than MathJax 2, but MathJax 3 (a complete rewrite) has significantly improved performance from the previous version and is now a bit faster than KaTeX in my experience.

    This website has a comparison of the loading times of the same LaTeX rendered in both KaTeX and MathJax: https://www.intmath.com/cg5/katex-mathjax-comparison.php

    by s20n
  • So if speed is comparable, which is best?
  • "Page complete" never stops with either library for me. It just keeps counting milliseconds. Chrome on Windows, no change when I disabled uBlock Origin Lite.
    by mkl
  • It is amusing that, in my particular environment, KaTeX is slower than MathJax 3 in processing time but actually faster when font loading time is accounted for. Both loads from your domain so there should be no routing issue; KaTeX fonts turned out to be substantially smaller than MathJax 3 at least in this particular case. Is this intentional or just a lucky coincidence for KaTeX? (KaTeX is also ~70% smaller than MathJax 3 in their gzipped forms, so it might well be intentional!)
  • I am curious, if there is any library for inline formula like KaTeX, but supporting Typst syntax?
  • I would assume you pretty much get that out of the box given Typst compiles to HTML natively?
  • I wrote a library with a syntax similar to Typst (actually inspired by AsciiMath; and predates Typst by about a decade). Then there are Markdown-It plugins around it.

    https://mathup.xyz/

    https://github.com/runarberg/markdown-it-math

  • It may or may not be as fast, but MathJax has broader support for LaTeX features, better accessibility features, and has slightly better typography in my very subjective opinion, and that's more important to me than a bit of rendering time.
  • I wish there was a native version of this. Every SSG seems to have the problem of having to depend on node in order to prerender html for math with katex.
  • Port it? Or maybe bundle a tiny interpreter instead of Node.
  • I use it in my static site generator in Python via https://github.com/rubenvannieuwpoort/PyKaTeX.

    Disclaimer: I am the author of PyKaTeX.

  • If your use case is generating html, MathML is supported in all modern browsers: https://developer.mozilla.org/en-US/docs/Web/MathML#browser_...
  • Hugo includes native KaTeX: https://gohugo.io/functions/transform/tomath/

    The docs recommend setting up KaTeX CSS (which requires either a CDN link or Node), but by changing output to 'mathml,' you can have the browser render equations with zero dependencies.

  • I've been using katex-rs, a Rust rewrite, to implement LaTeX rendering for a Rust web app. It was easy enough to hook into pulldown_cmark, so that $ and $$ and render a decent subset of LaTeX. Since pulldown_cmark is a proper Markdown parser, you listen for Event::InlineMath and Event::DisplayMath then call KaTeX directly. No regex or HTML escaping necessary. In my web app, this is all encapsulated into a single function that I can call within Tera templates. It's as SSR as it gets; no Node.js or client-side JavaScript necessary.

    The costliest asset is a minified stylesheet served through a CDN. (I do this out of laziness, and because the web app as-is needs nothing more than the standard Rust toolchain).

    https://github.com/katex-rs/katex-rs

  • Also see Temml, a fork of KaTeX that compiles to MathML instead of styled HTML.

    https://temml.org/

  • I think the latest version of MathJax (v4) has rendering speed comparable to, if not faster than, KaTeX. It also looks (subjectively) significantly better than KaTeX, and supports a wide array of accessibility features.
  • MathJax does not even let you select text, so it seems less accessible to me.
  • As a very much work-in-progress, yesterday, I started working on interactive equations https://p.migdal.pl/equations-explained-colorfully/ (it uses KaTeX under the hood).

    The idea is similar to https://betterexplained.com/articles/colorized-math-equation..., but with mouseover interaction (both for further description, but also for accessibility). For a deeper dive in the topic of explorable explanations, I wrote https://p.migdal.pl/blog/2024/05/science-games-explorable-ex... (was here on the HN as well).

  • This is really awesome! I've been really interested in creating an interactive introduction to basic algebra where parts of the equation can be manipulated using drag-and-drop, but I couldn't really figure out the best way to do it. Maybe using Katex is the way to go?
  • I switched from MathJax to KaTeX earlier this year for my blog. So far, it has been working out well.

    The only feature I really missed was the ability to use \label and \eqref for equation referencing, since KaTeX doesn't support these commands [1]. I worked around this limitation with a small custom setup defining my own \label and a custom \eqnref (not exactly \eqref though) [2].

    Another thing that bothered me a little was that the KaTeX autorender extension does not recognise \begin{align*}, \begin{alignat*}, etc. as top-level delimiters by default [3] but this was trivial to fix by customising the set of default delimiters [2].

    I know KaTeX supports server-side rendering but I don't use that yet [4]. I still use client-side rendering. Despite that my maths pages [5][6] render quickly since they are usually small, with only a single reflow from the initial load to the rendered page, without the continual reflows or jitter I used to see with MathJax. Overall, I am quite happy with the switch from MathJax to KaTeX.

    [1] https://katex.org/docs/supported.html

    [2] https://github.com/susam/susam.net/blob/0.3.0/layout/include...

    [3] https://katex.org/docs/autorender#api

    [4] https://news.ycombinator.com/item?id=44615271

    [5] https://susam.net/mutually-attacking-knights.html

    [6] https://susam.net/zigzag-number-spiral.html

  • I’ve never been able to switch since the feature set, whenever I’ve looked over the years, doesn’t seem geared toward serious mathematical exposition. I think I want to carry over habits from papers to blog pages though, which perhaps is misguided.
  • Does anyone know why Google doesn’t adopt something like this in Google Docs / Slides? It’s amazing to me that after all these years Google Docs still has some of the worst equation editing of all word processors. I was hopeful when they added markdown support that first class equation editing was near, but it’s been a while now and still nothing.
  • If only they'd added it in the first iteration when they had a free hand.
  • This is very obnoxious when transferring documents from Gemini to google docs (and not just math, tables/code sections are often not transferred correctly as well).

    I have a javascript hack from the dev console where I can at least print the chat to PDF, https://andrewpwheeler.com/2025/08/28/deep-research-and-open... (that at least worked 2 months ago)

  • Speculation: Google has a moderate amount of “core” applications that are clearly getting indefinite support, but all of those services also have a very conservative feature and update roadmap. New features are going to be limited to things that alphabet has in its global focus, so crap like Gemini and not much else.

    I’m sure engineers working on products like the google web suite would love to implement this kind of thing but have zero authorization or resources for that.

    Experimental applications, the ones that bloom rapidly and get shut down in a cycle that google has become known for, are ironically way more likely to see this kind of cool niche update.

    Twisted company has a whacky way of managing their products, because advertisement drives their revenue so everything else is just freestyle jazz.