Math & TeX

GitBook supports math equations and TeX thanks to plugins. There are currently 2 official plugins to display math: mathjax and katex.

Enable a math plugin:

To enable math support, you need to add one of these plugins to your book.json:

  1. {
  2. "plugins": ["mathjax"]
  3. }

Differences between MathJax and KaTeX

The mathjax and katex plugins are different implementations of TeX equation rendering, backed by their respective Open Source libraries: KaTeX and MathJax.

MathJax supports the entire TeX syntax, but the output is not perfect on ebooks (PDF, ePub and Mobi).
KaTeX renders perfectly on all formats (web and ebooks), but doesn’t yet support all the syntax.

Add math to your content:

  1. Here is some inline math: $$a \ne 0$$

A block of math should begin with a new line:

  1. Here is a block of math:
  2. $$
  3. a \ne 0
  4. $$