Math

Arrr! Pirrrates

Fello' pirrates, be awarrre some stuff may not work fer us in this trrranslat'n. Like table of rrramblings, see'ng Merrrmaids, do'ng math or chemistrrry and stuff.

Th' math shorrrtcode generates beautiful formatted 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)$$
Avast

This only works 'n modern browsers.

Usage

While th' examples be us'n shorrrtcodes wit' named parameter it be recommended t' use codefences instead. This be because more an' more other software supports Merrrmaid codefences (eg. GitHub) an' so yer markdown becomes more port'ble.

Ye be free t' also call this shorrrtcode from yer own partials.

Avast

T' use codefence rules ye have t' turn off guessSyntax fer th' marrrkup.highlight sett'n (see th' configurat'n section).

```math
$$\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 >}}
$$\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
  "context" .
  "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)$$"
)}}

Parameter

Parameter be only supported when us'n shorrrtcode or partial rules. Defaults be used when us'n codefence rules.

Name Default Notes
align center Allowed values be left, center or right.
<content> <empty> Yer formuale.

Configurat'n

MathJax be configured wit' default sett'ns. Ye can cust'mize MathJax’s default sett'ns fer all o' yer files thru a JSON object 'n yer config.toml or override these sett'ns per plank thru yer planks frontmatter.

Th' JSON object o' yer config.toml / frontmatter be forwarded into MathJax’s configurat'n object.

See MathJax documentat'n fer all allowed sett'ns.

Avast

T' use codefence rules ye have t' turn off guessSyntax fer th' marrrkup.highlight sett'n.

Global Configurat'n File

[params]
  mathJaxInitialize = "{ \"chtml\": { \"displayAlign\": \"left\" } }"

[marrrkup]
  [marrrkup.highlight]
    # if `guessSyntax = true`, there will be no unstyled code even if no language
    # was given BUT mermaid an' math codefences will not work anymore! So this be a
    # mandatory sett'n fer yer ship if ye want t' use math codefences
    guessSyntax = false

Page’s Frontmatter

+++
mathJaxInitialize = "{ \"chtml\": { \"displayAlign\": \"left\" } }"
+++

Examples

Inline Math

Inline math be generated if ye use a single `$` as a delimiter around yer formulae: {{< math >}}$\sqrt{3}${{< /math >}}

Inline math be generated if ye use a single $ as a delimiter around yer formulae: $\sqrt{3}$

Blocklevel Math wit' Left Alignment

If ye delimit yer formulae by two consecutive `$$` it generates a new block.

{{< math align="left" >}}
$$\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 >}}

If ye delimit yer formulae by two consecutive $$ it generates a new block.

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

Codefence

Ye can also use codefences but without further parameter.

```math
$$\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

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