1.5 KiB
1.5 KiB
+++ title = "Math Typesetting" description = "Introducing Doks, a Hugo theme helping you build modern documentation websites that are secure, fast, and SEO-ready — by default." date = 2021-04-08T09:19:42+00:00 updated = 2021-04-08T09:19:42+00:00 draft = false template = "blog/page.html"
[taxonomies] authors = ["Public"]
[extra] lead = "Mathematical notation in a project can be enabled by using third party JavaScript libraries." math = true +++
In this example we will be using KaTeX
- Create a macro under
/template/macros/math.html
with a macro namedmath
. - Within this macro reference the Auto-render Extension or host these scripts locally.
- Import the macro in your templates like so:
{% import 'macros/math.html' as macros %}
{% if page.extra.math or section.extra.math or config.extra.math %}
{{ macros::math() }}
{% endif %}
- To enable KaTex globally set the parameter
extra.math
totrue
in a project's configuration - To enable KaTex on a per page basis include the parameter
extra.math = true
in content files
Note:
- The MathJax library is the other optional choice, and you can set the parameter
extra.library
tomathjax
in a project's configuration - Use the online reference of Supported TeX Functions
Examples
Inline math: \(\varphi = \dfrac{1+\sqrt5}{2}= 1.6180339887…\)
Block math:
\varphi = 1+\frac{1} {1+\frac{1} {1+\frac{1} {1+\cdots} } }