Mathematical Notation
Jake G May 05, 2021 Updated: January 01, 2022 #Features #Shortcodes #MathematicsYou can use KaTeX to render mathematical notations.
You can enable the $\KaTeX$ support globally, per-section or per-page basis.
Enable Globally
To enable the $\KaTeX$ support globally, add math = true
under [extra]
of the config.toml
at your site root. Now the katex shortcode will be rendered, you can also add math_auto_render = true
and every section and page of your site will load the KaTeX autorender extension.
[]
= true
= false
Per-section Basis
To enable the $\KaTeX$ support in a particular section, add math = true
under [extra]
in the [SECTION_NAME]/_index.md
.
Now the katex shortcode will be rendered, you can also add math_auto_render = true
and the section of your site will load the KaTeX autorender extension.
+++
[]
= true
+++
Per-page Basis
To enable the $\KaTeX$ support in a particular page, add math = true
under [extra]
in the page's
frontmatter. Now the katex shortcode will be rendered, you can also add math_auto_render = true
and the page of your site will load the KaTeX autorender extension.
+++
[]
= true
= true
+++
It is a good practice to enable $\KaTeX$ support on a per-page basis, since this will only load the required files on that particular page, without affecting the page load speed of other pages. If your site is not math-heavy, please do NOT enable this feature globally or per-section basis.
Usage
Wrap any valid $\KaTeX$ syntax with $...$
for inline
Mathematics and $$...$$
for block Mathematics.
Inline Mathematics
This is the most beautiful equation I've ever seen:
Usage
^+1=0
e
Output
e^{i\pi}+1=0
Block Mathematics
Some Mathematics in display mode is fair enough:
Usage
^1 x^2 dx
\int_0
Output
\int_0^1 x^2 dx
Auto Render Inline
$ e^{i\pi}+1=0 $
Auto Render Block
$$ f(x) = \int_{-\infty}^\infty\hat f(\xi),e^{2 \pi i \xi x},d\xi $$