Abstract

Mathematical notation in a Hugo project via Hugo’s embedded instance of the KaTeX.

In this example we will be using KaTeX

Note: Use the online reference of Supported TeX Functions

And the general: LaTeX/Mathematics

Examples

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

Block math:


KL(y^y)=c=1My^clogy^cycJS(y^y)=12(KL(yy+y^2)+KL(y^y+y^2)) \begin{aligned} KL(\hat{y} || y) &= \sum_{c=1}^{M}\hat{y}_c \log{\frac{\hat{y}_c}{y_c}} \\ JS(\hat{y} || y) &= \frac{1}{2}(KL(y||\frac{y+\hat{y}}{2}) + KL(\hat{y}||\frac{y+\hat{y}}{2})) \end{aligned}
i=1ni=n(n+1)2 \sum_{i=1}^{n}{i}=\frac{n(n+1)}{2} 0<i<m0<j<nP(i,j) \sum_{\substack{ 0<i<m \\ 0<j<n }} P(i,j) j0(k0ajkzk)=k0zn(k0,k1,0k0+k1+=na0k0a1k1) \begin{equation} \prod_{j\geq 0} \left(\sum_{k\geq 0}a_{jk} z^k\right) = \sum_{k\geq 0} z^n \left( \sum_{{k_0,k_1,\ldots\geq 0} \atop{k_0+k_1+\ldots=n} } a{_0k_0}a_{1k_1}\ldots \right) \end{equation}
xX,yϵ \forall x \in X, \quad \exists y \leq \epsilon
α,A,β,B,γ,Γ,π,Π,ϕ,φ,μ,Φ \alpha, \Alpha, \beta, \Beta, \gamma, \Gamma, \pi, \Pi, \phi, \varphi, \mu, \Phi (a),[b],{c},d,e,f,g,h,i,/j\ ( a ), [ b ], \{ c \}, | d |, \| e \|, \langle f \rangle, \lfloor g \rfloor, \lceil h \rceil, \ulcorner i \urcorner, / j \backslash cool  cool \overrightarrow{\text{cool}} \,{\Huge \Re }\;\overleftarrow{\text{cool}} β=(β1,β2,,βn) \boldsymbol{\beta} = (\beta_1,\beta_2,\dotsc,\beta_n)
cos(2θ)=cos2θsin2θ \cos (2\theta) = \cos^2 \theta - \sin^2 \theta
limxexp(x)=0 \lim\limits_{x \to \infty} \exp(-x) = 0
amodbxa(modb) \begin{aligned} &a \bmod b \\ &x \equiv a \pmod{b} \end{aligned}
kn+1=n2+kn2kn1 k_{n+1} = n^2 + k_n^2 - k_{n-1} f(n)=n5+4n2+2n=17 f(n) = n^5 + 4n^2 + 2 |_{n=17}
n!k!(nk)!=(nk) \frac{n!}{k!(n-k)!} = \binom{n}{k} 1x+1yyz \frac{\frac{1}{x}+\frac{1}{y}}{y-z} (x2y3) \left(\frac{x^2}{y^3}\right) x=a0+1a1+1a2+1a3+1a4 \begin{equation} x = a_0 + \cfrac{1}{a_1 + \cfrac{1}{a_2 + \cfrac{1}{a_3 + \cfrac{1}{a_4} } } } \end{equation}
ab \sqrt{\frac{a}{b}} 1+x+x2+x3++xnn \sqrt[n]{1+x+x^2+x^3+\dots+x^n}
0exdx \int_0^\infty \mathrm{e}^{-x}\,\mathrm{d}x ab \int\limits_a^b ϕ(t)=12π0tex2/2dx \begin{equation} \phi(t)=\frac{1}{\sqrt{2\pi}} \int^t_0 e^{-x^2/2} \mathrm{d}x \end{equation}
abcdefghi \begin{matrix} a & b & c \\ d & e & f \\ g & h & i \end{matrix} 1324=1324 \begin{matrix} -1 & 3 \\ 2 & -4 \end{matrix}= \begin{matrix*}[r] -1 & 3 \\ 2 & -4 \end{matrix*} Am,n=(a1,1a1,2a1,na2,1a2,2a2,nam,1am,2am,n) A_{m,n} = \begin{pmatrix} a_{1,1} & a_{1,2} & \cdots & a_{1,n} \\ a_{2,1} & a_{2,2} & \cdots & a_{2,n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{m,1} & a_{m,2} & \cdots & a_{m,n} \end{pmatrix} 1234 \begin{array}{c|c} 1 & 2 \\ \hline 3 & 4 \end{array} M=[561605601605616] M = \begin{bmatrix} \frac{5}{6} & \frac{1}{6} & 0 \\[0.3em] \frac{5}{6} & 0 & \frac{1}{6} \\[0.3em] 0 & \frac{5}{6} & \frac{1}{6} \end{bmatrix}

A matrix in text must be set smaller: (abcd)\bigl(\begin{smallmatrix} a&b \\ c&d \end{smallmatrix} \bigr) to not increase leading in a portion of text.

F(x,y)=0andF ⁣xxF ⁣xyF ⁣xF ⁣yxF ⁣yyF ⁣yF ⁣xF ⁣y0=0 \begin{equation} {F}(x,y)=0\quad\mathrm{and}\quad \left|\begin{array}{ccc} F_{\!xx}'' & F_{\!xy}'' & F_{\!x}' \\[0.3em] F_{\!yx}'' & F_{\!yy}'' & F_{\!y}' \\[0.3em] F_{\!x}' & F_{\!y}' & 0 \end{array} \right| =0 \end{equation}
k=x2 k = {\color{red}x} \mathbin{\color{blue}-} 2
((((( ( \big( \Big( \bigg( \Bigg( ddx(kg(x))ddx(kg(x))ddx(kg(x)) \begin{aligned} &\frac{\mathrm d}{\mathrm d x} \left( k g(x) \right) \\ &\frac{\mathrm d}{\mathrm d x} \big( k g(x) \big) \\ &\frac{\mathrm d}{\mathrm d x} \Big( k g(x) \Big) \end{aligned} {x2y3} \left\{\frac{x^2}{y^3}\right\} P(A=2|A2B>4) P\left(A=2\middle|\frac{A^2}{B}>4\right) x3301 \left.\frac{x^3}{3}\right|_0^1
f(n)={n/2if n is even(n+1)/2if n is odd f(n) = \begin{cases} n/2 & \quad \text{if } n \text{ is even}\\ -(n+1)/2 & \quad \text{if } n \text{ is odd} \end{cases} {(a,,ak as,(b,,bl bsk+1 elements} \begin{equation} \{\underbrace{% \overbrace{\mathstrut a,\ldots,a}^{k\ a's}, \overbrace{\mathstrut b,\ldots,b}^{l\ b's}} _{k+1\ \mathrm{elements}} \} \end{equation}
50apples×100apples=lotsofapples2 50 apples \times 100 apples = lots of apples^2 50apples×100apples=lots of apples2 50 \text{apples} \times 100 \text{apples} = \text{lots of apples}^2 50 apples×100 apples=lots of apples2 50 \text{ apples} \times 100 \text{ apples} = \text{lots of apples}^2
ydx \int y \mathrm{d}x ydx \int y\, \mathrm{d}x ydx \int y\: \mathrm{d}x y  dx \int y\; \mathrm{d}x y ⁣dx \int y\! \mathrm{d}x (nr)=n!r!(nr)! \left( \begin{array}{c} n \\ r \end{array} \right) = \frac{n!}{r!(n-r)!} ( ⁣nr ⁣)=n!r!(nr)! \left(\! \begin{array}{c} n \\ r \end{array} \!\right) = \frac{n!}{r!(n-r)!}