Live data from Hacker News

KaTeX: Math typesetting for the web

khan.github.io

91–100 of 101 posts

Re: KaTeX: Math typesetting for the web

#91
post #84

Is there support for matrices? Neither \begin{bmatrix} a & b \\ c & d \end{bmatrix} nor \begin{array}{ccc} a & b & c \\ d & e & f \\ g & h & i \end{array} works.

Doesn't look like it: https://github.com/Khan/KaTeX/wiki/Function-Support-in-KaTeX

Sad. I mean, for sure blazing speed needs some limitations, but I use a lot of matrices in my stuff.

Re: KaTeX: Math typesetting for the web

#92
post #84

Is there support for matrices? Neither \begin{bmatrix} a & b \\ c & d \end{bmatrix} nor \begin{array}{ccc} a & b & c \\ d & e & f \\ g & h & i \end{array} works.

Hey! We're planning on adding environments (everything that uses \begin and \end) sometime soon. There's a couple github issues touching on this point; if you want to know how development's going, you can follow one of the issues.

Re: KaTeX: Math typesetting for the web

#93

I'm curious: why does this work so much better than MathJax? What's the technical "secret sauce" that makes this tick? I was looking for that on the site and in the README, but it doesn't seem to have any explanation as to the tricks that make up KaTeX.

There's no real "secret sauce", it's mostly just "do things smart". For example, while MathJax tends to do a bunch of calculations about exact positions of where different characters should go, KaTeX manages to get away with offloading most of that into the CSS, so the native CSS renderer can handle it.

MathJax also does strange things involving inserting elements into the DOM to look at metrics that it uses in its calculations, then removing them, which takes a lot of time. We make sure that the same input is rendered the same every time, and try to make sure it looks good everywhere (there are a couple cases where we aren't the best at this, mostly because browser font rendering isn't great).

We also support less environments than MathJax, for example we only support HTML+CSS output (for now, though MathML is in the works for accessibility reasons), whereas MathJax supports HTML+CSS, SVG, MathML, and older browsers like IE 6. This means it can't rely on things like good CSS rendering like we do. It's a worthwhile tradeoff for us, because we can make ours so much faster, but it is a tradeoff.

Re: KaTeX: Math typesetting for the web

#94
post #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?

Minimal example: LaTeX embedding as practiced on the web doesn't reflow. TeX was intended for documents that knew their width, height, margins and etc.; no guarantees in a web page.

Re: KaTeX: Math typesetting for the web

#95
I wish this effort was put into browser engines' MathML support, so that math could be interoperably declarative like text (HTML) and vector graphics (SVG).

If you don't see the value in browser built-in features, consider how badly the upgrade to retina worked with JS+canvas compared to SVG.

Re: KaTeX: Math typesetting for the web

#96
post #8

A great idea would be that when you copy a math expression from the browser, it would put the LaTeX code in the copy-paste buffer: f(x) = \int_{-\infty}^\infty \hat f(\xi)\,e^{2 \pi i \xi x} \,d\xi So then I could paste it in an email, in a text editor, in my own LaTeX document, etc.

I recently discovered this works in wikipedia,i.e. if copying the first rendered formula in a page[0] I get latex code. Not sure if it's just the alt text. [0] Try http://en.wikipedia.org/wiki/Axiom_of_choice and you get \forall X \left[ \emptyset \notin X \implies \exists f \colon X \rarr \bigcup X \quad \forall A \in X \, ( f(A) \in A ) \right] \,.

This is only the case when you copy the fallback image--these have alt text that give you the LaTeX representation. Wikipedia sometimes gives you equations in the browser (non-fallback) and then you get unicode text similar to what klmr experienced in the other comment.

Re: KaTeX: Math typesetting for the web

#98

Is there an wysiwyg equation editor that can produce the code for this? Would be interested in adding equations to our product but our users wouldn't be familiar with TeX.

Please also try MathMagic. (www.mathmagic.com) It supports various output options. MathType like UI but more features. You can compare MathType and MathMagic. They both come with free versions and free trial period.

Re: KaTeX: Math typesetting for the web

#99

Earlier quoted context omitted.

yes, would love asciimath support. most of the math that'll exist on the web isn't there yet, and it'll be so much easier to the next billion internet users than learning latex. katex looks great though. we (socratic.org) might start using it if we can find a good asciimath=>latex converter.

Check out https://github.com/mathjax/asciimathml/blob/master/asciimath... . It uses the AsciiMath parser to generate latex to be fed into mimetex for rendering, but it could probably be daisy-chained with katex. I keep it current with the latest AsciiMath revisions.

I created such a daisy-chained page that uses ASCIIMathML input with KaTeX rendering where possible, and it falls back to MathJax when KaTeX can't handle the expression. See

http://www.intmath.com/cg5/asciimathml-katex-mathjax.php

Re: KaTeX: Math typesetting for the web

#100
You may be interested in my setup that accepts ASCIIMathML, converts it to LaTeX, delivers it by KaTeX where possible and falls back to MathJax when necessary.

Here it is: http://www.intmath.com/cg5/asciimathml-katex-mathjax.php

Here's how it was done: http://www.intmath.com/blog/katex-with-asciimathml-input-and...

Post reply on HN