-
Notifications
You must be signed in to change notification settings - Fork 0
14 Mathematical 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.
The following is the LaTeX syntax for the common quadratic equation:
Markdown and GitHub output |
---|
|
$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:
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.
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 |
---|
|
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.
|
|
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 |
Table 14.1 — Inline equation |
Generally, the use of inline equations should be restricted to single line type equations (
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 (`$
).
A formula block is an equation that appears outside any text and may span multiple lines:
Markdown and GitHub output |
---|
|
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.
|
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. 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 |
---|
|
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.
|
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. 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.
The following section gives some insights into the LaTeX equation syntax, this section has several examples of the types of equations that are possible:
|
|
---|
```math
f(x)=(x+a)(x+b)
```
|
```math
\cos(2\theta\phi) = \cos^2 \theta\phi - \sin^2 \theta\phi
```
|
```math
(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
```
|
```math
\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}}}
```
|
```math
x = a_0 + \frac{1}{\displaystyle a_1
+ \frac{1}{\displaystyle a_2
+ \fr
```
|
```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}
```
|
```math
\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}
```
|
```math
|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
```
|
```math
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}
```
|
```math
e^x = 1 + x + \frac{x^2}{2} + \cdots = \sum_{n\geq 0} \frac{x^n}{n!}
```
|
Table 14.4 — Example equations
|
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}
```
|
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})
```
|
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)
```
|
To use braces (instead of brackets or parentheses), precede the brace with a backslash:
```math
x=\{1-\frac{a}{b}\}
```
|
\left and \right: work in the same way as before:
```math
x=\left\{1-\frac{a}{b}\right\}
```
|
Various characters (Greek characters, symbols &c.) have their own commands:
```math
\tau\epsilon\chi
```
|
Superscript characters are preceded with ^
and subscript with _
. Thes can also be used for limits on operators:
```math
a^b
```
|
```math
a_b
```
|
With limits, it is like this:
```math
\sum_{n=1}^{\infty}
```
|
```math
\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:
Sym | Command | Sym | Command | Sym | Command | Sym | Command |
---|---|---|---|---|---|---|---|
|
\alpha |
|
\gamma |
|
\omega |
|
\sigma |
|
\beta |
|
\iota |
|
\phi |
|
\tau |
|
\chi |
|
\kappa |
|
\varphi |
|
\theta |
|
\delta |
|
\lambda |
|
\pi |
|
\upsilon |
|
\epsilon |
|
\mu |
|
\psi |
|
\xi |
|
\eta |
|
\nu |
|
\rho |
|
\zeta |
Sym | Command | Sym | Command | Sym | Command | Sym | Command |
---|---|---|---|---|---|---|---|
|
\Delta |
|
\Psi |
|
\varepsilon |
|
\aleph |
|
\Gamma |
|
\Sigma |
|
\varkappa |
|
\beth |
|
\Lambda |
|
\Theta |
|
\Phi |
|
\daleth |
|
\Omega |
|
\Upsilon |
|
\Pi |
|
\gimel |
|
\Xi |
|
\vartheta |
|
\varepsilon |
Sym | Command | Sym | Command | Sym | Command |
---|---|---|---|---|---|
|
\frac{abc}{xyz} |
|
\overline{abc} |
|
\overrightarrow{abc} |
|
f’ |
|
\underline{abc} |
|
\overleftarrow{abc} |
|
\sqrt{abc} |
|
\widehat{abc} |
|
\overbrace{abc} |
|
\sqrt[n]{abc} |
|
\widetilde{abc} |
|
\underbrace{abc} |
Sym | Command | Sym | Command | Sym | Command | Sym | Command |
---|---|---|---|---|---|---|---|
|
| |
|
\{ |
|
\Uparrow |
|
/ |
|
\vert |
|
\} |
|
\uparrow |
|
\backslash |
|
\Vert |
|
\langle |
|
\Downarrow |
||
|
( |
|
\rangle |
|
\downarrow |
||
|
) |
|
\lfloor |
|
\llcorner |
||
|
[ |
|
\rfloor |
|
\lrcorner |
||
|
] |
|
\lceil |
|
\ulcorner |
||
|
\rceil |
|
\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] |
Sym | Command | Sym | Command |
---|---|---|---|
|
\sum |
|
\biguplus |
|
\prod |
|
\bigcap |
|
\coprod |
|
\bigcup |
|
\int |
|
\bigoplus |
|
\oint |
|
\bigotimes |
|
\iint |
|
\bigodot |
|
\iiint |
|
\bigvee |
|
\lim |
|
\bigwedge |
Sym | Command | Sym | Command |
---|---|---|---|
|
\sum_{def}^{abc}x_y^z |
|
\biguplus_{n=1}^{10}A_n |
|
\prod_{def}^{abc} x_y^z |
|
\bigcap_{n=1}^{10}A_n |
|
\coprod_{n=1}^{\infty} x_y^z |
|
\bigcup_{n=1}^{10}A_n |
|
\int_{0}^{\infty} x^2 dx |
|
\bigoplus_{b\epsilon B}R_b |
|
\oint_{c_1} \frac{-y}{x^2 +y^2}dr |
|
\bigotimes_{b\epsilon B}R_b |
|
\iint_{w}^{k} dV |
|
\bigodot_{b\epsilon B}R_b |
|
\iiint_{w}^{k} dV |
|
\bigvee_{n=1}^{10}A_n |
|
\lim_{x\to \infty} x^2 |
|
\bigwedge_{n=1}^{10}A_n |
Sym | Command | Sym | Command | Sym | Command | Sym | Command |
---|---|---|---|---|---|---|---|
|
\arccos |
|
\arcsin |
|
\arctan |
|
\arg |
|
\cos |
|
\cosh |
|
\cot |
|
\coth |
|
\csc |
|
\deg |
|
\det |
|
\dim |
|
\exp |
|
\gcd |
|
\hom |
|
\inf |
|
\ker |
|
\lg |
|
\lim |
|
liminf |
|
\limsup |
|
\ln |
|
\log |
|
\max |
|
\min |
|
\Pr |
|
\sec |
|
\sin |
|
\sinh |
|
\sup |
|
\tan |
|
\tanh |
Standard functions should appear as Roman regular characters, not italics.
Sym | Command | Sym | Command | Sym | Command | Sym | Command |
---|---|---|---|---|---|---|---|
|
\ast |
|
\pm |
|
\cap |
|
\lhd |
|
\aaa |
|
\mp |
|
\cup |
|
\rhd |
|
\cdot |
|
\amalg |
|
\uplus |
|
\triangleleft |
|
\circ |
|
\odot |
|
\sqcap |
|
\triangleright |
|
\bullet |
|
\ominus |
|
\sqcup |
|
\unlhd |
|
\bigcirc |
|
\oplus |
|
\wedge |
|
\unrhd |
|
\diamond |
|
\oslash |
|
\vee |
|
\bigtriangledown |
|
\times |
|
\otimes |
|
\dagger |
|
\bigtriangleup |
|
\div |
|
\wr |
|
\ddagger |
|
\setminus |
|
\centerdot |
|
\Box |
|
\barwedge |
|
\veebar |
|
\circledast |
|
\boxplus |
|
\curlywedge |
|
\curlyvee |
|
\circledcirc |
|
\boxminus |
|
\Cap |
|
\Cup |
|
\circleddash |
|
\boxtimes |
|
\bot |
|
\top |
|
\dotplus |
|
\boxdot |
|
\intercal |
|
\rightthreetimes |
|
\divideontimes |
|
\square |
|
\doublebarwedge |
|
\leftthreetimes |
Sym | Command | Sym | Command | Sym | Command | Sym | Command |
---|---|---|---|---|---|---|---|
|
\equiv |
|
\leq |
|
\geq |
|
\perp |
|
\cong |
|
\prec |
|
\succ |
|
\mid |
|
\neq |
|
\preceq |
|
\succeq |
|
\parallel |
|
\sim |
|
\ll |
|
\gg |
|
\bowtie |
|
\simeq |
|
\subset |
|
\supset |
|
\Join |
|
\approx |
|
\subseteq |
|
\supseteq |
|
\ltimes |
|
\asymp |
|
\sqsubset |
|
\sqsupset |
|
\rtimes |
|
\doteq |
|
\sqsubseteq |
|
\sqsupseteq |
|
\smile |
|
\propto |
|
\dashv |
|
\vdash |
|
\frown |
|
\models |
|
\in |
|
\ni |
|
\notin |
Sym | Command | Sym | Command | Sym | Command | Sym | Command |
---|---|---|---|---|---|---|---|
|
\approxeq |
|
\leqq |
|
\geqq |
|
\lessgtr |
|
\thicksim |
|
\leqslant |
|
\geqslantcc |
|
\lesseqgtr |
|
\backsim |
|
\lessapprox |
|
\gtrapprox |
|
\lesseqqgtr |
|
\backsimeq |
|
\lll |
|
\ggg |
|
\gtreqqless |
|
\triangleq |
|
\lessdot |
|
\gtrdot |
|
\gtreqless |
|
\circeq |
|
\lesssim |
|
\gtrsim |
|
\gtrless |
|
\bumpeq |
|
\eqslantless |
|
\eqslantgtr |
|
\backepsilon |
|
\Bumpeq |
|
\precsim |
|
\succsim |
|
\between |
|
\doteqdot |
|
\precapprox |
|
\succapprox |
|
\pitchfork |
|
\thickapprox |
|
\Subset |
|
\Supset |
|
\shortmid |
|
\fallingdotseq |
|
\subseteqq |
|
\csupseteqqcc |
|
\smallfrown |
|
\risingdotseq |
|
\sqsubset |
|
\sqsupset |
|
\smallsmile |
|
\varpropto |
|
\preccurlyeq |
|
\succcurlyeq |
|
\Vdash |
|
\therefore |
|
\curlyeqprec |
|
\curlyeqsucc |
|
\vDash |
|
\because |
|
\blacktriangleleft |
|
\blacktriangleright |
|
\Vvdash |
|
\eqcirc |
|
\trianglelefteq |
|
\trianglerighteq |
|
\shortparallel |
|
\neq |
|
\vartriangleleft |
|
\vartriangleright |
|
\nshortparallel |
Sym | Command | Sym | Command | Sym | Command | Sym | Command |
---|---|---|---|---|---|---|---|
|
\ncong |
|
\nleq |
|
\ngeq |
|
\nsubseteq |
|
\nmid |
|
\nleqq |
|
\ngeqq |
|
\nsupseteq |
|
\nparallel |
|
\nleqslant |
|
\ngeqslant |
|
\nsubseteqq |
|
\nshortmid |
|
\nless |
|
\ngtr |
|
\nsupseteqq |
|
\nshortparallel |
|
\nprec |
|
\nsucc |
|
\subsetneq |
|
\nsim |
|
\npreceq |
|
\nsucceq |
|
\supsetneq |
|
\nVDash |
|
\precnapprox |
|
\succnapprox |
|
\subsetneqq |
|
\nvDash |
|
\precnsim |
|
\succnsim |
|
\supsetneqq |
|
\nvdash |
|
\lnapprox |
|
\gnapprox |
|
\varsubsetneq |
|
\ntriangleleft |
|
\lneq |
|
\gneq |
|
\varsupsetneq |
|
\ntrianglelefteq |
|
\lneqq |
|
\gneqq |
|
\varsubsetneqq |
|
\ntriangleright |
|
\lnsim |
|
\gnsim |
|
\varsupsetneqq |
|
\ntrianglerighteq |
|
\blvertneqqbb |
|
\gvertneqq |
Sym | Command | Sym | Command | Sym | Command |
---|---|---|---|---|---|
|
\leftarrow |
|
\longleftarrow |
|
\uparrow |
|
\Leftarrow |
|
\Longleftarrow |
|
\Uparrow |
|
\rightarrow |
|
\longrightarrow |
|
\downarrow |
|
\Rightarrow |
|
\Longrightarrow |
|
\Downarrow |
|
\leftrightarrow |
|
\longleftrightarrow |
|
\updownarrow |
Sym | Command | Sym | Command | Sym | Command |
---|---|---|---|---|---|
|
\mapsto |
|
\longmapsto |
|
\nearrow |
|
\hookleftarrow |
|
\hookrightarrow |
|
\searrow |
|
\leftharpoonup |
|
\rightharpoonup |
|
\swarrow |
|
\leftharpoondown |
|
\rightharpoondown |
|
\nwarrow |
|
\rightleftharpoons |
Sym | Command | Sym | Command | Sym | Command |
---|---|---|---|---|---|
|
\dashrightarrow |
|
\dashleftarrow |
|
\leftleftarrows |
|
\leftrightarrows |
|
\Lleftarrow |
|
\twoheadleftarrow |
|
\leftarrowtail |
|
\looparrowleft |
|
\leftrightharpoons |
|
\curvearrowleft |
|
\circlearrowleft |
|
\Lsh |
|
\upuparrows |
|
\upharpoonleft |
|
\downharpoonleft |
|
\multimap |
|
\leftrightsquigarrow |
|
\rightrightarrows |
|
\rightleftarrows |
|
\rightrightarrows |
|
\rightleftarrows |
|
\twoheadrightarrow |
|
\rightarrowtail |
|
\looparrowright |
|
\rightleftharpoons |
|
\curvearrowright |
|
\circlearrowright |
|
\Rsh |
|
\downdownarrows |
|
\upharpoonright |
|
\downharpoonright |
|
\rightsquigarrow |
Sym | Command | Sym | Command | Sym | Command |
---|---|---|---|---|---|
|
\nleftarrow |
|
\nrightarrow |
|
\nLeftarrow |
|
\nRightarrow |
|
\nleftrightarrow |
|
\nLeftrightarrow |
Sym | Command | Sym | Command | Sym | Command | Sym | Command |
---|---|---|---|---|---|---|---|
|
\infty |
|
\forall |
|
\Diamond |
|
\complement |
|
\nabla |
|
\exists |
|
\Finv |
|
\dtriangledowndd |
|
\partial |
|
\nexists |
|
\triangle |
||
|
\eth |
|
\emptyset |
|
\hbar |
|
\vartriangle |
|
\clubsuit |
|
\varnothing |
|
\hslash |
|
\blacklozenge |
|
\diamondsuit |
|
\imath |
|
\lozenge |
|
\blacksquare |
|
\heartsuit |
|
\jmath |
|
\mho |
|
\blacktriangle |
|
\spadesuit |
|
\ell |
|
\prime |
||
|
\cdots |
|
\sharp |
|
\square |
|
\backprime |
|
\vdots |
|
\flat |
|
\surd |
|
\circledS |
|
\ldots |
|
\natural |
|
\wp |
|
\measuredangle |
|
\Im |
|
\Re |
|
\diagdown |
|
\diagup |
Sym | Command | Sym | Command | Sym | Command | Sym | Command |
---|---|---|---|---|---|---|---|
|
\acute{a} |
|
\bar{a} |
|
\breve{a} |
|
\check{a} |
|
\ddot{a} |
|
\dot{a} |
|
\grave{a} |
|
\hat{a} |
|
\atilde{a}aa |
|
\vec{a} |
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):
|
|
|
---|
No delimiter |
```math
\begin{matrix}
1 & 2 & 3\\
a & b & c
\end{matrix}
```
|
---|
Parentheses |
```math
\begin{pmatrix}
1 & 2 & 3\\
a & b & c
\end{pmatrix}
```
|
---|
Brackets |
```math
\begin{bmatrix}
1 & 2 & 3\\
a & b & c
\end{bmatrix}
```
|
---|
Braces |
```math
\begin{Bmatrix}
1 & 2 & 3\\
a & b & c
\end{Bmatrix}
```
|
---|
Pipes |
```math
\begin{vmatrix}
1 & 2 & 3\\
a & b & c
\end{vmatrix}
```
|
---|
Double pipes |
```math
\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
```
|
---|
Different delimiters either side |
```math
\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}
```
|
---|
Table 14.5 — Matrices
|
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 \\
.
|
|
|
---|
Typical case |
```math
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).
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 \\
.
|
|
|
---|
Equation alignment |
```math
\begin{align}
x - 5y &= 8 \\
3x + 9y &= -12
\end{align}
```
|
---|
Table 14.7 — Aligning multiple equations
|
LaTeX is a typsetting language and supports various text formatting operations, these are discussed below:
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:
|
|
|
---|---|---|
\scriptscriptstyle |
9.60 | |
\tiny |
11.31 | |
\scriptsize |
11.31 | |
\scriptstyle |
11.68 | |
\small |
13.60 | |
\normalsize |
16.00 | |
\textstyle |
16.00 | |
\displaystyle |
16.00 | |
\large |
19.20 | |
\Large |
23.04 | |
\huge |
23.04 | |
\Huge |
23.04 | |
Table 14.8 — LaTeX text formatting, point size |
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{blue}EXAMPLE |
|
\color{#446FBD}EXAMPLE |
|
\color{rgb(255,0,0)}EXAMPLE |
|
\color{rgba(0,255,0, 0.5)}EXAMPLE |
|
\color{hsl(100%,0,0)}EXAMPLE |
|
\color{hsla(120, 100%, 50%, 0.5)}EXAMPLE |
Table 14.9 — LaTeX text formatting, colours |
The predefined colours are:
Colour | Name | RGB | Hex |
---|---|---|---|
black |
0,0,0 |
#000000 |
|
blue |
0,0,255 |
#0000FF |
|
brown |
191,248,64 |
#BF8040 |
|
cyan |
0,185,224 |
#00B9F2 |
|
darkgrey |
64,64,64 |
#404040 |
|
gray |
156,156,156 |
#9C9C9C |
|
green |
0,255,0 |
#00FF00 |
|
lightgrey |
191,191,191 |
#BFBFBF |
|
lime |
191,255,0 |
#BFFF00 |
|
magenta |
251,49,153 |
#FB3199 |
|
olive |
159,140,24 |
#9F8C18 |
|
orange |
255,128,0 |
#FF8000 |
|
pink |
255,191,191 |
#FFBFBF |
|
purple |
191,0,64 |
#BF0040 |
|
red |
255,0,0 |
#FF0000 |
|
teal |
0,128,128 |
#008080 |
|
violet |
128,0,128 |
#800080 |
|
yellow |
255,235,61 |
#FFEB3D |
|
white |
255,255,255 |
#FFFFFF |
|
Table 14.10 — LaTeX predefined colours |
Text can be entered directly into an equation by just typing it in:
Sym | Command |
---|---|
|
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} |
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} |
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).
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:
|
|
|
---|---|---|
\mathsf{ABCDEF} |
San-serif font | ![]() |
\mathbf{ABCDEF} |
Bold font | ![]() |
\mathcal{ABCDEF} |
Script font | ![]() |
\mathbb{ABCDEF} |
Double struck font | ![]() |
\mathefrak{ABCDEF} |
Frakturs font | ![]() |
This is good I thought, now I can play tunes with GitHub, but it wasn’t to be.
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.
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:
The following is an extract from an earlier section of this document:
The Markdown behind this is:
Markdown |
---|
|
$$\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
The Markdown being
Markdown |
---|
|
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↩
|
|
|
|
|
The PracticalSeries of Publications — Copyright © 2025 Michael Gledhill
⬆️ Top | [email protected] | PracticalSeries of Publications | Main repository
|
|
|
|
|
Licence
The licences and other details
The Licence
Why did I choose the MIT Licence?
Permissive licences
Copyleft licence
Limiting liabilities
Which licence to use?
A note on spelling: licence or license
1 Introducing the GitHub Wiki
1.1 What are GitHub Wiki pages?
1.2 Understanding the Wiki pages
1.3 Creating a Wiki for a repository
1.3.1 Creating the first Wiki page
1.3.2 Creating additional pages
1.3.3 Editing a Wiki page
1.4 The Wiki is its own repository
1.4.1 Viewing a Wiki page history
1.4.2 How GitHub handles Wiki branche
1.4.3 The Wiki link to the main repository
1.5 Basic components of a Wiki page
1.5.1 Title bar and revision
1.5.2 Contents (pages) area
Listing pages in the order you want
1.5.3 Sidebars
1.5.4 Footers
1.6 Sidebars and footers
1.6.1 Creating a sidebar and footer
2 Cloning a Wiki
2.1 Why clone a Wiki?
2.2 How to clone a Wiki
2.3 Pushing local changes to GitHub
2.3.1 Configuring username and email
2.3.2 Modifying the local repository
2.3.3 Committing and synchronising
3 A Wiki folder structure
3.1 The default arrangement
3.2 Create a sidebar or footer locally
3.3 Page naming and Wiki limits
3.3.1 Supported file types
3.3.2 Page names and numbering
3.3.3 Rules for page numbering
3.3.4 Limits for Wiki pages
3.4 A Practical Wiki folder structure
3.4.1 Subfolder names for Wiki pages
3.4.2 Storing images and other data
4 Different sidebars and footers
4.1 How sidebars work
4.1.1 The PracticalSeries sidebar
4.2 How footers work
4.2.1 The PracticalSeries footer
5 Markdown, GitHub Markdown and HTML
5.1 Some useful Markdown sites
5.2 An overview of Markdown
5.3 How Markdown works
5.4 Markdown flavours
5.4.1 GitHub Flavoured Markdown (GFM)
5.5 HTML and Markdown
5.5.1 HTML with GFM
GFM blacklisted HTML tags
GFM whitelisted HTML tags
GFM HTML tags - the grey area
GFM whitelisted HTML attributes
5.5.2 PracticalSeries and Markdown
5.6 Markdown difference between files
6 Basic Markdown and text formatting
6.1 Body text and fonts
6.1.1 Body text responsive design
6.1.2 Body text in sidebars and footers
6.1.3 Rules for body text
6.1.4 Body text examples
6.1.5 Alignment of Body text
Left aligned text (default)
Right aligned text
Centred text
Justified text
6.1.6 Body text propertie
6.2 Paragraphs and line breaks
6.2.1 Forced line break
6.2.2 Blank line and a line break
6.2.3 Trailing space line break
6.2.4 Paragraph and line break rules
6.2.5 Paragraph and line break examples
6.3 Horizontal line
6.3.1 Rules for horizontal lines
6.4 Emphasis with bold
6.4.1 Rules for bold
6.4.2 Bold text examples
6.5 Emphasis with italics
6.5.1 Rules for italics
6.5.2 Italic text examples
6.6 Emphasis with bold and italics
6.6.1 Rules for bold and italics
6.6.2 Bold and italic text examples
6.7 Emphasis with underlining
6.7.1 Rules for underlining
6.7.2 Underlining text examples
6.8 Emphasis with strikethrough
6.8.1 Rules for strikethrough
6.8.2 Strikethrough text examples
6.9 Superscript and subscript
6.9.1 Rules for superscript and subscript
6.9.2 Superscript and subscript examples
6.10 Headings
Alternatives for heading 1 and 2
6.10.1 Headings Markdown rules
6.10.2 Heading properties
7 Special characters and escaping characters
7.1 Escape characters and codes
7.1.1 Markdown escape sequences
7.1.2 HTML escape sequences
7.1.3 Decimal and hexadecimal codes
Hexadecimal escape codes
7.2 Special space characters
7.2.1 Escape sequence restrictions
7.3 Emojis and emoticons
A note by the Author about emojis
7.4 Comments
8 Block quotes, lists and alerts
8.1 Block quotes
8.1.1 Nested block quotes
8.1.2 Adding other elements
8.1.3 Rules for block quotes
8.2 Unordered (unnumbered) lists
8.2.1 Nested unordered lists
8.2.2 Type of bullet point
8.2.3 Indents and spacing
8.2.4 Numbers in an unordered list
8.2.5 Adding paragraphs
8.2.6 Adding other elements
8.2.7 Rules for unordered lists
8.3 Ordered (numbered) lists
8.3.1 Starting at a different number
8.3.2 Nested ordered lists
8.3.3 Type of numbering
8.3.4 Indents and spacing
8.3.5 Adding paragraphs
8.3.6 Adding other elements
8.3.7 Rules for ordered lists
8.4 Mixing ordered and unordered lists
8.5 Task lists (check boxes)
8.5.1 Nested task lists
8.6 Alerts
8.6.1 Rules for alerts
9 Links
9.1 Link to an external web page
9.1.1 A direct link to a URL
9.1.2 A link using substitute text
9.1.3 A link using tooltips
9.2 Link to another page in the Wiki
9.2.1 Rules for linking to a Wiki page
9.3 Link to headings on current page
9.3.1 Converting a heading to a link
9.3.2 An example of a heading link
9.3.3 Heading link with tooltips
9.4 Link to headings on a different page
9.4.1 An example of a heading link
9.5 Link to a named element
A note by the Author
9.5.1 Link to a point on another page
9.6 Downloading a file
9.6.1 The download attribute
9.6.2 Spaces in filenames
9.6.3 Downloading a .md file
9.7 Reference style links
9.8 Relative links
9.8.1 Relative links from any Wiki page
10 Tables
10.1 Markdown tables
10.1.1 Horizontal alignment
10.1.2 Table construction
10.1.3 Vertical line breaks and alignment
10.1.4 Making columns wider
10.1.5 Other elements in a table
10.1.6 Markdown table restrictions
10.2 HTML tables
10.2.1 A basic HTML table
10.2.2 Aligning a table on a page
10.2.3 Text wrap and side-by-side tables
What this means in practice
The problem with the align attribute
How to stop text wrapping
10.2.4 Setting the width of a table column
10.2.5 Setting the height of a table row
10.2.6 Horizontal alignment
10.2.7 Vertical alignment
10.2.8 Spanning columns and rows
10.2.9 Table border
10.2.10 Giving a table a navigable name
10.2.11 Additional HTML tags
11 Images
11.1 Markdown images
11.1.1 Image size in Markdown
11.1.2 Making the image a link
11.1.3 Drag and drop image link
A note by the Author
11.2 HTML images
11.2.1 A basic HTML image
11.2.2 Image size in HTML
11.2.3 Horizontal alignment
11.2.4 Making the image a link
11.2.5 Using a table to contain an image
11.3 Forcing an image refresh
11.4 Using a spacer image
11.5 Mermaid diagrams
11.5.1 Inserting a Mermaid diagram
11.5.2 The rendered Mermaid diagram
11.5.3 Supported version of Mermaid
11.6 Interactive maps
11.7 3D models
12 Contents (collapsible) and footnotes
12.1 A basic table of contents
12.2 Understanding the space characters
12.3 Collapsible content
12.3.1 Defaulting to open
12.3.2 Markdown restrictions
12.4 Collapsible TOC
12.5 TOCs in tables
12.6 Footnotes
13 Code fragments
13.1 Inline code
13.2 Code blocks
13.2.1 Preferred mechanism
13.3 Syntax highlighting
13.3.1 Supported languages
13.4 HTML code fragments
13.4.1 Converting HTML to code
14 Mathematical formulae
14.1 An overview of LaTex
14.2 Inserting an inline formula
14.2.1 Alternative delimiter
14.3 A formula block
14.4 Some example formulae
14.5 LaTeX syntax
14.5.1 Greek lowercase
14.5.2 Greek uppercase and Hebrew
14.5.3 Mathematical constructions
14.5.4 Variable sized delimiters
14.5.5 Variable sized symbols
14.5.6 Variable sized symbols with limits
14.5.7 Standard functions
14.5.8 Operators and relational symbols
14.5.9 Arrows
14.5.10 Other symbols
14.5.11 Accents
14.5.12 Matrices
14.5.13 Cases
Aligning multiple equations
14.5.14 Text formatting
Font size
Font colour
The text command
Font restrictions
14.6 Abusing LaTeX
14.6.1 Changing font colour with LaTeX
15 Navigation bars, badges and buttons
15.1 Navigation bars
15.1.1 Navigation bar practicalities
15.2 Badges
15.2.1 Creating a badge
15.2.2 Static badge options
15.2.3 Dynamic badges
15.3 Buttons
16 PracticalSeries Wiki conventions
16.1 The PracticalSeries Wiki page
16.2 The PracticalSeries folder structure
16.2.1 The root folder and home page
16.2.2 Leading pages
16.2.3 .gitkeep files
16.2.4 Folder and Markdown file names
Wiki pages that start at a section
16.3 The page title area
16.4 The page heading area
16.4.1 Top of page marker
16.4.2 Logo image
16.4.3 Web ID badge
16.5 Main body area
16.5.1 Common page elements
End of page marker
End of section elements
16.5.2 Headings
Compensating for number widths
Appendices headings
16.5.3 Tables
Links to a table
A note on Markdown tables
16.5.4 Images
Images that open in a new tab
Double images
Links to a figure
16.5.5 Lists
Common points for all lists
Basic unordered list
Basic ordered list
Mixed ordered and unordered lists
Enhanced mixed lists
Index list
Reverse index list
Index list with text wrap
Reverse index list with text wrap
Indexed, mixed list
Reverse indexed, mixed list
Task list
Enhanced task list with observations
16.5.6 Code fragments
16.5.7 Formulae
Standard formulae
Alternate formulae
16.6 Sidebar
16.6.1 sidebar files and locations
16.6.2 Sidebar title and location badge
16.6.3 Navigation bar
16.6.4 Table of contents
Unnumbered, non-collapsible TOC
Unnumbered, collapsible TOC
Single digit, collapsible TOC
Double digit, collapsible TOC
TOCs for appendices
16.6.5 End of page link
16.7 Footer
16.7.1 Footer files and locations
16.7.2 Location badge
16.7.3 Navigation bar
16.7.4 Colophon
16.7.5 Links and contacts
17 Managing a Wiki
17.1 Revision control
17.1.1 Managing commits
17.2 Finding the first Wiki commit
17.3 Rebasing the Wiki
17.3.1 Summarising the rebase process
17.3.2 Executing the rebase process
17.4 Wikis and search engine visibility
Appendices
B Full list of all emoji characters
B.1 Emojis, a brief explanation
B.1.1 Emoji short names
B.1.2 Emoji escape codes
B.1.3 Emoji variations
B.1.4 Emoji numbers
B.2 Emojis characters by category
Smileys and emotion
People and body
Component
Animals and nature
Food and drink
Travel and places
Activities
Objects
Symbols
Flags
B.3 Emoji characters by Unicode
C Segoe UI full character set
A note by the Author
C.1 Inserting Unicode characters
C.2 Characters U+00000 to U+00FFF
C.3 Characters U+01000 to U+01FFF
C.4 Characters U+02000 to U+02FFF
C.5 Characters U+03000 to U+09FFF
C.6 Characters U+0A000 to U+0AFFF
C.7 Characters U+0B000 to U+0FFFF
C.8 Characters U+10000 to U+10FFF
C.9 Characters U+11000 to U+11FFF
C.10 Characters U+12000 to U+12FFF
C.11 Characters U+13000 to U+15FFF
C.12 Characters U+16000 to U+1CFFF
C.13 Characters U+1D000 to U+1EFFF
C.14 Characters U+1F000 to U+3FFFF
⬇️ End of page |