jekyll-katex

This is a Jekyll plugin for performing server-side math rendering via the KaTeX library. KaTeX is a library for rending math on the web using LaTeX, similar to MathJax.

KaTeX differs from MathJax in that it displays faster rendering speed and renders to pure HTML rather than PNGs. There are various resources in benchmarking and comparing their performance, for more info, start here.

Comes packaged with KaTeX ^0.8.3 but

Installation

In your Jekyll project, add jekyll-katex to your gems.rb/Gemfile plugin block:

group :jekyll_plugins do
  gem 'jekyll-katex'
end

Once done, execute bundle install.

For alternative install methods, see here.

Config

Once plugin is included in your project, follow the installation instructions on the KaTeX README for the CSS and font files. You can skip including the .js file unless you want to do client-side in-browser rendering as well.

tl;dr

Put the following in your page headers:

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.8.3/katex.min.css">

Usage

Use the katex liquid tag for LaTeX math equations like so:

{% katex %}
c = \pm\sqrt{a^2 + b^2}
{% endkatex %}

If you want the equation to be rendered in display mode (on its own line, centered, large symbols), just pass in the display parameter:

{% katex display %}
c = \pm\sqrt{a^2 + b^2}
{% endkatex %}

Development

Getting Started

./bin/setup.sh

TODOs

  1. Better stand-alone packaging of KaTeX - specific KaTeX version shouldn't need to depend on this plugin

Contributing

Feel free to open issues and pull requests.

License

The gem is available as open source under the terms of the MIT License.