KaTeX Configuration

  1. Create or extend _includes/head_custom.html with:

    {% assign math = page.math | default: layout.math | default: site.math %}
    
    {% case math %}
      {% when "katex" %}
        {% include katex.html %}
    {% endcase %}
    
  2. Copy the following files to your website source repo:

  3. To make KaTeX available on all your web pages, add to _config.yml:

    math: katex
    

    To restrict KaTeX to pages that use it, add to the front matter either:

    math: katex
    

    or:

    layout: katex
    

    You can add a preamble of KaTeX definitions of new commands and environments to _layouts/katex.html. It extends the default layout.

KaTeX options

The following options are already set in _includes/katex.html and in assets/js/mathtex-script-type.js:

globalGroup: true,
trust: true,
strict: false,
throwOnError: false,

You can customise KaTeX by adding further options.