Skip navigation

Math Typesetting

Mathematical notation in a project can be enabled by using third party JavaScript libraries.

Installation

In this example we will be using KaTeX\KaTeX .

  • Create a macro under /template/macros/math.html with a macro named math.
  • 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 to true in a project's configuration
  • To enable KaTex on a per page basis include the parameter extra.math = true in content files

Examples

Inline math

Inline math 1: φ=1+52=1.6180339887\varphi = \dfrac{1+\sqrt5}{2}= 1.6180339887…


Find {x,y,z}N\{ x, y, z \} \in \N where:

{x2+7xy+y2=z23x2xyzy2=z2 \begin{cases} x^2 + 7xy + y^2 = z^2 \\ 3x^2 - xyz - y^2 = z^2 \end{cases}

Block math

Find{x,y,z}Nwhere{x2+7xy+y2=z23x2xyzy2=z2 \text{Find}\quad \{ x, y, z \} \in \N \quad\text{where}\quad \begin{cases} x^2 + 7xy + y^2 = z^2 \\ 3x^2 - xyz - y^2 = z^2 \end{cases}

abcdefghi \def\arraystretch{1.5} \begin{array}{c:c:c} a & b & c \\ \hline d & e & f \\ \hdashline g & h & i \end{array}

LT(λ)=(x,s)TlogP(sx)i=1mλi22σ2 \mathcal L_{\mathcal T}(\vec{\lambda}) = \sum_{(\mathbf{x},\mathbf{s})\in \mathcal T} \log P(\mathbf{s}\mid\mathbf{x}) - \sum_{i=1}^m \frac{\lambda_i^2}{2\sigma^2}

(k=1nakbk)2(k=1nak2)(k=1nbk2) \displaystyle \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)

xNa(NHX4)HPOX4Δ(NaPOX3)Xx+xNHX3+xHX2O \ce{x Na(NH4)HPO4 ->[\Delta] (NaPO3)_x + x NH3 ^ + x H2O}

ZnX2++2HX++2OHXZn(OH)X2amphoteres Hydroxid+2HX++2OHX[Zn(OH)X4]X2Hydroxozikat \ce{Zn^2+ <=>[+ 2OH-][+ 2H+] $\underset{\text{amphoteres Hydroxid}}{\ce{Zn(OH)2 v}}$ <=>[+ 2OH-][+ 2H+] $\underset{\text{Hydroxozikat}}{\ce{[Zn(OH)4]^2-}}$}

HgX2+IXHgIX2redIX[HgXIIIX4]X2red \ce{Hg^2+ ->[I-] $\underset{\mathrm{red}}{\ce{HgI2}}$ ->[I-] $\underset{\mathrm{red}}{\ce{[Hg^{II}I4]^2-}}$}

f(x)=f^(ξ)e2πiξxdξ % \f is defined as #1f(#2) using the macro \f\relax{x} = \int_{-\infty}^\infty \f\hat\xi\,e^{2 \pi i \xi x} \,d\xi

37=7321122=7321227321732=7321227321732=7312117327312(112732) \begin{align} \sqrt{37} & = \sqrt{\frac{73^2-1}{12^2}} \\ & = \sqrt{\frac{73^2}{12^2}\cdot\frac{73^2-1}{73^2}} \\ & = \sqrt{\frac{73^2}{12^2}}\sqrt{\frac{73^2-1}{73^2}} \\ & = \frac{73}{12}\sqrt{1 - \frac{1}{73^2}} \\ & \approx \frac{73}{12}\left(1 - \frac{1}{2\cdot73^2}\right) \end{align}

f(n)={n/2,if n is even3n+1,if n is odd f(n) = \begin{cases} n/2, & \text{if $n$ is even} \\ 3n+1, & \text{if $n$ is odd} \end{cases}

nLeftCenterRight10.24112521189832020001+10i \begin{array}{c|lcr} n & \text{Left} & \text{Center} & \text{Right} \\ \hline 1 & 0.24 & 1 & 125 \\ 2 & -1 & 189 & -8 \\ 3 & -20 & 2000 & 1+10i \end{array}

f([1+{x,y}(xy+yx)(u+1)+a]3/2) f\left( \left[ \frac{ 1+\left\{x,y\right\} }{ \left( \frac{x}{y}+\frac{y}{x} \right) \left(u+1\right) }+a \right]^{3/2} \right)

maxz=cTxs.t.Axbx0dualityminv=bTys.t.ATycy0(PC)(DC)add slack varminus surplus varmaxz=cTxs.t.Ax+s=bx,s0some steps skippeddualityminv=bTys.t.ATyt=cy,t0(PS)(DS) % \require{extpfeil} % produce extensible horizontal arrows \begin{array}{ccc} % arrange LPPs % first row % first LPP \begin{array}{ll} \max & z = c^T x \\ \text{s.t.} & A x \le b \\ & x \ge 0 \end{array} & \xtofrom{\text{duality}} & % second LPP \begin{array}{ll} \min & v = b^T y \\ \text{s.t.} & A^T y \ge c \\ & y \ge 0 \end{array} \\ ({\cal PC}) & & ({\cal DC}) \\ \text{add } {\Large \downharpoonleft} \text{slack var} & & \text{minus } {\Large \downharpoonright} \text{surplus var}\\ % Change to your favorite arrow style % % second row % third LPP \begin{array}{ll} \max & z = c^T x \\ \text{s.t.} & A x + s = b \\ & x,s \ge 0 \end{array} & \xtofrom[\text{some steps skipped}]{\text{duality}} & % fourth LPP \begin{array}{ll} \min & v = b^T y \\ \text{s.t.} & A^T y - t = c \\ & y,t \ge 0 \end{array} \\ ({\cal PS}) & & ({\cal DS}) % \end{array}

x1x2x3s1s2s3s120210060s224501070s303100127810250000ratio45/25s120210060x21/215/401/4035/2s33/2011/403/4151/23025/205/20175ratio3/225/4x11011/20030x2013/41/41/405/2s3005/43/43/4139/20019/23/25/20265ratiox11011/20030x2011/3001/39s2005/3114/3260041/34010/3330 \begin{array}{rrrrrrr|r} & x_1 & x_2 & x_3 & s_1 & s_2 & s_3 & \\ \hline s_1 & -2 & 0 & -2 & 1 & 0 & 0 & -60 \\ s_2 & -2 & -4^* & -5 & 0 & 1 & 0 & -70 \\ s_3 & 0 & -3 & -1 & 0 & 0 & 1 & -27 \\ \hdashline & 8 & 10 & 25 & 0 & 0 & 0 & 0 \\ \text{ratio} & -4 & -5/2 & -5 & & & & \\ \hline s_1 & -2^* & 0 & -2 & 1 & 0 & 0 & -60 \\ x_2 & 1/2 & 1 & 5/4 & 0 & -1/4 & 0 & 35/2 \\ s_3 & 3/2 & 0 & 11/4 & 0 & -3/4 & 1 & 51/2 \\ \hdashline & 3 & 0 & 25/2 & 0 & 5/2 & 0 & -175 \\ \text{ratio} & -3/2 & & 25/4 & & & & \\ \hline x_1 & 1 & 0 & 1 & -1/2 & 0 & 0 & 30 \\ x_2 & 0 & 1 & 3/4 & 1/4 & -1/4 & 0 & 5/2 \\ s_3 & 0 & 0 & 5/4 & 3/4 & -3/4^* & 1 & -39/2 \\ \hdashline & 0 & 0 & 19/2 & 3/2 & 5/2 & 0 & -265 \\ \text{ratio} & & & & & \dots & & \\ \hline x_1 & 1 & 0 & 1 & -1/2 & 0 & 0 & 30 \\ x_2 & 0 & 1 & 1/3 & 0 & 0 & -1/3 & 9 \\ s_2 & 0 & 0 & -5/3 & -1 & 1 & -4/3 & 26 \\ \hdashline & 0 & 0 & 41/3 & 4 & 0 & 10/3 & -330 \end{array}

(1a1a12a1n1a2a22a2n1amam2amn) \begin{pmatrix} 1 & a_1 & a_1^2 & \cdots & a_1^n \\ 1 & a_2 & a_2^2 & \cdots & a_2^n \\ \vdots & \vdots& \vdots & \ddots & \vdots \\ 1 & a_m & a_m^2 & \cdots & a_m^n \end{pmatrix}

A0.1B0.2C0.3D0.4E0.50.60.70.80.90.10.20.30.4F0.5G0.6H0.7I0.8J12 % \require{enclose} \begin{array}{ccccccccc} \Large{{A}} & \xrightarrow{0.1} & \Large{{B}} & \xrightarrow{0.2} & \Large{{C}} & \xleftarrow{0.3} & \Large{{D}} & \xleftarrow{0.4} & \Large{{E}}\\ \scriptsize{0.5}\large{\downarrow} & \scriptsize{0.6}\large{\searrow} & \scriptsize{0.7}\large{\downarrow} & \scriptsize{0.8}\large{\nearrow} & \scriptsize{0.9}\large{\downarrow} & \scriptsize{0.1}\large{\swarrow} & \scriptsize{0.2}\large{\downarrow} & \scriptsize{0.3}\large{\nwarrow} & \scriptsize{0.4}\large{\downarrow}\\ \Large{{F}} & \xrightarrow[0.5]{} & \Large{{G}} & \xrightarrow[0.6]{} & \Large{{H}} & \xleftarrow[0.7]{} & \Large{{I}} & \xleftarrow[0.8]{} & \Large{{J}}\\ \circlearrowright\tfrac12\\ \end{array}

(3x((log(3x26)x283x1/2))  x=2  x=8 \left. \left(3x\left(\frac{\left(\log(\frac{3x^2}{6}\right)^{\frac{-x^2}{8}}}{3x^{1/2}} \right) \right) \right|_{\;x=2}^{\;x=8}

Vijk={yu+yl2xu+xl2,if xu<yl1C[xu3yl36+yl2+xu22xl+(xuyl)xl22+yu2xu22(xuxl)(yuxu)xu2xl22],if xu[yl,yu]1xuxl[(yu+yl)26yu+yl2xl+xl22],otherwise \begin{align*} V_{ijk}& = \begin{cases} \dfrac{y_u+y_l}2 - \dfrac{x_u+x_l}2,& \text{if }x_u < y_l\\[15pt] \dfrac1C \bigg[\dfrac{x_u^3-y_l^3}{6}+\dfrac{y_l^2+x_u^2}{2}x_l + (x_u-y_l)\dfrac{x_l^2}{2}+ \dfrac{y_u^2-x_u^2}{2}(x_u-x_l)& - (y_u-x_u)\dfrac{x_u^2-x_l^2}{2} \bigg], \\[12pt]& \text{if }x_u\in\left[y_l,y_u\right]\\[15pt] \dfrac1{x_u-x_l}\bigg[\dfrac{(y_u+y_l)^2}6 - \dfrac{y_u+y_l}2 x_l + \dfrac{x_l^2}2\bigg],& \text{otherwise} \end{cases} \end{align*}

Ez=kλzabdx(z2+x2)3/2=kλz(xz2+x2)ab=kλz(bz2+b2+az2+a2) E_z = k\lambda z \int_{-a}^b \frac{dx}{(z^2 + x^2)^{3/2}} = \frac{k\lambda}{z}\left(\frac{x}{\sqrt{z^2 + x^2}}\right)\Big|_{-a}^b = \frac{k\lambda}{z}\left(\frac{b}{\sqrt{z^2 + b^2}} + \frac{a}{\sqrt{z^2 + a^2}}\right)

123+211a1 \dfrac{\left\vert\dfrac{12\sqrt{3+211}}{a}\right|}{1}