Skip to content

Write formulas

You can use MkDocs Workspace to create powerful mathematical documentation websites or print documents, by exporting docs to pdf files. MkDocs Workspace renders LaTeX math equations with MathJax.

Showcase: formulas
\[ T^{i_1 i_2 \dots i_p}_{j_1 j_2 \dots j_q} = T(x^{i_1},\dots,x^{i_p},e_{j_1},\dots,e_{j_q}) \]
\[ \begin{align} p(v_i=1|\mathbf{h}) & = \sigma\left(\sum_j w_{ij}h_j + b_i\right) \\ p(h_j=1|\mathbf{v}) & = \sigma\left(\sum_i w_{ij}v_i + c_j\right) \end{align} \]
\[ \begin{matrix} 1 & x & x^2 \\ 1 & y & y^2 \\ 1 & z & z^2 \\ \end{matrix} \]
\[ \left[ \begin{array}{cc|c} 1&2&3\\ 4&5&6 \end{array} \right] \]
\[ \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) = \begin{cases} n/2, & \text{if $n$ is even} \\ 3n+1, & \text{if $n$ is odd} \end{cases} \]
\[ \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} \]
\[ \left\{ \begin{array}{l} 0 = c_x-a_{x0}-d_{x0}\dfrac{(c_x-a_{x0})\cdot d_{x0}}{\|d_{x0}\|^2} + c_x-a_{x1}-d_{x1}\dfrac{(c_x-a_{x1})\cdot d_{x1}}{\|d_{x1}\|^2} \\[2ex] 0 = c_y-a_{y0}-d_{y0}\dfrac{(c_y-a_{y0})\cdot d_{y0}}{\|d_{y0}\|^2} + c_y-a_{y1}-d_{y1}\dfrac{(c_y-a_{y1})\cdot d_{y1}}{\|d_{y1}\|^2} \end{array} \right. \]
\[ \underset{j=1}{\overset{\infty}{\LARGE\mathrm K}}\frac{a_j}{b_j}=\cfrac{a_1}{b_1+\cfrac{a_2}{b_2+\cfrac{a_3}{b_3+\ddots}}} \]
\[ \bbox[yellow] { e^x=\lim_{n\to\infty} \left( 1+\frac{x}{n} \right)^n \qquad (1) } \]
\[ |x|, ||v|| \quad\longrightarrow\quad \lvert x\rvert, \lVert v\rVert \]
\[ \begin{array}{c|rrrr}& x^3 & x^2 & x^1 & x^0\\ & 1 & -6 & 11 & -6\\ {\color{red}1} & \downarrow & 1 & -5 & 6\\ \hline & 1 & -5 & 6 & |\phantom{-} {\color{blue}0} \end{array} \]
\[ z = \overbrace{ \underbrace{x}_\text{real} + i \underbrace{y}_\text{imaginary} }^\text{complex number} \]
\[ T^{i_1 i_2 \dots i_p}_{j_1 j_2 \dots j_q} = T(x^{i_1},\dots,x^{i_p},e_{j_1},\dots,e_{j_q}) \]

$$
\begin{align}
    p(v_i=1|\mathbf{h}) & = \sigma\left(\sum_j w_{ij}h_j + b_i\right) \\
    p(h_j=1|\mathbf{v}) & = \sigma\left(\sum_i w_{ij}v_i + c_j\right)
\end{align}
$$

$$
    \begin{matrix}
    1 & x & x^2 \\
    1 & y & y^2 \\
    1 & z & z^2 \\
    \end{matrix}
$$

$$ \left[
\begin{array}{cc|c}
1&2&3\\
4&5&6
\end{array}
\right] 
$$

$$
\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) =
\begin{cases}
n/2,  & \text{if $n$ is even} \\
3n+1, & \text{if $n$ is odd}
\end{cases}
$$

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

$$ \left\{ \begin{array}{l}
0 = c_x-a_{x0}-d_{x0}\dfrac{(c_x-a_{x0})\cdot d_{x0}}{\|d_{x0}\|^2} + c_x-a_{x1}-d_{x1}\dfrac{(c_x-a_{x1})\cdot d_{x1}}{\|d_{x1}\|^2} \\[2ex] 
0 = c_y-a_{y0}-d_{y0}\dfrac{(c_y-a_{y0})\cdot d_{y0}}{\|d_{y0}\|^2} + c_y-a_{y1}-d_{y1}\dfrac{(c_y-a_{y1})\cdot d_{y1}}{\|d_{y1}\|^2} \end{array} \right. 
$$

$$
\underset{j=1}{\overset{\infty}{\LARGE\mathrm K}}\frac{a_j}{b_j}=\cfrac{a_1}{b_1+\cfrac{a_2}{b_2+\cfrac{a_3}{b_3+\ddots}}}
$$

$$ \bbox[yellow]
{
e^x=\lim_{n\to\infty} \left( 1+\frac{x}{n} \right)^n
\qquad (1)
}
$$

$$
|x|, ||v|| \quad\longrightarrow\quad \lvert x\rvert, \lVert v\rVert
$$

$$
\begin{array}{c|rrrr}& x^3 & x^2 & x^1 &  x^0\\ & 1 & -6 & 11 & -6\\ {\color{red}1} & \downarrow & 1 & -5 & 6\\ \hline & 1 & -5 & 6 & |\phantom{-} {\color{blue}0} \end{array}
$$

$$
z = \overbrace{
   \underbrace{x}_\text{real} + i
   \underbrace{y}_\text{imaginary}
  }^\text{complex number}
$$

Inline vs. block mode

Formulas are created using one of the notations:

  • $...$ and \(...\) for inline math
  • $$...$$, \[...\], and \begin{}...\end{} for block math.

Block mode should start from the new line.

Inline and block formulas render differently.

For example, this is \(\sum_{i=0}^n i^2 = \frac{(n^2+\epsilon)(2n+1)}{6\phi}\) an inline mode)

And the block mode looks like this (don't forget empty line!)

\[\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}\]
Inline and block formulas render differently. 

For example, this is $\sum_{i=0}^n i^2 = \frac{(n^2+\epsilon)(2n+1)}{6\phi}$
an inline mode) 

And the block mode looks like this (don't forget empty line!)

$$\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}$$

Add Greek letters to the formula

\[\sum_{i=0}^n \pi^2 = \Delta\frac{(n^2+\epsilon)(2n+1)}{6\phi}\]
$$
\sum_{i=0}^n \pi^2 = \Delta\frac{(n^2+\epsilon)(2n+1)}{6\phi}
$$

Groups

A group is either a single symbol, or any formula surrounded by curly braces {…}. Operators, fractions, subscripts or superscripts appy to the group or groups.

For example, you can use use ^ and _ to create superscripts and subscripts respectively.

\[ x_i^2 + \log_2 x \]
$$
x_i^2 + \log_2 x 
$$

And because superscripts, subscripts, and other operations apply only to the next group, if you write 10^10, you will get a surprise: \(10^10\). But 10^{10} gives what you probably wanted: \(10^{10}\).

Fractions

In order to create fractions use \frac{...}{...}. I.e.

\[ \frac{73^2-1}{12^2} \]
$$
\frac{73^2-1}{12^2}
$$

Combine Fractions

\[ \frac{\Gamma + \Omega}{\frac{73^2-1}{12^2}} \]
$$
\frac{\Gamma + \Omega}{\frac{73^2-1}{12^2}}
$$

Operators and other notations

Examples of Latex math operators and notations

Notation Output
\sqrt{x} \(\sqrt{x}\)
\sin(a + b) \(\sin(a + b)\)
\log(x + y) \(\log{(x + y)}\)
\log_4(x + y) \(\log_4{(x + y)}\)
\ln{x} \(\ln{x}\)
e^{x + y} \(e^{x + y}\)
\lim_{x \to 0}{x^2} \(\lim_{x \to 0}{x^2}\)
\min{x} \(\min{x}\)
f(n) = x^2 \(f(n) = x^2\)
... ...

Special symbols

Notation Output
a\equiv b \(a\equiv b\)
\bar{x} - \hat{x} - \tilde{x} \(\bar{x} \hat{x} \tilde{x}\)
\dot{x} + \ddot{x} + \dddot{x} \(\dot{x} \ddot{x} \dddot{x}\)
\exists a,b\in G$ with $a\neq b$ such that $f(a)=f(b) \(\exists a,b\in G\) with \(a\neq b\) such that \(f(a)=f(b)\)
a_1 + a_2 + a_3 + \cdots + a_n \(a_1 + a_2 + a_3 + \cdots + a_n\)
\lt \gt \le \leq \leqq \leqslant \(\lt \gt \le \leq \leqq \leqslant\)
\ge \geq \geqq \geqslant \neq \(\ge \geq \geqq \geqslant \neq\)
\times \div \pm \mp \cdot \(\times \div \pm \mp \cdot\)
\cup \cap \(\cup \cap\)
\setminus \subset \subseteq \subsetneq \supset \(\setminus \subset \subseteq \subsetneq \supset\)
\in \notin \(\in \notin\)
\emptyset \varnothing \(\emptyset \varnothing\)
\binom{n+1}{2k} \(\binom{n+1}{2k}\)
\to \rightarrow \leftarrow \Rightarrow \Leftarrow \mapsto \(\to \rightarrow \leftarrow \Rightarrow \Leftarrow \mapsto\)
\land \lor \lnot \forall \exists \top \bot \vdash \vDash \(\land \lor \lnot \forall \exists\)
$\top \bot \vdash \vDash$ \(\top \bot \vdash \vDash\)
\approx \sim \simeq \cong \equiv \prec \lhd \therefore \(\approx \sim \simeq \cong \equiv \prec \lhd \therefore\)
\overline{ABC} \(\overline{ABC}\)
\underline{XYZ} \(\underline{XYZ}\)
\widetilde{AB} \(\widetilde{AB}\)
\underleftarrow{ABC} \(\underleftarrow{ABC}\)
\underrightarrow{XYZ} \(\underrightarrow{XYZ}\)
\xleftarrow{} \xrightarrow{} \(\xleftarrow{} \xrightarrow{}\)

Sums, products, integrals

Notation Output
\sum_{i=0}^n i^2 \(\sum_{i=0}^n i^2\)
\prod_{i=0}^n (2i + i) \(\prod_{i=0}^n (2i + i)\)
\int(x) \(\int(x)\)
\int_{i=0}^n (2i + i) \(\int_{i=0}^n (2i + i)\)
\iint \(\iint\)
\iiint \(\iiint\)
\idotsint \(\idotsint\)

Set operators

Notation Output
\overline{A} = A^c \(\overline{A} = A^c\)
A \in B, B \notin C, D = \emptyset \(A \in B, B \notin C, D = \emptyset\)
(A \cup B \cap C) \setminus (D \subset E) \subseteq F \((A \cup B \cap C) \setminus (D \subset E) \subseteq F\)
\bigcup_{i=1}^n A_i \(\bigcup_{i=1}^n A^i\)
\bigcap_{i=1} A_i \(\bigcap_{i=1} A_i\)

Parentheses

Ordinary symbols ()[] make parentheses and brackets, i.e. \((2+3)[4+4]\). Use escape char \{ and \} for curly braces {}.

Notation Output
(x) \((x)\)
[x] \([x]\)
\{x\} \(\{x\}\)
|x| \(\vert x \vert\)
||x|| \(\Vert x \Vert\)
$\vert x \vert$ \(\vert x \vert\)
$\Vert x \Vert$ \(\Vert x \Vert\)
\langle x \rangle \(\langle x \rangle\)
\lceil x \rceil \(\lceil x \rceil\)
\lfloor x \rfloor \(\lfloor x \rfloor\)

There are different sizes of parentheses

\[ \Biggl(\biggl(\Bigl(\bigl((x)\bigr)\Bigr)\biggr)\Biggr) \]
$$
\Biggl(\biggl(\Bigl(\bigl((x)\bigr)\Bigr)\biggr)\Biggr)
$$

Hint

Use \left( and \right) notations in formulas instead of ( and ) respectively.

Symbols like ( will make small parentheses, which are not suitable for fractions. For example, in case of (\frac{\sqrt x}{y^3}) the output is:

\[ (\frac{\sqrt x}{y^3}) \]
$$
(\frac{\sqrt x}{y^3})
$$

But if you use \left( and \right) notations instead, you will get

\[ \left(\frac{\sqrt x}{y^3}\right) \]
$$
\left(\frac{\sqrt x}{y^3}\right)
$$

Combine fractions, operators and parentheses:

\[ \left(\frac{\left(\sqrt{\frac{73^2}{12x}}\sqrt{\frac{x|x|}{\log_x}}\right)}{\sqrt[3]{\frac xy}}\right) \]
$$
\left(\frac{\left(\sqrt{\frac{73^2}{12x}}\sqrt{\frac{x|x|}{\log_x}}\right)}{\sqrt[3]{\frac xy}}\right)
$$

System of equations, formulas and functions

Use cases to create systems of equations or functions definitions by cases (piecewise functions).

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

Aligned systems of formulas using \begin{align} and \end{align}

\[ \begin{align} \nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\ \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\ \nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\ \nabla \cdot \vec{\mathbf{B}} & = 0 \end{align} \]
$$
\begin{align}
\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\   \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
\nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
\nabla \cdot \vec{\mathbf{B}} & = 0
\end{align}
$$

In order to create system of quations use \begin{array}, \end{array} together with \left\{ and \right

\[ \left\{ \begin{array}{c} a_1x+b_1y+c_1z=d_1 \\ a_2x+b_2y+c_2z=d_2 \\ a_3x+b_3y+c_3z=d_3 \end{array} \right. \]
$$
\left\{ 
\begin{array}{c}
a_1x+b_1y+c_1z=d_1 \\ 
a_2x+b_2y+c_2z=d_2 \\ 
a_3x+b_3y+c_3z=d_3
\end{array}
\right. 
$$

System of equations

Alternative way to produce system of equations

\[ \begin{cases} a_1x+b_1y+c_1z=d_1 \\ a_2x+b_2y+c_2z=d_2 \\ a_3x+b_3y+c_3z=d_3 \end{cases} \]

To align the = signs use \begin{aligned} and \end{aligned} together with \left\{ and \right

\[ \left\{ \begin{aligned} a_1x+b_1y+c_1z &=d_1+e_1 \\ a_2x+b_2y&=d_2 \\ a_3x+b_3y+c_3z &=d_3 \end{aligned} \right. \]

Use \begin{array}{ll} to align everything left

\[ \left\{ \begin{array}{ll} a_1x+b_1y+c_1z &=d_1+e_1 \\ a_2x+b_2y &=d_2 \\ a_3x+b_3y+c_3z &=d_3 \end{array} \right. \]

Use \\[2ex] to create larger vertical spaces between equations

\[ \begin{cases} a_1x+b_1y+c_1z=\frac{p_1}{q_1} \\[2ex] a_2x+b_2y+c_2z=\frac{p_2}{q_2} \\[2ex] a_3x+b_3y+c_3z=\frac{p_3}{q_3} \end{cases} \]
Alternative way to produce system of equations

$$
\begin{cases}
a_1x+b_1y+c_1z=d_1 \\ 
a_2x+b_2y+c_2z=d_2 \\ 
a_3x+b_3y+c_3z=d_3
\end{cases}
$$

To align the ```=``` signs use ```\begin{aligned}``` and ```\end{aligned}``` together with ```\left\{``` and ```\right```

$$
\left\{
\begin{aligned} 
a_1x+b_1y+c_1z &=d_1+e_1 \\ 
a_2x+b_2y&=d_2 \\ 
a_3x+b_3y+c_3z &=d_3 
\end{aligned} 
\right. 
$$

Use ```\begin{array}{ll}``` to align everything left

$$
\left\{
\begin{array}{ll}
a_1x+b_1y+c_1z &=d_1+e_1 \\ 
a_2x+b_2y &=d_2 \\ 
a_3x+b_3y+c_3z &=d_3 
\end{array} 
\right.
$$

Use ```\\[2ex]``` to create larger vertical spaces between equations

$$
\begin{cases}
a_1x+b_1y+c_1z=\frac{p_1}{q_1} \\[2ex] 
a_2x+b_2y+c_2z=\frac{p_2}{q_2} \\[2ex] 
a_3x+b_3y+c_3z=\frac{p_3}{q_3}
\end{cases}
$$

Matrices

In order to create matrixes use $$\begin{matrix}…\end{matrix}$$, in between the \begin and \end, put the matrix elements. End each matrix row with \\, and separate matrix elements with &

\[ \begin{matrix} 1 & x & x^2 \\ 1 & y & y^2 \\ 1 & z & z^2 \\ \end{matrix} \]
$$
\begin{matrix}
1 & x & x^2 \\
1 & y & y^2 \\
1 & z & z^2 \\
\end{matrix}
$$

Advanced matrix notations

To add brackets use {pmatrix}, {bmatrix}, {Bmatrix}, {vmatrix}.

With {pmatrix}

\[ \begin{pmatrix} 1 & x & x^2 \\ 1 & y & y^2 \\ 1 & z & z^2 \\ \end{pmatrix} \]

With {bmatrix}

\[ \begin{bmatrix} 1 & x & x^2 \\ 1 & y & y^2 \\ 1 & z & z^2 \\ \end{bmatrix} \]

With {Bmatrix}

\[ \begin{Bmatrix} 1 & x & x^2 \\ 1 & y & y^2 \\ 1 & z & z^2 \\ \end{Bmatrix} \]

With {Vmatrix}

\[ \begin{vmatrix} 1 & x & x^2 \\ 1 & y & y^2 \\ 1 & z & z^2 \\ \end{vmatrix} \]

With vertical line

\[ \left[ \begin{array}{cc|c} 1&2&3\\ 4&5&6 \end{array} \right] \]

With horizontal line

\[ \begin{pmatrix} a & b\\ c & d\\ \hline 1 & 0\\ 0 & 1 \end{pmatrix} \]

Use \cdots for , \ddots for and \vdots for when you want to omit some of the entries:

\[ \begin{vmatrix} 1 & x & \cdots & x^2 \\ 1 & y & \cdots & y^2 \\ \vdots & \vdots & \ddots & \vdots \\ 1 & z & \cdots & z^2 \\ \end{vmatrix} \]
To add brackets use ```{pmatrix}```, ```{bmatrix}```, ```{Bmatrix}```, ```{vmatrix}```.

With ```{pmatrix}```

$$
    \begin{pmatrix}
    1 & x & x^2 \\
    1 & y & y^2 \\
    1 & z & z^2 \\
    \end{pmatrix}
$$  

With ```{bmatrix}```

$$
    \begin{bmatrix}
    1 & x & x^2 \\
    1 & y & y^2 \\
    1 & z & z^2 \\
    \end{bmatrix}
$$ 

With ```{Bmatrix}```

$$
    \begin{Bmatrix}
    1 & x & x^2 \\
    1 & y & y^2 \\
    1 & z & z^2 \\
    \end{Bmatrix}
$$  

With ```{Vmatrix}```

$$
    \begin{vmatrix}
    1 & x & x^2 \\
    1 & y & y^2 \\
    1 & z & z^2 \\
    \end{vmatrix}
$$ 

With vertical line

$$ 
\left[
\begin{array}{cc|c}
1&2&3\\
4&5&6
\end{array}
\right] 
$$

With horizontal line

$$
\begin{pmatrix}
    a & b\\
    c & d\\
\hline
    1 & 0\\
    0 & 1
\end{pmatrix}
$$

Use ```\cdots``` for **⋯**, ```\ddots``` for **⋱** and ```\vdots``` for **⋮** when you want to omit some of the entries:

$$
    \begin{vmatrix}
    1 & x & \cdots & x^2 \\
    1 & y & \cdots & y^2 \\
    \vdots & \vdots & \ddots & \vdots \\
    1 & z & \cdots & z^2 \\
    \end{vmatrix}
$$