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.
Install the crate
cargo install mdbook-katex
Add the preprocessor to your book.toml
file
toml
[preprocessor.katex]
Use $
and $$
delimiters for inline / display equations within your .md
files. Use \$
for a regular dollar symbol.
```
Here is an inline example, $ \pi(\theta) $,
an equation,
$$ \nabla f(x) \in \mathbb{R}^n, $$
and a regular $ symbol. ```
Macros must be defined in a .txt
file, according to the following pattern
txt
\grad:{\nabla}
\R:{\mathbb{R}^{#1 \times #2}}
Then, specify the macros location in your book.toml
toml
[preprocessor.katex]
macros = "path/to/macros.txt"
You can now use these macros in your .md
files
```
$$ \grad f(x) \in \R{n}{p} $$ ```