GithubHelp home page GithubHelp logo

tjhu / mdbook-katex Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lzanini/mdbook-katex

0.0 1.0 0.0 692 KB

A preprocessor for mdBook, rendering LaTex equations to HTML at build time.

License: MIT License

Rust 100.00%

mdbook-katex's Introduction

A preprocessor for mdBook, pre-rendering LaTex equations to HTML at build time. 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.

Getting Started

First, install mdbook-katex

cargo install --git "https://github.com/lzanini/mdbook-katex"

Then, add the following lines to your book.toml file

[output.katex]

[preprocessor.katex]

You can now use $ and $$ delimiters for inline and display equations within your .md files. If you need a regular dollar symbol, you can escape delimiters with a backslash \$.

# Chapter 1

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

an equation,

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

and a regular \$ symbol.

LaTex equations will be rendered as HTML when running mdbook build or mdbook serve as usual.

Katex options

The preprocessor supports passing options to the katex-rs crate in order to configure its behaviour. These options are specified under the [preprocessor.katex] directive.

The currently spported arguments are:

Argument Type
leqno boolean
fleqn boolean
throw-on-error boolean
error-color string
min-rule-thickness number
max-size number
max-expand number
trust boolean

There are also options to configure the behaviour of the preprocessor:

Option Default Description
static-css false Generates fully static html pages with katex styling
macros None Path to macros file (see Custom macros)

Custom macros

Custom LaTex macros must be defined in a .txt file, according to the following pattern

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

You need to specify the path of this file in your book.toml as follows

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

These macros can then be used in your .md files

# Chapter 1

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

mdbook-katex's People

Contributors

lzanini avatar matthewacon avatar kknives avatar luni-4 avatar tjni avatar tjhu avatar lovesegfault avatar srevinsaju avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.