2015-12-30 22:04:24 +08:00
|
|
|
# MathJax Support
|
|
|
|
|
2018-08-03 10:34:26 +08:00
|
|
|
mdBook has optional support for math equations through
|
|
|
|
[MathJax](https://www.mathjax.org/).
|
2015-12-30 22:04:24 +08:00
|
|
|
|
2018-08-03 10:34:26 +08:00
|
|
|
To enable MathJax, you need to add the `mathjax-support` key to your `book.toml`
|
|
|
|
under the `output.html` section.
|
2015-12-30 22:04:24 +08:00
|
|
|
|
2017-08-11 00:11:26 +08:00
|
|
|
```toml
|
|
|
|
[output.html]
|
|
|
|
mathjax-support = true
|
2015-12-30 22:04:24 +08:00
|
|
|
```
|
2017-08-11 00:11:26 +08:00
|
|
|
|
2018-08-03 10:34:26 +08:00
|
|
|
>**Note:** The usual delimiters MathJax uses are not yet supported. You can't
|
|
|
|
currently use `$$ ... $$` as delimiters and the `\[ ... \]` delimiters need an
|
|
|
|
extra backslash to work. Hopefully this limitation will be lifted soon.
|
2017-08-11 00:11:26 +08:00
|
|
|
|
2018-08-03 10:34:26 +08:00
|
|
|
>**Note:** When you use double backslashes in MathJax blocks (for example in
|
|
|
|
> commands such as `\begin{cases} \frac 1 2 \\ \frac 3 4 \end{cases}`) you need
|
|
|
|
> to add _two extra_ backslashes (e.g., `\begin{cases} \frac 1 2 \\\\ \frac 3 4
|
|
|
|
> \end{cases}`).
|
2018-04-03 16:17:06 +08:00
|
|
|
|
|
|
|
|
2017-08-11 00:11:26 +08:00
|
|
|
### Inline equations
|
2018-08-03 10:34:26 +08:00
|
|
|
Inline equations are delimited by `\\(` and `\\)`. So for example, to render the
|
|
|
|
following inline equation \\( \int x dx = \frac{x^2}{2} + C \\) you would write
|
|
|
|
the following:
|
2017-08-11 00:11:26 +08:00
|
|
|
```
|
|
|
|
\\( \int x dx = \frac{x^2}{2} + C \\)
|
2015-12-30 22:04:24 +08:00
|
|
|
```
|
|
|
|
|
2017-08-11 00:11:26 +08:00
|
|
|
### Block equations
|
2018-08-03 10:34:26 +08:00
|
|
|
Block equations are delimited by `\\[` and `\\]`. To render the following
|
|
|
|
equation
|
2015-12-30 22:04:24 +08:00
|
|
|
|
|
|
|
\\[ \mu = \frac{1}{N} \sum_{i=0} x_i \\]
|
|
|
|
|
|
|
|
|
2017-08-11 00:11:26 +08:00
|
|
|
you would write:
|
2015-12-30 22:04:24 +08:00
|
|
|
|
2016-08-07 03:24:21 +08:00
|
|
|
```bash
|
2015-12-30 22:04:24 +08:00
|
|
|
\\[ \mu = \frac{1}{N} \sum_{i=0} x_i \\]
|
|
|
|
```
|