What is the best way to embed LaTeX in a webpage?

后端 未结 10 1747
旧巷少年郎
旧巷少年郎 2020-11-28 20:21

I\'m not asking about converting a LaTeX document to html.

What I\'d like to be able to do is have some way to use LaTeX math commands in an html document, and have

10条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-28 20:51

    I'm starting to look into this myself and it seems things have evolved. I have come across this comparison demo of KaTeX and MathJax.


    Long story short (as of this writing):

    • Fractions inside a matrix run into each other in KaTeX, but not MathJax (see "cross product")
    • Inside the square (or nth) root symbol, exponents and nested square roots seem to run up against the horizontal top line (see "Repeating Fractions" and "nth root".)
    • MathJax has slightly bolder and larger font, KaTeX is slightly leaner.

    But perhaps most decisive of all, I found that the total MathJax processing for the page averaged to 1674 ms for three runs. In contrast, KaTeX averaged 128 ms, which is an order of magnitude better!


    There are some other points of comparison to consider when looking through their respective websites:

    • The KaTeX main website claims to support most, but not all, of LaTeX. They list their supported functions here. MathJax expresses some of its limitations as well. Though it's hard knowing from a quick skim of these who in the end has "better" support. Some blogs I've run across say KaTeX has less support, but others have said that KaTeX has improved support significantly in recent years.
    • The MathJax website advertises support of MathML for both input and output. Some KaTeX issues on its github site here and here indicate that they support MathML for output, but not for input (I don't know much about MathML, but it at least seems important if you want to help out users with visual disabilities).
    • KaTeX renders synchronously, so it doesn't reflow the page (part of what makes it faster). But in exchange it temporarily locks the browser.
    • StackOverflow is a partner of MathJax (see here). It's used on some StackExchange sites, though not on StackOverflow itself due to page load time performance. In contrast, KaTeX was developed by Kahn Academy.

提交回复
热议问题