Live data from Hacker News

KaTeX: Math typesetting for the web

khan.github.io

21–30 of 101 posts

Re: KaTeX: Math typesetting for the web

#21

Heavy mathjax user here. Couple of use cases I'd love to know more about: - does KaTeX work pretty reasonably across the platforms? The simplest way I figured out for rendering math notation in-app on mobile devices was through web views + mathjax. E.g. say I wanted to use it in a web view in iOS or Android, would it work as intended? MathJax comes by default with a giant folder of various fonts / ways of rendering,…

We try to test in lots of different environments, so it should work reasonably in most environments. To get the speed we wanted, we had to ditch much older browsers (we don't support IE 7 and earlier), and we only render to HTML/CSS, not things like MathML. However, we're so far very happy with the look of the math in the environments we've tested.

KaTeX works great in a headless environment. You can even do server side rendering if you want a browserless environment which can serve up straight HTML with no JS.

Both KaTeX and MathJax's biggest slowdown is the font loading. However, since KaTeX's CSS can be included manually (instead of letting MathJax put it in the DOM after load) it should load a little faster.

Also, looks like your use cases are similar to ours at Khan Academy! We've been struggling with MathJax on slow computers and iPads for a while, which is why we made this. Let me know if you want more info!

Re: KaTeX: Math typesetting for the web

#22
Props to the coders for improving upon the LaTeX/Web use case space, but I can't help but feel something other than LaTeX is going to be necessary for the internet. LaTeX was fundamentally about document-level typesetting, and the internet is fundamentally not a place where that happens.

Re: KaTeX: Math typesetting for the web

#24

Earlier quoted context omitted.

We're not compatible yet, but we're working on it! In the meantime, you can fallback to MathJax on things we don't support. That way, most things can be rendered fast, and anything super complicated gets special treatment. We'll be releasing something soon on how to do this, and if you use React you can use the KA TeX component: http://khan.github.io/react-components/#tex

So is your goal to be a faster MathJax-compatible alternative? We currently use MathJax, but there's definitely a need for faster rendering. As an example, we sometimes run a page load through wkhtmltopdf, and MathJax content can take a LONG time EDIT: Thanks for replying to my comment in spite of the downvotes

Yep, that's our goal. Khan Academy does a bunch of math rendering, and our exercises were suffereing because of it. Hopefully some time we'll be able to stop using MathJax.

Re: KaTeX: Math typesetting for the web

#26

Are you also using the STIX fonts? If yes: I am working on a web application which downloads those STIX fonts anyway, can I point KaTeX to use my already downloaded fonts instead of downloading its own?

Unfortunately, we're not. We might support that in the future though.

Re: KaTeX: Math typesetting for the web

#27
Looks great! Will KaTeX support (c.q. integrate with) ASCIIMathML.js¹,²? AsciiMath is dubbed “TeX without backslashes”, or as “markdown for math”.³ (La)TeX input can become laborious, and the syntax gets difficultly readable, very rapidly.

With AsciiMath syntax⁴ (and Unicode!⁵) you can write δA instead of `\delta A`, ½ instead of `\frac{1}{2}`, ((a,b),(c,d)) instead of `\begin{pmatrix}a & b \\ c & d \end{pmatrix}`, &c.

¹ http://en.wikipedia.org/wiki/ASCIIMathML ² http://www.asciimath.org ³ http://boolesrings.org/krautzberger/2014/08/10/asciimathml-t...http://www1.chapman.edu/~jipsen/mathml/asciimathsyntax.htmlhttp://www.johndcook.com/math_symbols.html

Re: KaTeX: Math typesetting for the web

#28

Is there support for alternate math fonts (not sure what the proper term is) like \mathbf, \mathcal, \mathbb? Couldn't get it working. Looks fantastic though.

Please! I find MathJax unusable because of this shortcoming.

Huh? Not sure about \mathbf, but \mathcal and \mathbb definitely work in Mathjax.

Re: KaTeX: Math typesetting for the web

#29

Are you also using the STIX fonts? If yes: I am working on a web application which downloads those STIX fonts anyway, can I point KaTeX to use my already downloaded fonts instead of downloading its own?

Unfortunately, we're not. We might support that in the future though.

Very cool anyway. Because you are just using CSS instead of the DOM trickery of MathJax I should still be able to use it for my purposes.

Re: KaTeX: Math typesetting for the web

#30

Props to the coders for improving upon the LaTeX/Web use case space, but I can't help but feel something other than LaTeX is going to be necessary for the internet. LaTeX was fundamentally about document-level typesetting, and the internet is fundamentally not a place where that happens.

I suppose by "internet" you mean "web" and in particular the fundamental problem you see is that LaTeX assumes the input contains everything needed for the final output, whereas hypertext on the web can be remixed in an open-ended way? I.e., it's hard to get pleasing results out of a process of composition of disparate LaTeX sources?

Otherwise could you clarify the conflict you have in mind?

Post reply on HN