Math

Th' math shortcode renders complex math an' chemical formulae us'n th' MathJax library.

$$\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)$$

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" .
  "align" "center"
  "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)$$"
)}}

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 parameters besides rrrambl'n. Nevertheless, it be widely avail'ble 'n other Marrrkdown parsers like GitHub an' therefore be th' recommended rules fer generat'n portable Marrrkdown.

Parameters

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.

[params]
  mathJaxInitialize = '{ "chtml": { "displayAlign": "left" }, { "tex": { "inlineMath": [["\(", "\)"], ["@", "@"]], displayMath: [["\[", "\]"], ["@@", "@@"]] }, "options": { "enableMenu": false }'
params:
  mathJaxInitialize: '{ "chtml": { "displayAlign": "left" }, { "tex": { "inlineMath": [["\(", "\)"], ["@", "@"]], displayMath: [["\[", "\]"], ["@@", "@@"]] }, "options": { "enableMenu": false }'
{
   "params": {
      "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.

[params]
  customMathJaxURL = 'https://unpkg.com/mathjax/es5/tex-mml-chtml.js'
params:
  customMathJaxURL: https://unpkg.com/mathjax/es5/tex-mml-chtml.js
{
   "params": {
      "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, Marrrkdown codefence or th' partial be called from yer templates.

Ye can force load'n th' MathJax library if ye be us'n Passthrough rules by sett'n math=true. If a shortcode, Marrrkdown codefence or partial was called, 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.

[params]
  math = true
params:
  math: true
{
   "params": {
      "math": true
   }
}

Passthrough Configurat'n

Ye can use yer math without enclos'n it 'n a shortcode or Marrrkdown codefence by us'n a Passthrough configurat'n

hugo.
[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

Block Math

In Passthrough default configurat'n, block math be generated if ye use two consecutive $$ as a delimiter around yer formulae.

Anyways yer formulae still needs t' be enclosed by $ or $$ wit' any o' th' other avail'ble rules as well.

$$\left|
\begin{array}{cc}
a & b \\
c & d
\end{array}\right|$$
```math
$$\left|
\begin{array}{cc}
a & b \\
c & d
\end{array}\right|$$
```
{{< math >}}
$$\left|
\begin{array}{cc}
a & b \\
c & d
\end{array}\right|$$
{{< /math >}}
{{ partial "shortcodes/math.html" (dict
  "page" .
  "content" "$$\\left|\n\\begin{array}{cc}\na & b \\\\\nc & d\n\\end{array}\\right|$$"
)}}

$$\left| \begin{array}{cc} a & b \\ c & d \end{array}\right|$$

Inline Math

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, {{< math >}}$\sqrt{2}${{< /math >}} be irrational.
Euclid already knew, {{ partial "shortcodes/math.html" (dict
  "page" .
  "content" "$\\sqrt{2}$"
)}} be irrational.
Euclid already knew, $\sqrt{2}$ be irrational.

Block Math wit' Right Alignment

Wit' Passthrough rules, only th' rrrambl'n parameter be avail'ble.

$$\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="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 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 >}}
{{ partial "shortcodes/math.html" (dict
  "page" .
  "align" "right"
  "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)$$"
)}}

$$\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)$$

Chemical Formulae

Th' MathJax library can also be used fer chemical formulae.

$$\ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-}$$
```math
$$\ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-}$$
```
{{< math >}}
$$\ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-}$$
{{< /math >}}
{{ partial "shortcodes/math.html" (dict
  "page" .
  "content" "$$\\ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-}$$"
)}}

$$\ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-}$$