14 Mathematical formulae - practicalseries/GitHub-Wiki-Design-and-Implementation GitHub Wiki

PAL Logo showing Wiki Documentation heading

14SpacerMathematical formulae

GitHub flavoured Markdown supports the use of mathematical formulae (this was introduced in 2022). These are entered using the TeX and LaTeX💠1 (more LaTeX than TeX).

LaTeX is a programming syntax used to encode a particular formula; it is a plain-text format. This is then interpreted by the JavaScript application MathJax which renders the formula in the correct, visually pleasing, form.

⬆️ Top



14.1SpacerAn overview of LaTex

The following is the LaTeX syntax for the common quadratic equation:

Markdown and GitHub output
${\large \color{#0050C0}\text{M\ A\ R\ K\ D\ O\ W\ N}}$ 🔽

$x=\frac{-b\pm\sqrt{b^2—4ac}}{2a}$

${\large \color{#B00000}\text{G\ I\ T\ H\ U\ B}\space\ \space\text{O\ U\ T\ P\ U\ T}}$ 🔽

$\Large x=\frac{-b\pm\sqrt{b^2—4ac}}{2a}$

Table 14.1 — GitHub Wiki rendering of a mathematical formulae

This rendering is carried out by the MathJax application. It’s pretty good and does an excellent job of rendering equations.

I’ve used MathJax before, in fact I have a website about it here. The thing I liked about MathJax was that it could use AsciiMath💠2.

AsciiMath is quite intuitive to use, this for example, is the quadratic formulae in AsciiMath form (the one we all know from O levels):

   x=(-b +- sqrt(b^2 — 4ac))/(2a)

MathJax would render it as:

${\Large x=\frac{-b\pm\sqrt{b^2—4ac}}{2a}}$

AsciiMath is a bit hard to explain, but at an intuitive level you can see exactly how it works. If you wanted to type that equation as a single line on a computer terminal, I bet you would come up with something similar to the above.

When I found out the GitHub was using MathJax I had high hopes that it could use AsciiMath, but it can’t. It only uses the LaTeX syntax and this is harder to understand, see the next section.

⬆️ Top



14.2SpacerInserting an inline formula

GitHub supports inline equations. Inline equations appear in the middle of a line or paragraph of text.

Inline equations are surrounded by an open dollar sign and left brace ${ and closed with a right brace and a dollar sign }$:

Markdown and GitHub output
${\large \color{#0050C0}\text{M\ A\ R\ K\ D\ O\ W\ N}}$ 🔽

GitHub supports the use of inline formulae; they can be inserted directly into a paragraph of text
and the equation will be given the correct amount of spacing above and below. This is an inline 
formula ${x=\frac{-b\pm\sqrt{b^2—4ac}}{2a}}$, it sits in the middle of a line. The text 
surrounding the equation is normal body text, the equation itself uses a mathematical 
font that forms part of MathJax.

${\large \color{#B00000}\text{G\ I\ T\ H\ U\ B}\space\ \space\text{O\ U\ T\ P\ U\ T}}$ 🔽

GitHub supports the use of inline formulae; they can be inserted directly into a paragraph of text and the equation will be given the correct amount of spacing above and below. This is an inline formula ${x=\frac{-b\pm\sqrt{b^2—4ac}}{2a}}$, it sits in the middle of a line. The text surrounding the equation is normal body text, the equation itself uses a mathematical font that forms part of MathJax.

Table 14.1 — Inline equation

Generally, the use of inline equations should be restricted to single line type equations (${x=b+1}$ for example), these look better. Where more complex equations are used, the difference in line spacing gives an untidy appearance.

⬆️ Top



14.2.1SpacerAlternative delimiter

The normal delimiter for an inline equation is ${...}$ . An alternative is to start the equation with a dollar, backtick ($`) and end it with a backtick dollar (`$).

⬆️ Top



14.3SpacerA formula block

A formula block is an equation that appears outside any text and may span multiple lines:

Markdown and GitHub output
${\large \color{#0050C0}\text{M\ A\ R\ K\ D\ O\ W\ N}}$ 🔽

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

```math
x=\frac{-b\pm\sqrt{b^2—4ad}}{2a}
```
Lorem ipsum dolor sit amet, consectetur adipiscing elit. 

${\large \color{#B00000}\text{G\ I\ T\ H\ U\ B}\space\ \space\text{O\ U\ T\ P\ U\ T}}$ 🔽

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

${x=\frac{-b\pm\sqrt{b^2—4ad}}{2a}}$

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Table 14.2 — Block equation

Alternatively, the equation can be surrounded by a double dollar sign ($$) or the dollar, braces arrangement (${...}$):

Markdown and GitHub output
${\large \color{#0050C0}\text{M\ A\ R\ K\ D\ O\ W\ N}}$ 🔽

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

$$x=\frac{-b\pm\sqrt{b^2—4ad}}{2a}$$

${x=\frac{-b\pm\sqrt{b^2—4ad}}{2a}}$

Lorem ipsum dolor sit amet, consectetur adipiscing elit. 

${\large \color{#B00000}\text{G\ I\ T\ H\ U\ B}\space\ \space\text{O\ U\ T\ P\ U\ T}}$ 🔽

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

$$x=\frac{-b\pm\sqrt{b^2—4ad}}{2a}$$

${x=\frac{-b\pm\sqrt{b^2—4ad}}{2a}}$

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Table 14.3 — Block equation alternative

Both do exactly the same thing.

Important

Block equations must have a blank line above and below.

⬆️ Top



14.4SpacerSome example formulae

The following section gives some insights into the LaTeX equation syntax, this section has several examples of the types of equations that are possible:

${\large \color{#0050C0}\text{M\ A\ R\ K\ D\ O\ W\ N}}$ 🔽 ${\large \color{#B00000}\text{G\ I\ T\ H\ U\ B}\space\ \space\text{O\ U\ T\ P\ U\ T}}$ 🔽

```math
f(x)=(x+a)(x+b)
```


$$f(x)=(x+a)(x+b)$$
```math
\cos(2\theta\phi) = \cos^2 \theta\phi - \sin^2 \theta\phi
```


$$\cos(2\theta\phi) = \cos^2 \theta\phi - \sin^2 \theta\phi$$
```math
(a+b)\left[1-\frac{b}{a+b}\right]=a
```


$$(a+b)\left[1-\frac{b}{a+b}\right]=a$$
```math
\int_a^bu\frac{d^2v}{dx^2}\,dx
=\left.u\frac{dv}{dx}\right|_a^b
-\int_a^b\frac{du}{dx}\frac{dv}{dx}\,dx
```


$$\int_a^bu\frac{d^2v}{dx^2}\,dx =\left.u\frac{dv}{dx}\right|_a^b -\int_a^b\frac{du}{dx}\frac{dv}{dx}\,dx$$
```math
\tilde f(\omega)=\frac{1}{2\pi}
\int_{-\infty}^\infty f(x)e^{-i\omega x}\,dx
```


$$\tilde f(\omega)=\frac{1}{2\pi} \int_{-\infty}^\infty f(x)e^{-i\omega x}\,dx$$
```math
x = a_0 + \frac{1}{a_1 + \frac{1}{a_2 + \frac{1}{a_3 + a_4}}}
```


$$x = a_0 + \frac{1}{a_1 + \frac{1}{a_2 + \frac{1}{a_3 + a_4}}}$$
```math
x = a_0 + \frac{1}{\displaystyle a_1
+ \frac{1}{\displaystyle a_2
+ \fr
```


$$x = a_0 + \frac{1}{\displaystyle a_1 + \frac{1}{\displaystyle a_2 + \frac{1}{\displaystyle a_3 + a_4}}}$$
```math
\begin{bmatrix}
1 & x & 0 \\
0 & 1 & -1
\end{bmatrix}\begin{bmatrix}
1 \\
y \\
1
\end{bmatrix}
=\begin{bmatrix}
1+xy \\
y-1
\end{bmatrix}
```





$$\begin{bmatrix} 1 & x & 0 \\\ 0 & 1 & -1 \end{bmatrix}\begin{bmatrix} 1 \\\ y \\\ 1 \end{bmatrix} =\begin{bmatrix} 1+xy \\\ y-1 \end{bmatrix}$$
```math
\begin{pmatrix}
2 & 3 & 4\\
5 & 6 & 7\\
8 & 9 & 10 \end{pmatrix} v = 0
```



$$\begin{pmatrix} 2 & 3 & 4\\\ 5 & 6 & 7\\\ 8 & 9 & 10 \end{pmatrix} v = 0$$
```math
\begin{matrix}
-2 & 1 & 0 & 0 & \cdots & 0 \\
1 & -2 & 1 & 0 & \cdots & 0 \\
0 & 1 & -2 & 1 & \cdots & 0 \\
0 & 0 & 1 & -2 & \ddots & \vdots \\
\vdots & \vdots & \vdots & \ddots & \ddots & 1 \\
0 & 0 & 0 & \cdots & 1 & -2
\end{matrix}
```



$$\begin{matrix} -2 & 1 & 0 & 0 & \cdots & 0 \\\ 1 & -2 & 1 & 0 & \cdots & 0 \\\ 0 & 1 & -2 & 1 & \cdots & 0 \\\ 0 & 0 & 1 & -2 & \ddots & \vdots \\\ \vdots & \vdots & \vdots & \ddots & \ddots & 1 \\\ 0 & 0 & 0 & \cdots & 1 & -2 \end{matrix}$$
```math
|x|=\begin{cases}
x, & \text{if }x\geq 0 \\
-x, & \text{if }x< 0
\end{cases}
```



$$|x|=\begin{cases} x, & \text{if }x\geq 0 \\\ -x, & \text{if }x< 0 \end{cases}$$
```math
(1+x)^n = \sum_{i=0}^n {n \choose i} x^i
```

$$(1+x)^n = \sum_{i=0}^n {n \choose i} x^i$$
```math
e^x = 1 + x + \frac{x^2}{2} + \cdots = \sum_{n\geq 0} \frac{x^n}{n!}
```


$$e^x = 1 + x + \frac{x^2}{2} + \cdots = \sum_{n\geq 0} \frac{x^n}{n!}$$
```math
\frac{n!}{k!(n-k)!} = \binom{n}{k}
```


$$\frac{n!}{k!(n-k)!} = \binom{n}{k}$$
```math
e^x = 1 + x + \frac{x^2}{2} + \cdots = \sum_{n\geq 0} \frac{x^n}{n!}
```


$$e^x = 1 + x + \frac{x^2}{2} + \cdots = \sum_{n\geq 0} \frac{x^n}{n!}$$
Table 14.4 — Example equations


⬆️ Top



14.5SpacerLaTeX syntax

LaTeX isn’t quite as intuitive as AsciiMath, but the more you use it, the more you begin to understand it.

LaTeX uses some mathematical operators: +, -, =, and brackets and parenthesis [], () directly, just by typing them on a keyboard. Other things are entered as commands: \sqrt these always start with a backslash character.

Some commands have arguments, these are encompassed in braces {}. For example the fraction is in the form:

```math
\frac{a}{a+b}
```


$$\frac{a}{a+b}$$

Everything in the first pair of braces is numerator (top of the fraction) and everything in the second pair of braces is the denominator (bottom of the fraction).

Brackets and parenthesis do not by default expand vertically to encompass whatever is inside them:

```math
x=(1-\frac{a}{b})
```


$$x=(1-\frac{a}{b})$$

Here, the parentheses remain small and the fraction extends above and below it.

To make brackets and parenthesis resize, precede the left bracket/parenthesis with \left and the right bracket/parenthesis with \right:

```math
x=\left(1-\frac{a}{b}\right)
```


$$x=\left(1-\frac{a}{b}\right)$$

To use braces (instead of brackets or parentheses), precede the brace with a backslash:

```math
x=\{1-\frac{a}{b}\}
```


$$x=\{1-\frac{a}{b}\}$$

\left and \right: work in the same way as before:

```math
x=\left\{1-\frac{a}{b}\right\}
```


$$x=\left\{1-\frac{a}{b}\right\}$$

Various characters (Greek characters, symbols &c.) have their own commands:

```math
\tau\epsilon\chi
```



$$\tau\epsilon\chi$$

Superscript characters are preceded with ^ and subscript with _. Thes can also be used for limits on operators:

```math
a^b
```



$$a^b$$
```math
a_b
```



$$a_b$$

With limits, it is like this:

```math
\sum_{n=1}^{\infty}
```


$$\sum_{n=1}^{\infty}$$
```math
\int_{0}^{\infty}
```


$$\int_{0}^{\infty}$$

The braces are not always required, but where multiple limit (or super/subscript) terms are used, it is best to put the braces around everything that should be a limit or super/subscript.

The following tables summarise all the LaTeX commands:

14.5.1SpacerGreek lowercase

Sym Command Sym Command Sym Command Sym Command
$$\alpha$$ \alpha $$\gamma$$ \gamma $$\omega$$ \omega $$\sigma$$ \sigma
$$\beta$$ \beta $$\iota$$ \iota $$\phi$$ \phi $$\tau$$ \tau
$$\chi$$ \chi $$\kappa$$ \kappa $$\varphi$$ \varphi $$\theta$$ \theta
$$\delta$$ \delta $$\lambda$$ \lambda $$\pi$$ \pi $$\upsilon$$ \upsilon
$$\epsilon$$ \epsilon $$\mu$$ \mu $$\psi$$ \psi $$\xi$$ \xi
$$\eta$$ \eta $$\nu$$ \nu $$\rho$$ \rho $$\zeta$$ \zeta



14.5.2SpacerGreek uppercase, variations and Hebrew

Sym Command Sym Command Sym Command Sym Command
$$\Delta$$ \Delta $$\Psi$$ \Psi $$\varepsilon$$ \varepsilon $$\aleph$$ \aleph
$$\Gamma$$ \Gamma $$\Sigma$$ \Sigma $$\varkappa$$ \varkappa $$\beth$$ \beth
$$\Lambda$$ \Lambda $$\Theta$$ \Theta $$\Phi$$ \Phi $$\daleth$$ \daleth
$$\Omega$$ \Omega $$\Upsilon$$ \Upsilon $$\Pi$$ \Pi $$\gimel$$ \gimel
$$\Xi$$ \Xi $$\vartheta$$ \vartheta $$\varepsilon$$ \varepsilon



14.5.3SpacerMathematical constructions

Sym Command Sym Command Sym Command
$$\frac{abc}{xyz}$$ \frac{abc}{xyz} $$\overline{abc}$$ \overline{abc} $$\overrightarrow{abc}$$ \overrightarrow{abc}
$$f’$$ f’ $$\underline{abc}$$ \underline{abc} $$\overleftarrow{abc}$$ \overleftarrow{abc}
$$\sqrt{abc}$$ \sqrt{abc} $$\widehat{abc}$$ \widehat{abc} $$\overbrace{abc}$$ \overbrace{abc}
$$\sqrt[n]{abc}$$ \sqrt[n]{abc} $$\widetilde{abc}$$ \widetilde{abc} $$\underbrace{abc}$$ \underbrace{abc}



14.5.4SpacerVariable sized delimiters

Sym Command Sym Command Sym Command Sym Command
$$|$$ | $$\{$$ \{ $$\Uparrow$$ \Uparrow $$/$$ /
$$\vert$$ \vert $$\}$$ \} $$\uparrow$$ \uparrow $$\backslash$$ \backslash
$$\Vert$$ \Vert $$\langle$$ \langle $$\Downarrow$$ \Downarrow
$$($$ ( $$\rangle$$ \rangle $$\downarrow$$ \downarrow
$$)$$ ) $$\lfloor$$ \lfloor $$\llcorner$$ \llcorner
$$[$$ [ $$\rfloor$$ \rfloor $$\lrcorner$$ \lrcorner
$$]$$ ] $$\lceil$$ \lceil $$\llcorner$$ \ulcorner
$$\rceil$$ \rceil $$\urcorner$$ \urcorner

Precede the first delimiter with \left and last delimiter with \right to match the height of their content (note \left and \right must be paired). E.g.:

Sym Command Sym Command
$$\left(1-\frac{a}{b}\right)$$ \left(1-\frac{a}{b}\right) $$\left[1-\frac{a}{b}\right]$$ \left[1-\frac{a}{b}\right]



14.5.5SpacerVariable sized symbols

Sym Command Sym Command
$$\sum$$ \sum $$\biguplus$$ \biguplus
$$\prod$$ \prod $$\bigcap$$ \bigcap
$$\coprod$$ \coprod $$\bigcup$$ \bigcup
$$\int$$ \int $$\bigoplus$$ \bigoplus
$$\oint$$ \oint $$\bigotimes$$ \bigotimes
$$\iint$$ \iint $$\bigodot$$ \bigodot
$$\iiint$$ \iiint $$\bigvee$$ \bigvee
$$\lim$$ \lim $$\bigwedge$$ \bigwedge



14.5.6SpacerVariable sized symbols with limits

Sym Command Sym Command
$$\sum_{def}^{abc}x_y^z$$ \sum_{def}^{abc}x_y^z $$\biguplus_{n=1}^{10}A_n$$ \biguplus_{n=1}^{10}A_n
$$\prod_{def}^{abc} x_y^z$$ \prod_{def}^{abc} x_y^z $$\bigcap_{n=1}^{10}A_n$$ \bigcap_{n=1}^{10}A_n
$$\coprod_{n=1}^{\infty} x_y^z$$ \coprod_{n=1}^{\infty} x_y^z $$\bigcup_{n=1}^{10}A_n$$ \bigcup_{n=1}^{10}A_n
$$\int_{0}^{\infty} x^2 dx$$ \int_{0}^{\infty} x^2 dx $$\bigoplus_{b\epsilon B}R_b$$ \bigoplus_{b\epsilon B}R_b
$$\oint_{c_1} \frac{-y}{x^2 +y^2}dr$$ \oint_{c_1} \frac{-y}{x^2 +y^2}dr $$\bigotimes_{b\epsilon B}R_b$$ \bigotimes_{b\epsilon B}R_b
$$\iint_{w}^{k} dV$$ \iint_{w}^{k} dV $$\bigodot_{b\epsilon B}R_b$$ \bigodot_{b\epsilon B}R_b
$$\iiint_{w}^{k} dV$$ \iiint_{w}^{k} dV $$\bigvee_{n=1}^{10}A_n$$ \bigvee_{n=1}^{10}A_n
$$\lim_{x\to \infty} x^2$$ \lim_{x\to \infty} x^2 $$\bigwedge_{n=1}^{10}A_n$$ \bigwedge_{n=1}^{10}A_n



14.5.7SpacerStandard functions

Sym Command Sym Command Sym Command Sym Command
$$\arccos$$ \arccos $$\arcsin$$ \arcsin $$\arctan$$ \arctan $$\arg$$ \arg
$$\cos$$ \cos $$\cosh$$ \cosh $$\cot$$ \cot $$\coth$$ \coth
$$\csc$$ \csc $$\deg$$ \deg $$\det$$ \det $$\dim$$ \dim
$$\exp$$ \exp $$\gcd$$ \gcd $$\hom$$ \hom $$\inf$$ \inf
$$\ker$$ \ker $$\lg$$ \lg $$\lim$$ \lim $$\liminf$$ liminf
$$\limsup$$ \limsup $$\ln$$ \ln $$\log$$ \log $$\max$$ \max
$$\min$$ \min $$\Pr$$ \Pr $$\sec$$ \sec $$\sin$$ \sin
$$\sinh$$ \sinh $$\sup$$ \sup $$\tan$$ \tan $$\tanh$$ \tanh

Standard functions should appear as Roman regular characters, not italics.


14.5.8SpacerOperators and relational symbols

Sym Command Sym Command Sym Command Sym Command
$$\ast$$ \ast $$\pm$$ \pm $$\cap$$ \cap $$\lhd$$ \lhd
$$\star$$ \aaa $$\mp$$ \mp $$\cup$$ \cup $$\rhd$$ \rhd
$$\cdot$$ \cdot $$\amalg$$ \amalg $$\uplus$$ \uplus $$\triangleleft$$ \triangleleft
$$\circ$$ \circ $$\odot$$ \odot $$\sqcap$$ \sqcap $$\triangleright$$ \triangleright
$$\bullet$$ \bullet $$\ominus$$ \ominus $$\sqcup$$ \sqcup $$\unlhd$$ \unlhd
$$\bigcirc$$ \bigcirc $$\oplus$$ \oplus $$\wedge$$ \wedge $$\unrhd$$ \unrhd
$$\diamond$$ \diamond $$\oslash$$ \oslash $$\vee$$ \vee $$\bigtriangledown$$ \bigtriangledown
$$\times$$ \times $$\otimes$$ \otimes $$\dagger$$ \dagger $$\bigtriangleup$$ \bigtriangleup
$$\div$$ \div $$\wr$$ \wr $$\ddagger$$ \ddagger $$\setminus$$ \setminus
$$\centerdot$$ \centerdot $$\Box$$ \Box $$\barwedge$$ \barwedge $$\veebar$$ \veebar
$$\circledast$$ \circledast $$\boxplus$$ \boxplus $$\curlywedge$$ \curlywedge $$\curlyvee$$ \curlyvee
$$\circledcirc$$ \circledcirc $$\boxminus$$ \boxminus $$\Cap$$ \Cap $$\Cup$$ \Cup
$$\circleddash$$ \circleddash $$\boxtimes$$ \boxtimes $$\bot$$ \bot $$\top$$ \top
$$\dotplus$$ \dotplus $$\boxdot$$ \boxdot $$\intercal$$ \intercal $$\rightthreetimes$$ \rightthreetimes
$$\divideontimes$$ \divideontimes $$\square$$ \square $$\doublebarwedge$$ \doublebarwedge $$\leftthreetimes$$ \leftthreetimes



Sym Command Sym Command Sym Command Sym Command
$$\equiv$$ \equiv $$\leq$$ \leq $$\geq$$ \geq $$\perp$$ \perp
$$\cong$$ \cong $$\prec$$ \prec $$\succ$$ \succ $$\mid$$ \mid
$$\neq$$ \neq $$\preceq$$ \preceq $$\succeq$$ \succeq $$\parallel$$ \parallel
$$\sim$$ \sim $$\ll$$ \ll $$\gg$$ \gg $$\bowtie$$ \bowtie
$$\simeq$$ \simeq $$\subset$$ \subset $$\supset$$ \supset $$\Join$$ \Join
$$\approx$$ \approx $$\subseteq$$ \subseteq $$\supseteq$$ \supseteq $$\ltimes$$ \ltimes
$$\asymp$$ \asymp $$\sqsubset$$ \sqsubset $$\sqsupset$$ \sqsupset $$\rtimes$$ \rtimes
$$\doteq$$ \doteq $$\sqsubseteq$$ \sqsubseteq $$\sqsupseteq$$ \sqsupseteq $$\smile$$ \smile
$$\propto$$ \propto $$\dashv$$ \dashv $$\vdash$$ \vdash $$\frown$$ \frown
$$\models$$ \models $$\in$$ \in $$\ni$$ \ni $$\notin$$ \notin



Sym Command Sym Command Sym Command Sym Command
$$\approxeq$$ \approxeq $$\leqq$$ \leqq $$\geqq$$ \geqq $$\lessgtr$$ \lessgtr
$$\thicksim$$ \thicksim $$\leqslant$$ \leqslant $$\geqslant$$ \geqslantcc $$\lesseqgtr$$ \lesseqgtr
$$\backsim$$ \backsim $$\lessapprox$$ \lessapprox $$\gtrapprox$$ \gtrapprox $$\lesseqqgtr$$ \lesseqqgtr
$$\backsimeq$$ \backsimeq $$\lll$$ \lll $$\ggg$$ \ggg $$\gtreqqless$$ \gtreqqless
$$\triangleq$$ \triangleq $$\lessdot$$ \lessdot $$\gtrdot$$ \gtrdot $$\gtreqless$$ \gtreqless
$$\circeq$$ \circeq $$\lesssim$$ \lesssim $$\gtrsim$$ \gtrsim $$\gtrless$$ \gtrless
$$\bumpeq$$ \bumpeq $$\eqslantless$$ \eqslantless $$\eqslantgtr$$ \eqslantgtr $$\backepsilon$$ \backepsilon
$$\Bumpeq$$ \Bumpeq $$\precsim$$ \precsim $$\succsim$$ \succsim $$\between$$ \between
$$\doteqdot$$ \doteqdot $$\precapprox$$ \precapprox $$\succapprox$$ \succapprox $$\pitchfork$$ \pitchfork
$$\thickapprox$$ \thickapprox $$\Subset$$ \Subset $$\Supset$$ \Supset $$\shortmid$$ \shortmid
$$\fallingdotseq$$ \fallingdotseq $$\subseteqq$$ \subseteqq $$\supseteqq$$ \csupseteqqcc $$\smallfrown$$ \smallfrown
$$\risingdotseq$$ \risingdotseq $$\sqsubset$$ \sqsubset $$\sqsupset$$ \sqsupset $$\smallsmile$$ \smallsmile
$$\varpropto$$ \varpropto $$\preccurlyeq$$ \preccurlyeq $$\succcurlyeq$$ \succcurlyeq $$\Vdash$$ \Vdash
$$\therefore$$ \therefore $$\curlyeqprec$$ \curlyeqprec $$\curlyeqsucc$$ \curlyeqsucc $$\vDash$$ \vDash
$$\because$$ \because $$\blacktriangleleft$$ \blacktriangleleft $$\blacktriangleright$$ \blacktriangleright $$\Vvdash$$ \Vvdash
$$\eqcirc$$ \eqcirc $$\trianglelefteq$$ \trianglelefteq $$\trianglerighteq$$ \trianglerighteq $$\shortparallel$$ \shortparallel
$$\neq$$ \neq $$\vartriangleleft$$ \vartriangleleft $$\vartriangleright$$ \vartriangleright $$\nshortparallel$$ \nshortparallel



Sym Command Sym Command Sym Command Sym Command
$$\ncong$$ \ncong $$\nleq$$ \nleq $$\ngeq$$ \ngeq $$\nsubseteq$$ \nsubseteq
$$\nmid$$ \nmid $$\nleqq$$ \nleqq $$\ngeqq$$ \ngeqq $$\nsupseteq$$ \nsupseteq
$$\nparallel$$ \nparallel $$\nleqslant$$ \nleqslant $$\ngeqslant$$ \ngeqslant $$\nsubseteqq$$ \nsubseteqq
$$\nshortmid$$ \nshortmid $$\nless$$ \nless $$\ngtr$$ \ngtr $$\nsupseteqq$$ \nsupseteqq
$$\nshortparallel$$ \nshortparallel $$\nprec$$ \nprec $$\nsucc$$ \nsucc $$\subsetneq$$ \subsetneq
$$\nsim$$ \nsim $$\npreceq$$ \npreceq $$\nsucceq$$ \nsucceq $$\supsetneq$$ \supsetneq
$$\nVDash$$ \nVDash $$\precnapprox$$ \precnapprox $$\succnapprox$$ \succnapprox $$\subsetneqq$$ \subsetneqq
$$\nvDash$$ \nvDash $$\precnsim$$ \precnsim $$\succnsim$$ \succnsim $$\supsetneqq$$ \supsetneqq
$$\nvdash$$ \nvdash $$\lnapprox$$ \lnapprox $$\gnapprox$$ \gnapprox $$\varsubsetneq$$ \varsubsetneq
$$\ntriangleleft$$ \ntriangleleft $$\lneq$$ \lneq $$\gneq$$ \gneq $$\varsupsetneq$$ \varsupsetneq
$$\ntrianglelefteq$$ \ntrianglelefteq $$\lneqq$$ \lneqq $$\gneqq$$ \gneqq $$\varsubsetneqq$$ \varsubsetneqq
$$\ntriangleright$$ \ntriangleright $$\lnsim$$ \lnsim $$\gnsim$$ \gnsim $$\varsupsetneqq$$ \varsupsetneqq
$$\ntrianglerighteq$$ \ntrianglerighteq $$\lvertneqq$$ \blvertneqqbb $$\gvertneqq$$ \gvertneqq



14.5.9SpacerArrows

Sym Command Sym Command Sym Command
$$\leftarrow$$ \leftarrow $$\longleftarrow$$ \longleftarrow $$\uparrow$$ \uparrow
$$\Leftarrow$$ \Leftarrow $$\Longleftarrow$$ \Longleftarrow $$\Uparrow$$ \Uparrow
$$\rightarrow$$ \rightarrow $$\longrightarrow$$ \longrightarrow $$\downarrow$$ \downarrow
$$\Rightarrow$$ \Rightarrow $$\Longrightarrow$$ \Longrightarrow $$\Downarrow$$ \Downarrow
$$\leftrightarrow$$ \leftrightarrow $$\longleftrightarrow$$ \longleftrightarrow $$\updownarrow$$ \updownarrow



Sym Command Sym Command Sym Command
$$\mapsto$$ \mapsto $$\longmapsto$$ \longmapsto $$\nearrow$$ \nearrow
$$\hookleftarrow$$ \hookleftarrow $$\hookrightarrow$$ \hookrightarrow $$\searrow$$ \searrow
$$\leftharpoonup$$ \leftharpoonup $$\rightharpoonup$$ \rightharpoonup $$\swarrow$$ \swarrow
$$\leftharpoondown$$ \leftharpoondown $$\rightharpoondown$$ \rightharpoondown $$\nwarrow$$ \nwarrow
$$\rightleftharpoons$$ \rightleftharpoons



Sym Command Sym Command Sym Command
$$\dashrightarrow$$ \dashrightarrow $$\dashleftarrow$$ \dashleftarrow $$\leftleftarrows$$ \leftleftarrows
$$\leftrightarrows$$ \leftrightarrows $$\Lleftarrow$$ \Lleftarrow $$\twoheadleftarrow$$ \twoheadleftarrow
$$\leftarrowtail$$ \leftarrowtail $$\looparrowleft$$ \looparrowleft $$\leftrightharpoons$$ \leftrightharpoons
$$\curvearrowleft$$ \curvearrowleft $$\circlearrowleft$$ \circlearrowleft $$\Lsh$$ \Lsh
$$\upuparrows$$ \upuparrows $$\upharpoonleft$$ \upharpoonleft $$\downharpoonleft$$ \downharpoonleft
$$\multimap$$ \multimap $$\leftrightsquigarrow$$ \leftrightsquigarrow $$\rightrightarrows$$ \rightrightarrows
$$\rightleftarrows$$ \rightleftarrows $$\rightrightarrows$$ \rightrightarrows $$\rightleftarrows$$ \rightleftarrows
$$\twoheadrightarrow$$ \twoheadrightarrow $$\rightarrowtail$$ \rightarrowtail $$\looparrowright$$ \looparrowright
$$\rightleftharpoons$$ \rightleftharpoons $$\curvearrowright$$ \curvearrowright $$\circlearrowright$$ \circlearrowright
$$\Rsh$$ \Rsh $$\downdownarrows$$ \downdownarrows $$\upharpoonright$$ \upharpoonright
$$\downharpoonright$$ \downharpoonright $$\rightsquigarrow$$ \rightsquigarrow



Sym Command Sym Command Sym Command
$$\nleftarrow$$ \nleftarrow $$\nrightarrow$$ \nrightarrow $$\nLeftarrow$$ \nLeftarrow
$$\nRightarrow$$ \nRightarrow $$\nleftrightarrow$$ \nleftrightarrow $$\nLeftrightarrow$$ \nLeftrightarrow



14.5.10SpacerOther symbols

Sym Command Sym Command Sym Command Sym Command
$$\infty$$ \infty $$\forall$$ \forall $$\Diamond$$ \Diamond $$\complement$$ \complement
$$\nabla$$ \nabla $$\exists$$ \exists $$\Finv$$ \Finv $$\triangledown$$ \dtriangledowndd
$$\partial$$ \partial $$\nexists$$ \nexists $$\triangle$$ \triangle
$$\eth$$ \eth $$\emptyset$$ \emptyset $$\hbar$$ \hbar $$\vartriangle$$ \vartriangle
$$\clubsuit$$ \clubsuit $$\varnothing$$ \varnothing $$\hslash$$ \hslash $$\blacklozenge$$ \blacklozenge
$$\diamondsuit$$ \diamondsuit $$\imath$$ \imath $$\lozenge$$ \lozenge $$\blacksquare$$ \blacksquare
$$\heartsuit$$ \heartsuit $$\jmath$$ \jmath $$\mho$$ \mho $$\blacktriangle$$ \blacktriangle
$$\spadesuit$$ \spadesuit $$\ell$$ \ell $$\prime$$ \prime
$$\cdots$$ \cdots $$\sharp$$ \sharp $$\square$$ \square $$\backprime$$ \backprime
$$\vdots$$ \vdots $$\flat$$ \flat $$\surd$$ \surd $$\circledS$$ \circledS
$$\ldots$$ \ldots $$\natural$$ \natural $$\wp$$ \wp $$\measuredangle$$ \measuredangle
$$\Im$$ \Im $$\Re$$ \Re $$\diagdown$$ \diagdown $$\diagup$$ \diagup



14.5.11SpacerAccents

Sym Command Sym Command Sym Command Sym Command
$$\acute{a}$$ \acute{a} $$\bar{a}$$ \bar{a} $$\breve{a}$$ \breve{a} $$\check{a}$$ \check{a}
$$\ddot{a}$$ \ddot{a} $$\dot{a}$$ \dot{a} $$\grave{a}$$ \grave{a} $$\hat{a}$$ \hat{a}
$$\tilde{a}$$ \atilde{a}aa $$\vec{a}$$ \vec{a}



14.5.12SpacerMatrices

Matrices can be generated using the \begin{xmatrix} command where x defines the type of delimiter used.

Following the command, columns are separated by the & character and a new row follows a double backslash character \\.

The following are some examples (in each case the x character preceding matrix changes):

${\large \color{#00C050}\text{D\ E\ S\ C\ R\ I\ P\ T\ I\ O\ N}}$ 🔽 ${\large \color{#0050C0}\text{M\ A\ R\ K\ D\ O\ W\ N}}$ 🔽 ${\large \color{#B00000}\text{G\ I\ T\ H\ U\ B}\space\ \space\text{O\ U\ T\ P\ U\ T}}$ 🔽

No delimiter
```math
\begin{matrix}
1 & 2 & 3\\
a & b & c
\end{matrix}
```




$$\begin{matrix} 1 & 2 & 3\\\ a & b & c \end{matrix}$$
Parentheses
```math
\begin{pmatrix}
1 & 2 & 3\\
a & b & c
\end{pmatrix}
```




$$\begin{pmatrix} 1 & 2 & 3\\\ a & b & c \end{pmatrix}$$
Brackets
```math
\begin{bmatrix}
1 & 2 & 3\\
a & b & c
\end{bmatrix}
```




$$\begin{bmatrix} 1 & 2 & 3\\\ a & b & c \end{bmatrix}$$
Braces
```math
\begin{Bmatrix}
1 & 2 & 3\\
a & b & c
\end{Bmatrix}
```




$$\begin{Bmatrix} 1 & 2 & 3\\\ a & b & c \end{Bmatrix}$$
Pipes
```math
\begin{vmatrix}
1 & 2 & 3\\
a & b & c
\end{vmatrix}
```




$$\begin{vmatrix} 1 & 2 & 3\\\ a & b & c \end{vmatrix}$$
Double pipes
```math
\begin{Vmatrix}
1 & 2 & 3\\
a & b & c
\end{Vmatrix}
```




$$\begin{Vmatrix} 1 & 2 & 3\\\ a & b & c \end{Vmatrix}$$
Left and right ceiling delimiters
(these use a plain matrix
inside the specified delimiter)
```math
\left\lceil
\begin{matrix}
1 & 2 & 3\\
a & b & c
\end{matrix}
\right\rceil
```




$$\left\lceil \begin{matrix} 1 & 2 & 3\\\ a & b & c \end{matrix} \right\rceil$$
Different delimiters either side
```math
\left\langle
\begin{matrix}
1 & 2 & 3\\
a & b & c
\end{matrix}
\right\rangle
```




$$\left\langle \begin{matrix} 1 & 2 & 3\\\ a & b & c \end{matrix} \right\rangle$$

Matrices automatically align the columns where the content is wider:

Different column widths
```math
\begin{pmatrix}
111 & 2 & 3\\
a & b & ccc
\end{pmatrix}
```




$$\begin{pmatrix} 111 & 2 & 3\\\ a & b & ccc \end{pmatrix}$$
Table 14.5 — Matrices





14.5.13SpacerCases

Cases are a variation of matrices; they are often referred to as a piecewise function and consist of a left brace containing the results that occur under specific conditions. Cases are generated using the \begin{cases} command.

Following the command, columns are separated by the & character and a new row follows a double backslash character \\.

${\large \color{#00C050}\text{D\ E\ S\ C\ R\ I\ P\ T\ I\ O\ N}}$ 🔽 ${\large \color{#0050C0}\text{M\ A\ R\ K\ D\ O\ W\ N}}$ 🔽 ${\large \color{#B00000}\text{G\ I\ T\ H\ U\ B}\space\ \space\text{O\ U\ T\ P\ U\ T}}$ 🔽

Typical case
```math
x=\begin{cases}
x, & \text{if }x\geq 0 \\
0, & \text{if }x< 0
\end{cases}
```



$$x=\begin{cases} x, & \text{if }x\geq 0 \\\ 0, & \text{if }x< 0 \end{cases}$$
Table 14.6 — Cases


The \text{} command is used to render the text between the braces literally (see Text formatting — the text command section for details).




Aligning multiple equations     

The \begin{align} command will align multiple equations at the & sign, the & can be inserted anywhere in the equation (usually before the equals sign).

The equations for each line are separated by the double backslash character \\.

${\large \color{#00C050}\text{D\ E\ S\ C\ R\ I\ P\ T\ I\ O\ N}}$ 🔽 ${\large \color{#0050C0}\text{M\ A\ R\ K\ D\ O\ W\ N}}$ 🔽 ${\large \color{#B00000}\text{G\ I\ T\ H\ U\ B}\space\ \space\text{O\ U\ T\ P\ U\ T}}$ 🔽

Equation alignment
```math
\begin{align} 
x - 5y &= 8 \\ 
3x + 9y &= -12
\end{align}
```



$$\begin{align} x - 5y &= 8 \\ 3x + 9y &= -12 \end{align}$$
Table 14.7 — Aligning multiple equations





14.5.14SpacerText formatting

LaTeX is a typsetting language and supports various text formatting operations, these are discussed below:

Font size     

LaTeX supports different font sizes, some are general sizes (large, tiny &c.) and some are mathematical formula sizes (these all end with the word style). GitHub is a bit inconsistent in how these render (some are just duplicates of others).

To change the font size, use the command below, everything following the command will be at the size specified. The point sizes are those generated by GitHub in the main body text area:

${\large \color{#0050C0}\text{M\ A\ R\ K\ D\ O\ W\ N}}$ 🔽 ${\large \color{#00C050}\text{P\ O\ I\ N\ T}\space\ \space\text{S\ I\ Z\ E}}$ 🔽 ${\large \color{#B00000}\text{G\ I\ T\ H\ U\ B}\space\ \space\text{O\ U\ T\ P\ U\ T}}$ 🔽
\scriptscriptstyle 9.60 ${\scriptscriptstyle \text{Lorem\ ipsum}}$
\tiny 11.31 ${\tiny \text{Lorem\ ipsum}}$
\scriptsize 11.31 ${\scriptsize \text{Lorem\ ipsum}}$
\scriptstyle 11.68 ${\scriptstyle \text{Lorem\ ipsum}}$
\small 13.60 ${\small \text{Lorem\ ipsum}}$
\normalsize 16.00 ${\normalsize \text{Lorem\ ipsum}}$
\textstyle 16.00 ${\textstyle \text{Lorem\ ipsum}}$
\displaystyle 16.00 ${\displaystyle \text{Lorem\ ipsum}}$
\large 19.20 ${\large \text{Lorem\ ipsum}}$
\Large 23.04 ${\Large \text{Lorem\ ipsum}}$
\huge 23.04 ${\huge \text{Lorem\ ipsum}}$
\Huge 23.04 ${\Huge \text{Lorem\ ipsum}}$
Table 14.8 — LaTeX text formatting, point size




Font colour     

The \color{} command can be used to change the colour of any text that follows.

It is fairly flexible in its approach, it can use pre-named colours, RGB hex colours, RGB decimal colours, RGBA with transparency, HSL colours and HSLA with transparency.

Once invoked, everything that follows the closing brace will be in the specified colour:

Sym Command
${\color{red}EXAMPLE}$ \color{red}EXAMPLE
${\color{blue}EXAMPLE}$ \color{blue}EXAMPLE
${\color{#446FBD}EXAMPLE}$ \color{#446FBD}EXAMPLE
${\color{rgb(255,0,0)}EXAMPLE}$ \color{rgb(255,0,0)}EXAMPLE
${\color{rgba(0,255,0, 0.5)}EXAMPLE}$ \color{rgba(0,255,0, 0.5)}EXAMPLE
${\color{hsl(100%,0,0)}EXAMPLE}$ \color{hsl(100%,0,0)}EXAMPLE
${\color{hsla(120, 100%, 50%, 0.5)}EXAMPLE}$ \color{hsla(120, 100%, 50%, 0.5)}EXAMPLE
Table 14.9 — LaTeX text formatting, colours

The predefined colours are:

Colour Name RGB Hex
${\color{black}\text{EXAMPLE}}$ black 0,0,0 #000000
${\color{blue}\text{EXAMPLE}}$ blue 0,0,255 #0000FF
${\color{brown}\text{EXAMPLE}}$ brown 191,248,64 #BF8040
${\color{cyan}\text{EXAMPLE}}$ cyan 0,185,224 #00B9F2
${\color{darkgrey}\text{EXAMPLE}}$ darkgrey 64,64,64 #404040
${\color{gray}\text{EXAMPLE}}$ gray 156,156,156 #9C9C9C
${\color{green}\text{EXAMPLE}}$ green 0,255,0 #00FF00
${\color{lightgrey}\text{EXAMPLE}}$ lightgrey 191,191,191 #BFBFBF
${\color{lime}\text{EXAMPLE}}$ lime 191,255,0 #BFFF00
${\color{magenta}\text{EXAMPLE}}$ magenta 251,49,153 #FB3199
${\color{olive}\text{EXAMPLE}}$ olive 159,140,24 #9F8C18
${\color{orange}\text{EXAMPLE}}$ orange 255,128,0 #FF8000
${\color{pink}\text{EXAMPLE}}$ pink 255,191,191 #FFBFBF
${\color{purple}\text{EXAMPLE}}$ purple 191,0,64 #BF0040
${\color{red}\text{EXAMPLE}}$ red 255,0,0 #FF0000
${\color{teal}\text{EXAMPLE}}$ teal 0,128,128 #008080
${\color{violet}\text{EXAMPLE}}$ violet 128,0,128 #800080
${\color{yellow}\text{EXAMPLE}}$ yellow 255,235,61 #FFEB3D
${\color{white}\text{EXAMPLE}}$ white 255,255,255 #FFFFFF
Table 14.10 — LaTeX predefined colours




The text command     

Text can be entered directly into an equation by just typing it in:

Sym Command
${EXAMPLE}$ EXAMPLE

The problem with this is that text entered this way is always in italics and, depending on the context and position, some spaces can go missing.

To ensure that text is displayed correctly, use the \text{} command:

Sym Command
${\text{EXAMPLE}}$ \text{EXAMPLE}

The \text{} command can be a bit hit and miss with spaces, to make sure that a space is definitely shown, precede it with a backslash (\ ). I.e. backslash space.

Sym Command

${\text{EXAMPLE\ TEXT}}$

\text{EXAMPLE\ TEXT}

Important

The \ backslash space also works in an equation outside of the \text{} command, as does the \space option (which does not work inside the\text{} command).




Font restrictions     

LaTeX supports different fonts (of course it does, it’s a typesetting language). It has all the following options available to it (and this is just for maths formulae).

It should work like this:

${\large \color{#0050C0}\text{M\ A\ R\ K\ D\ O\ W\ N}}$ 🔽 ${\large \color{#00C050}\text{D\ E\ S\ C\ R\ I\ P\ T\ I\ O\ N}}$ 🔽 ${\large \color{#B00000}\text{E\ X\ P\ E\ C\ T\ E\ D}\space\ \space\text{O\ U\ T\ P\ U\ T}}$ 🔽
\mathsf{ABCDEF} San-serif font San-serif
\mathbf{ABCDEF} Bold font Bold
\mathcal{ABCDEF} Script font Script
\mathbb{ABCDEF} Double struck font Double struck
\mathefrak{ABCDEF} Frakturs font Frakturs

This is good I thought, now I can play tunes with GitHub, but it wasn’t to be.

${\Large \color{#C00000}\text{GitHub\ ignores\ all\ these\ commands.}}$

GitHub ignores all commands that apply specific fonts. All LaTeX entries are always rendered in the standard GitHub Math font (a serif font).

So there go my hopes for using a different font.

⬆️ Top



14.6SpacerAbusing LaTeX

Er… I might need to rethink that title.

GitHub doesn’t allow the font colour to be changed. It will change it itself for things like links, but as users, we can’t just change the font to green for example.

The following uses inline LaTeX formulas to add text in any colour to a GitHub page, it is a poor substitute, it is clumsy to enter and uses the standard LaTeX serif font, but it does work:

⬆️ Top



14.6.1SpacerUsing LaTeX to change the font colour

The following is an extract from an earlier section of this document:

     $$\large \color{#7030A0}\text{https:/}\text{/github.com}\color{#446FBD}\text{/}\color{#ED7D31}\text{[UserName]}\color{#446FBD}\text{/}\color{#00B050}\text{[RepositoryName]}\color{#446FBD}\text{/}\color{#c00000}\text{wiki}$$

The Markdown behind this is:

Markdown
${\large \color{#0050C0}\text{M\ A\ R\ K\ D\ O\ W\ N}}$ 🔽

$$\large \color{#7030A0}\text{https:/}\text{/github.com}\color{#446FBD}\text{/}\color{#ED7D31}\text{[UserName]}\color{#446FBD}\text{/}\color{#00B050}\text{[RepositoryName]}\color{#446FBD}\text{/}\color{#c00000}\text{wiki}$$

Table 14.11 — Coloured text example

It starts and ends with a double dollar sign ($$), this makes it a block equation (centres it on the page). It then uses a series of \color{} and \text{} commands to construct the visible text string and assign the different colours.

The only oddball thing here is the splitting of the https://github.com web address, it has become \text{https:}\text{//github.com}. I.e. it has been split into two parts, https: and //github.com.

The reason for this is that GitHub doesn’t like links in LaTeX formula (it won’t render the formula if there is a link in it), hence splitting it into two components that are not interpreted by GitHub as a link, but look like one when joined together.

Inline colour is perfectly possible too:

This line has inline ${\color{#C00000}\text{coloured}}$ ${\color{#00B050}\text{text}}$ information.

The Markdown being

Markdown
${\large \color{#0050C0}\text{M\ A\ R\ K\ D\ O\ W\ N}}$ 🔽

This line has inline ${\color{#C00000}\text{coloured}}$ ${\color{#00B050}\text{text}}$ information.

Table 14.12 — Inline colours

The principle is exactly the same, just encapsulate it between ${…}$ to signify an inline formula (see section 14.2)


Footnotes:     


Note

💠1 TeX and LaTeX; TeX (pronounced tech) came first. It’s named after the Greek word τέχνη which means something between art and skill, the first three letters being tau, epsilon, and chi or TEX in the Roman alphabet (the chi character looks like an x, but is pronounced “k”, hence tech not tex).

TeX is a very low-level typesetting programming language (developed by Donald Knuth in 1978), it was intended as a mechanism for producing professional documents, in particular it is used for the publication of mathematical, engineering and physics documentation. It is a comprehensive set of extensions (sometimes engines) and macros that provide extensive type-setting functions, including the representation of mathematical formulae.

LaTeX (pronounced Lay-tech) is a version of TeX created by Leslie Lamport in 1984 (the La being the first two letters of his surname). It works at a (slightly) higher programming language level than TeX and provides various macros that move away from the elementary programming commands of Tex to a markup language format.

Generally, LaTeX is more widely used and it is this format that GitHub uses to display mathe-matical formulae

Note

💠1 AsciiMath itself is a plain-text form of notation for writing equations.




⚠️ **GitHub.com Fallback** ⚠️