diff --git a/docs/reference/katex.md b/docs/reference/katex.md new file mode 100644 index 000000000..a07c1baba --- /dev/null +++ b/docs/reference/katex.md @@ -0,0 +1,70 @@ +--- +icon: material/alphabet-greek +--- + +# MathJax + +[KaTeX] is a Lightning-fast library to display mathematical expressions +in the browser. + + [KaTeX]: https://katex.org/ + +KaTeX isn't supported by default, but can be easily integrated with Material for MkDocs. + +## Configuration + +This configuration enables support for rendering block and inline block +equations through [KaTex]. Create a configuration file and add the following +lines to `mkdocs.yml`: + +=== ":octicons-file-code-16: `docs/javascripts/katex.js`" + + ``` js + document$.subscribe(() => { // (1)! + renderMathInElement(document.body, { + delimiters: [ + {left: '$$', right: '$$', display: true}, + {left: '$', right: '$', display: false}, + {left: '\\(', right: '\\)', display: false}, + {left: '\\[', right: '\\]', display: true}, + ], + }); + }) + ``` + + 1. This integrates MathJax with [instant loading]. + +=== ":octicons-file-code-16: `overrides/main.html`" + + ```html + {% extends "base.html" %} + + {% block libs %} + + + + + + {{ super() }} + {% endblock %} + ``` + +=== ":octicons-file-code-16: `mkdocs.yml`" + + ``` yaml + extra_javascript: + - javascripts/katex.js + ``` + + [instant loading]: ../setup/setting-up-navigation.md#instant-loading + +## Usage + +### Using block syntax + +Blocks must be enclosed in `#!latex $$...$$` or `#!latex \[...\]` on separate +lines. + +### Using inline block syntax + +Inline blocks must be enclosed in `#!latex $...$` or `#!latex \(...\)`. \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index 25f00ac59..a62260d81 100755 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -220,6 +220,7 @@ nav: - Images: reference/images.md - Lists: reference/lists.md - MathJax: reference/mathjax.md + - KaTeX: reference/katex.md - Tooltips: reference/tooltips.md - Insiders: - insiders/index.md