Math

Arrr! Pirrrates

Fello' pirrrates, grog made us dizzy! Be awarrre some stuff may look weird in this trrranslat'n. Like Merrrmaids, do'n math or chemistrrry and stuff.

Th' math shortcode 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 Math codefences (eg. GitHub) an' so yer markdown becomes more port'ble.

Ye be free t' also call this shortcode 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 { 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"
)}}

Parameter

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 Merrrmaid 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' Right Alignment

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

{{< 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 >}}

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.

```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-}$$