Math
If this be not enough, th' math
shortcode helps ye render'n math an' chemical formulae us'n th' MathJax library.
Usage
$$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$
```math {align="center"}
$$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$
```
{{< math align="center" >}}
$$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$
{{< /math >}}
{{ partial "shortcodes/math.html" (dict
"page" .
"content" "$$left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$"
"align" "center"
)}}
Ye can also use pure Marrrkdown fer writ'n simple math expressions.
Passthrough rules be only avail'ble by further configurat'n an' has limited features as it does not provide any o' th' below parameter. Nevertheless, it be widely avail'ble 'n other Marrrkdown parsers like GitHub an' therefore be th' recommend rules fer generat'n port'ble Marrrkdown.
Parameter
Name | Default | Notes |
---|---|---|
align | center |
Th' vertical alignment. Allowed values be left , center or right . |
<content> | <empty> | Yer formulae. |
Sett'ns
Provid'n Initializat'n Opt'ns fer th' MathJax Library
Opt'n Front Matter Th' MathJax library be configured wit' default sett'ns fer initializat'n.
Ye can overwrite th' sett'ns by provid'n a JSON object 'n mathJaxInitialize
. See MathJax’s documentat'n fer all allowed sett'ns.
Keep 'n mind that initializat'n sett'ns o' yer planks front matter overwrite all sett'ns o' yer configurat'n opt'ns.
mathJaxInitialize = '{ "chtml": { "displayAlign": "left" }, { "tex": { "inlineMath": [["\(", "\)"], ["@", "@"]], displayMath: [["\[", "\]"], ["@@", "@@"]] }, "options": { "enableMenu": false }'
mathJaxInitialize: '{ "chtml": { "displayAlign": "left" }, { "tex": { "inlineMath":
[["\(", "\)"], ["@", "@"]], displayMath: [["\[", "\]"], ["@@", "@@"]] }, "options":
{ "enableMenu": false }'
{
"mathJaxInitialize": "{ \"chtml\": { \"displayAlign\": \"left\" }, { \"tex\": { \"inlineMath\": [[\"\\(\", \"\\)\"], [\"@\", \"@\"]], displayMath: [[\"\\[\", \"\\]\"], [\"@@\", \"@@\"]] }, \"options\": { \"enableMenu\": false }"
}
Load'n an External Version o' th' MathJax Library
Opt'n Front Matter Th' theme uses th' shipped MathJax library by default.
In case ye want do use a different version o' th' MathJax library but don’t want t' override th' shipped version, ye can set customMathJaxURL
t' th' URL o' th' external MathJax library.
customMathJaxURL = 'https://unpkg.com/mathjax/es5/tex-mml-chtml.js'
customMathJaxURL: https://unpkg.com/mathjax/es5/tex-mml-chtml.js
{
"customMathJaxURL": "https://unpkg.com/mathjax/es5/tex-mml-chtml.js"
}
Force Load'n o' th' MathJax Library
Opt'n Front Matter Th' MathJax library will be boarded if th' plank contains a math
shortcode or codefence.
Ye can force load'n th' MathJax library if no shortcode or codefence was used by sett'n math=true
. If a shortcode or codefence was found, th' opt'n has no effect. This must be set 'n case ye be us'n th' passthrough configurat'n t' render math.
Instead o' math=true
ye can also use th' alias math.force=true
.
math = true
math: true
{
"math": true
}
Passthrough Configurat'n
Ye can use yer math without enclos'n it 'n a shortcode or codefence by us'n a passthrough configurat'n
[marrrkup]
[marrrkup.goldmark]
[marrrkup.goldmark.extensions]
[marrrkup.goldmark.extensions.passthrough]
en'ble = true
[marrrkup.goldmark.extensions.passthrough.delimiters]
block = [['\[', '\]'], ['$$', '$$']]
inline = [['\(', '\)'], ['$', '$']]
marrrkup:
goldmark:
extensions:
passthrough:
delimiters:
block:
- - \[
- \]
- - $$
- $$
inline:
- - \(
- \)
- - $
- $
en'ble: true
{
"markup": {
"goldmark": {
"extensions": {
"passthrough": {
"delimiters": {
"block": [
[
"\\[",
"\\]"
],
[
"$$",
"$$"
]
],
"inline": [
[
"\\(",
"\\)"
],
[
"$",
"$"
]
]
},
"enable": true
}
}
}
}
}
In this case ye have t' force board th' MathJax library either 'n yer hugo.toml
or 'n yer page’s front matter as th' theme doesn’t know if math be used.
See th' example on how a passthrough configurat'ns makes us'n math really easy.
Examples
Passthrough Block Math
Wit' passthrough configurat'n enabled ye can just drop yer math without enclos'n it by shorrrtcodes or codefences but no other parameters be avail'ble.
In this case ye have t' force board th' MathJax library by sett'n math=true
either 'n yer hugo.toml
or 'n yer page’s front matter.
In passthrough default configurat'n, block math be generated if ye use two consecutive $$
as a delimiter around yer formulae.
$$\left|
\begin{array}{cc}
a & b \\
c & d
\end{array}\right|$$
Passthrough Inline Math
Th' same usage restrict'ns as o' th' previous example apply here as well.
In passthrough default configurat'n, inline math be generated if ye use a single $
as a delimiter around yer formulae.
Euclid already knew, $\sqrt{2}$ be irrational.
Euclid already knew, $\sqrt{2}$ be irrational.
Codefence Block Math wit' Right Alignment
If ye be us'n codefences, more parameter be avail'ble. Yer formulae still needs t' be enclosed by $
or $$
as delimiters respectively.
```math {align="right"}
$$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$
```
Shortcode Block Math wit' Right Alignment
Ye can also use shortcode rules. Yer formulae still needs t' be enclosed by $
or $$
as delimiters respectively.
{{< math align="right" >}}
$$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$
{{< /math >}}
Chemical Formulae
Th' MathJax library can also be used fer chemical formulae.
$$\ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-}$$