Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add KaTeX rendering (KaTeX 0.10.0) #50

Open
wants to merge 1 commit into
base: master
from

Conversation

@hcgatewood
Copy link
Contributor

commented Mar 11, 2019

Add support for KaTeX rendering.

KaTeX

KaTeX is a JavaScript library for LaTeX-like equation rendering that trades the full-featured functionality of MathJax for much faster render speed. Try it out on their home page.

Updates to Livedown

To get KaTeX rendering working locally, we need to include three resources in the public/vendor directory, referenced from index.html:

  • katex.min.js
  • katex.min.css
  • the KaTeX fonts directory

Additionally, for full functionality, we want markdown-it to perform the server-side conversion to HTML for us (which the above resources then render properly in the browser). We would use markdown-it-katex, but per this issue and my own debugging, this "official" package does not support current KaTeX versions. Thus, we instead can use an up-to-date fork (thanks to @iktakahiro) which supports KaTeX 0.10, a recent-enough version of KaTeX.

Using KaTeX

Note that there are some differences between KaTeX and LaTeX. For example, the line break (\\) is not supported in $$ environments in KaTeX v0.10.0. Instead, use \begin{array} or \begin{aligned} for multi-line equations.

If you're not sure if/how some equation should render, check it out in the playground on KaTeX's landing page. See below for an example.

$$
\begin{aligned}
a_{n+1} &= \frac{x_{n+1} + nc_n}{n+1} \\
\iff a_{n+1} &= a_n + \frac{x_{n+1} - a_n}{n+1}
\end{aligned}
$$

Screen Shot 2019-03-11 at 7 18 58 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.