3.2 KiB
template |
---|
overrides/main.html |
MathJax
MathJax is a beautiful and accessible way to display mathematical content in the browser, allows for writing formulas in different notations, including LaTeX, MathML and AsciiMath, and can be easily integrated with Material for MkDocs.
Configuration
Arithmatex
:octicons-file-code-24: Source · :octicons-workflow-24: Extension
The Arithmatex extension, which is part of of Python Markdown
Extensions, allows the rendering of block and inline block equations, and
can be enabled via mkdocs.yml
:
markdown_extensions:
- pymdownx.arithmatex:
generic: true
Besides enabling the extension in mkdocs.yml
, a MathJax configuration and
the JavaScript runtime need to be included, which can be done with additional
JavaScript:
=== "docs/javascript/config.js"
``` js
window.MathJax = {
tex: {
inlineMath: [["\\(", "\\)"]],
displayMath: [["\\[", "\\]"]],
processEscapes: true,
processEnvironments: true
},
options: {
ignoreHtmlClass: ".*|",
processHtmlClass: "arithmatex"
}
};
```
=== "mkdocs.yml"
``` yaml
extra_javascript:
- javascripts/config.js
- https://polyfill.io/v3/polyfill.min.js?features=es6
- https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js
```
MathJax can be configured in many different ways, for which Material for MkDocs might not provide native support. See the official documentation for more information.
Usage
Using block syntax
Blocks must be enclosed in #!latex $$...$$
or #!latex \[...\]
on separate lines:
Example:
$$
\operatorname{ker} f=\{g\in G:f(g)=e_{H}\}{\mbox{.}}
$$
Result:
\operatorname{ker} f=\{g\in G:f(g)=e_{H}\}{\mbox{.}}
Using inline block syntax
Inline blocks must be enclosed in #!latex $...$
or #!latex \(...\)
:
Example:
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)$.
Result:
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)
.