In the meantime, you could use our TeX React component to use KaTeX when possible, and fall back to MathJax only when necessary: http://khan.github.io/react-components/#tex
Also, kind of irrelevant, do you think we'll ever get something better than (La)TeX syntax? I've been frustrated by obscure error messages from LaTeX in big documents because it's a macro language, so the interpreter doesn't actually see what you're typing. How does KaTeX handle errors?
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.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] \,.
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.https://github.com/Khan/KaTeX/wiki/Function-Support-in-KaTeX
Some examples:
My attempt: http://camdenre.github.io/src/app/html/EquationEditor
Mathway: https://www.mathway.com/
Mathjq: http://www.mathjq.com/math-editor/
It would be nice to have something officially supported by a large project. I think that there is a lot of potential on the web for interactive math lessons with symbolic input using a CAS (not multiple choice).
All MIT licensed if you are interested in using it.
Absolutely agree that if this was made and made open there would be a lot of opportunities in the math education space.
Otherwise could you clarify the conflict you have in mind?
Not that there isn't a usecase for this, but is this fully MathJax compatible?
EDIT: Thanks for replying to my comment in spite of the downvotes
Q: does this fallback method also cover browsers not supported by KaTeX but supported by MathJax?
That was always my dream when doing homework at the university.
http://windows.microsoft.com/en-us/windows7/use-math-input-p...
- 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, what's the KaTeX story for this?
- would KaTeX work just fine in a headless environment? e.g. say I'm using http://wkhtmltopdf.org/ to generate PDF from some HTML
- how does KaTeX compare to MathJax from a payload size? Mathjax takes quite a bit to load from basic connections even though you have to cache it only once.
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!
We're all dealing with having to display more complex math to students once you get past 5th grade in the Common Core, also on web and iPads. Appreciate you folks taking the time to release something like this to the public. People haven't been hounding us down because of the slow UX yet, but I can see that happening down the line. I'm hoping we can open source some of our tools as well once we're your size :)
My only other question was: is KaTeX 100% interchangeable with MathJax as far as syntax goes? What I'm asking is if we already have a lot of content written for MathJax, will we need to massage it into a new syntax or should it work for the most part?
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.html ⁵ http://www.johndcook.com/math_symbols.html
katex looks great though. we (socratic.org) might start using it if we can find a good asciimath=>latex converter.
Markdown is very deficient in, say, organizing a blog post in several sections and subsections. There's formatting syntax, but not semantic syntax. No support for different styling at a higher level (in the template renderer); no support for generating indexes, footnotes.
(The state of footnotes on the web in 2014 is lamentable).
All these valiant efforts in having portable math typesetting that like to make puns with "LaTeX" fall regrettably short of enabling one to make a short blogpost detailing a mathematical curiosity, or even heavily-referenced semi-scholarly output. LaTeX is a template engine that happens to leverage a programmable typesetter. We have a programmable typesetter with modern JavaScript, can we focus on semantic templating already?
EDIT: also wanted to add that most markdown parsers that I've used (pandoc, python markdown) have support for footnotes and tables, though footnotes are compiled at the end of the document instead of at the end of individual 'sections' or 'subsections', which is a major pain for longer documents.
This is very useful for big math threads like often on terrytao.wordpress.com, which can take up to a minute to render in my browser. On mobile it's even worse.
Support for tikz would be great, too.
More broadly: great project! Looks to bring us closer to the day when math on the web is easy and just works.
If you don't mind me asking, can you say why you didn't work with MathJax, and decided to start over?
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.
For example, the event handler that updates r at the bottom of this page: http://www.vizitsolutions.com/portfolio/gausslaw/ does not know anything about the expression as a whole, it only knows to update elements with a certain class with the new r value.
Of course I will take a look at this and see how it works for my content. It seems though, that this would be a case of interest to Khan Academy as it is comparatively common in instructional material.
Edit: I guess I hit a nerve then.
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...
How large is the performance difference between the server-side rendered version and the JS version?
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.