1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2024-12-01 02:27:17 +01:00
mkdocs-material/docs/reference/mathjax.md

122 lines
3.0 KiB
Markdown
Raw Normal View History

2020-07-24 16:11:42 +02:00
---
template: overrides/main.html
2022-06-19 13:01:44 +02:00
icon: material/alphabet-greek
2020-07-24 16:11:42 +02:00
---
# MathJax
2021-10-10 12:19:14 +02:00
[MathJax] is a beautiful and accessible way to display mathematical content
in the browser, adds support for mathematical typesetting in different notations
(e.g. [LaTeX], [MathML], [AsciiMath]), and can be easily integrated with
2020-07-24 16:11:42 +02:00
Material for MkDocs.
2021-10-10 12:19:14 +02:00
[MathJax]: https://www.mathjax.org/
[LaTeX]: https://en.wikibooks.org/wiki/LaTeX/Mathematics
[MathML]: https://en.wikipedia.org/wiki/MathML
[AsciiMath]: http://asciimath.org/
2020-07-24 16:11:42 +02:00
## Configuration
2021-10-10 12:19:14 +02:00
This configuration enables support for rendering block and inline block
equations through [MathJax]. Create a configuration file and add the following
lines to `mkdocs.yml`:
2020-07-24 16:11:42 +02:00
2022-09-11 19:25:40 +02:00
=== ":octicons-file-code-16: `docs/javascripts/mathjax.js`"
2020-07-24 16:11:42 +02:00
``` js
window.MathJax = {
tex: {
inlineMath: [["\\(", "\\)"]],
displayMath: [["\\[", "\\]"]],
processEscapes: true,
processEnvironments: true
},
options: {
ignoreHtmlClass: ".*|",
processHtmlClass: "arithmatex"
}
};
2021-12-11 14:30:07 +01:00
document$.subscribe(() => { // (1)!
MathJax.typesetPromise()
})
2020-07-24 16:11:42 +02:00
```
2021-10-10 12:19:14 +02:00
1. This integrates MathJax with [instant loading].
2022-09-11 19:25:40 +02:00
=== ":octicons-file-code-16: `mkdocs.yml`"
2020-07-24 16:11:42 +02:00
``` yaml
2021-10-10 12:19:14 +02:00
markdown_extensions:
- pymdownx.arithmatex:
generic: true
2020-07-24 16:11:42 +02:00
extra_javascript:
2021-10-10 12:19:14 +02:00
- javascripts/mathjax.js
2020-07-24 16:11:42 +02:00
- https://polyfill.io/v3/polyfill.min.js?features=es6
- https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js
```
2021-10-10 12:19:14 +02:00
See additional configuration options:
2020-07-24 16:11:42 +02:00
2021-10-10 12:19:14 +02:00
- [Arithmatex]
2021-10-10 12:19:14 +02:00
[Arithmatex]: ../setup/extensions/python-markdown-extensions.md#arithmatex
[instant loading]: ../setup/setting-up-navigation.md#instant-loading
2020-07-24 16:11:42 +02:00
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<script>
window.MathJax = {
tex: {
inlineMath: [["\\(", "\\)"]],
displayMath: [["\\[", "\\]"]],
processEscapes: true,
processEnvironments: true
},
options: {
ignoreHtmlClass: ".*|",
processHtmlClass: "arithmatex"
}
};
</script>
## Usage
### Using block syntax
Blocks must be enclosed in `#!latex $$...$$` or `#!latex \[...\]` on separate
lines:
2020-07-24 16:11:42 +02:00
``` latex title="MathJax, block syntax"
2020-07-24 16:11:42 +02:00
$$
\operatorname{ker} f=\{g\in G:f(g)=e_{H}\}{\mbox{.}}
$$
```
<div class="result" markdown>
2020-07-24 16:11:42 +02:00
$$
\operatorname{ker} f=\{g\in G:f(g)=e_{H}\}{\mbox{.}}
$$
</div>
2020-07-24 18:29:34 +02:00
### Using inline block syntax
2020-07-24 16:11:42 +02:00
2020-07-24 18:29:34 +02:00
Inline blocks must be enclosed in `#!latex $...$` or `#!latex \(...\)`:
2020-07-24 16:11:42 +02:00
``` latex title="MathJax, inline syntax"
2020-07-24 16:11:42 +02:00
The homomorphism $f$ is injective if and only if its kernel is only the
singleton set $e_G$, because otherwise $\exists a,b\in G$ with $a\neq b$ such
that $f(a)=f(b)$.
```
<div class="result" markdown>
2020-07-24 16:11:42 +02:00
The homomorphism $f$ is injective if and only if its kernel is only the
singleton set $e_G$, because otherwise $\exists a,b\in G$ with $a\neq b$ such
that $f(a)=f(b)$.
</div>