#mdbook #latex #html #preprocessor #katex

app mdbook-katex

mdBook preprocessor rendering LaTex equations to HTML

14 releases

new 0.2.5 Nov 28, 2020
0.2.4 Nov 22, 2020
0.1.8 Nov 19, 2020
Download history 184/week @ 2020-11-16 81/week @ 2020-11-23

88 downloads per month

MIT license

290KB
181 lines

A Rust preprocessor for mdBook rendering LaTex equations to HTML. It allows for very fast page loading, compared to rendering equations in the browser.

This preprocessor uses the Katex crate; see this page for the list of supported Latex functions.

Usage

Install the crate

cargo install mdbook-katex

Add the preprocessor to your book.toml file

[preprocessor.katex]

Use $ and $$ delimiters for inline / display equations within your .md files. Use \$ for a regular dollar symbol.

# Chapter 1

Here is an inline example, $ \pi(\theta) $, 

an equation,

$$ \nabla f(x) \in \mathbb{R}^n, $$

and a regular \$ symbol.

Macros

Macros must be defined in a .txt file, according to the following pattern

\grad:{\nabla}
\R:{\mathbb{R}^{#1 \times #2}}

Then, specify the macros location in your book.toml

[preprocessor.katex]
macros = "path/to/macros.txt"

You can now use these macros in your .md files

# Chapter 1

$$ \grad f(x) \in \R{n}{p} $$

Dependencies

~12MB
~259K SLoC