|
1 | 1 | # MathJax support |
2 | 2 |
|
3 | | -mdBook has optional support for math equations through |
4 | | -[MathJax](https://www.mathjax.org/). |
5 | | - |
6 | | -To enable MathJax, you need to add the `mathjax-support` key to your `book.toml` |
7 | | -under the `output.html` section. |
| 3 | +mdBook has optional support for math formulas, which are rendered through |
| 4 | +[MathJax](https://www.mathjax.org/) (more precisely, the latest release of |
| 5 | +MathJax version 4). To enable it, set `output.html.math` to `true` in your |
| 6 | +`book.toml`: |
8 | 7 |
|
9 | 8 | ```toml |
10 | 9 | [output.html] |
11 | | -mathjax-support = true |
| 10 | +math = true |
12 | 11 | ``` |
13 | 12 |
|
14 | | ->**Note:** The usual delimiters MathJax uses are not yet supported. You can't |
15 | | -currently use `$$ ... $$` as delimiters and the `\[ ... \]` delimiters need an |
16 | | -extra backslash to work. Hopefully this limitation will be lifted soon. |
| 13 | +Inline equations are delimited by `$...$` and block equations are delimited |
| 14 | +by `$$...$$`. For example, to obtain |
17 | 15 |
|
18 | | ->**Note:** When you use double backslashes in MathJax blocks (for example in |
19 | | -> commands such as `\begin{cases} \frac 1 2 \\ \frac 3 4 \end{cases}`) you need |
20 | | -> to add _two extra_ backslashes (e.g., `\begin{cases} \frac 1 2 \\\\ \frac 3 4 |
21 | | -> \end{cases}`). |
| 16 | +> If $n \geq 3$ then there are no integers $a, b, c \geq 1$ satisfying $$a^n + b^n = c^n$$ |
22 | 17 |
|
| 18 | +you would write the following: |
23 | 19 |
|
24 | | -### Inline equations |
25 | | -Inline equations are delimited by `\\(` and `\\)`. So for example, to render the |
26 | | -following inline equation \\( \int x dx = \frac{x^2}{2} + C \\) you would write |
27 | | -the following: |
28 | 20 | ``` |
29 | | -\\( \int x dx = \frac{x^2}{2} + C \\) |
| 21 | +If $n \geq 3$ then there are no integers $a, b, c \geq 1$ satisfying $$a^n + b^n = c^n$$ |
30 | 22 | ``` |
31 | 23 |
|
32 | | -### Block equations |
33 | | -Block equations are delimited by `\\[` and `\\]`. To render the following |
34 | | -equation |
35 | | - |
36 | | -\\[ \mu = \frac{1}{N} \sum_{i=0} x_i \\] |
37 | | - |
| 24 | +## Legacy MathJax support |
38 | 25 |
|
39 | | -you would write: |
40 | | - |
41 | | -```bash |
42 | | -\\[ \mu = \frac{1}{N} \sum_{i=0} x_i \\] |
43 | | -``` |
| 26 | +The legacy option `output.html.mathjax-support` enables equations with a |
| 27 | +different syntax: `\\( ... \\)` for inline equations and `\\[ ... \\]` for |
| 28 | +block equations. Because it does not parse formulas in the Markdown input |
| 29 | +but instead lets MathJax find the delimiters in the HTML output, it has |
| 30 | +the limitation that characters which have an effect in Markdown, such as |
| 31 | +underscores, need to be escaped in formulas. This option is kept for |
| 32 | +backwards compatibility; use `output.html.math` in new books. It uses |
| 33 | +MathJax 2.7.1. |
0 commit comments