Repository is archived
No release in over 3 years
Low commit activity in last 3 years
Renders LaTeX formulas to your site via KaTeX
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0
~> 0.1
~> 1.0
~> 13.0
~> 3.9
~> 1.2
~> 0.16

Runtime

~> 2.7
>= 3.3, < 5.0
>= 1.9, < 3.0
 Project Readme

Jekyll LaTeX Block

Jekyll LaTeX Block is a plugin for Jekyll that uses KaTeX to render LaTeX at build time, without the need for client-side JavaScript.

Requirements

Ensure that your build environment has a JavaScript interpreter supported by ExecJS.

Installation

Add this gem to your project's Gemfile:

group :jekyll_plugins do
  gem "jekyll-latex-block", "~> 0.13.2"
end

And then execute:

$ bundle

Usage

In your content, you can use the latex block tag like so:

{% latex %}
e^{i \pi} + 1 = 0
{% endlatex %}

Additional rendering options such as displayMode may be specified like so:

{% latex displayMode=true %}
\int_{a}^a f(x) dx
{% endlatex %}

To display the resulting markup properly, you MUST include KaTeX CSS and relevant web fonts on your site. The generated HTML does not require KaTeX client-side JavaScript.

Easy-mode CSS & Fonts Integration ✔️

Place the following stylesheet just above your closing </body> tag.

Why not place it in the <head>? CSS is a blocking resource. If this external resource is (a) placed in the head, and (b) were to not load (or slowly load) for whatever reason, it would block the entire page from rendering.

The official recommendation for using this plugin is "external CSS belongs at the end of the body". Ultimately, you can do whatever you want. 🤷
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.13.2/katex.min.css" integrity="sha512-el2z+rjIj40JeIlKyqcoRjGNjvwHVlyahNQ1PhSs4PCztr6jJ4GgpjgN+1a++L9HZxhLXpa4eLG3ry976z0O2Q==" crossorigin="anonymous" />

Hard-mode CSS & Fonts Integration ⚠️

For maximum control, you may wish to manually download KaTeX CSS / web fonts and place them directly in your project. The author of this plugin is not responsible for your pain and suffering should you choose to go this route.

Contributing

After checking out the repo...

# Install dependencies, setup submodules
$ bin/setup

# Run tests
$ bin/rake test

# Run interactive prompt
$ bin/console

# Lint code for style violations
$ bin/rubocop

# Build a gem into the pkg/ directory
$ bin/rake build

Bug reports and pull requests are welcome on GitHub at https://github.com/t-richards/jekyll-latex-block.

License

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