 # Basic LaTeX for math

latex for equations

Tools

2020.10.28

In markdown notes, it’s easy to insert simple mathematical formulas with plain $\LaTeX$. However, I’m always forget some basic characters for equations. So, let’s take a short review basic on the note $\LaTeX$ math for undergrads1. Note the render engine is $\KaTeX$ in this web page.

## Common constructs

plain $\LaTeX$ output
x^2 $x^2$
x_{i, j} $x_{i, j}$
\sqrt{2}, \sqrt[n]{3} $\sqrt{2}, \sqrt[n]{3}$
frac{2}{3}, 2/3 $\frac{2}{3}, 2/3$

## Calligraphic letters

Use \mathcal{A}:

$\mathcal{A} \mathcal{B} \mathcal{XYZ}$

## Greek

plain $\LaTeX$ output plain $\LaTeX$ output
\alpha $\alpha$ \xi, \Xi $\xi, \Xi$
\beta $\beta$ o $o$
\gamma, \Gamma $\gamma, \Gamma$ \pi, \Pi $\pi, \Pi$
\delta, \Delta $\delta, \Delta$ \varpi $\varpi$
\epsilon $\epsilon$ \rho $\rho$
\varepsilon $\varepsilon$ \varrho $\varrho$
\zeta $\zeta$ \sigma, \Sigma $\sigma, \Sigma$
\eta $\eta$ \varsigma $\varsigma$
\theta, \Theta $\theta, \Theta$ \tau $\tau$
\vartheta $\vartheta$ \upsilon, \Upsilon $\upsilon, \Upsilon$
\iota $\iota$ \phi, \Phi $\phi, \Phi$
\kappa $\kappa$ \varphi $\varphi$
\lambda, \Lambda $\lambda, \Lambda$ \chi $\chi$
\mu $\mu$ \psi, \Psi $\psi, \Psi$
\nu $\nu$ \omega, \Omega $\omega, \Omega$

## Sets and logic

plain $\LaTeX$ plain $\LaTeX$ plain $\LaTeX$
\cup $\cup$ \mathbb{R} $\mathbb{R}$ \forall $\forall$
\cap $\cap$ \mathbb{Z} $\mathbb{Z}$ \exists $\exists$
\subset $\subset$ \mathbb{Q} $\mathbb{Q}$ \neg $\neg$
\subseteq $\subseteq$ \mathbb{N} $\mathbb{N}$ \vee $\vee$
\supset $\supset$ \mathbb{C} $\mathbb{C}$ \wedge $\wedge$
\supseteq $\supseteq$ \varnothing $\varnothing$ \vdash $\vdash$
\in $\in$ \emptyset $\emptyset$ \models $\models$
\ni $\ni$ \aleph $\aleph$ \Rightarrow $\Rightarrow$
\notin $\notin$ \setminus $\setminus$ \nRightarrow $\nRightarrow$
\not\in $\not\in$ \equiv $\equiv$

Negate an operator, as in $\not\subset$, with \not\subset. Get the set complement $A^{\mathsf{c}}$ with A^{\mathsf{c}}, get $A^{\complement}$ with \A^{\complement}, or get $\bar{A}$ with \bar{A}.

## Decorations

plain $\LaTeX$ plain $\LaTeX$ plain $\LaTeX$
f' $f'$ \dot{a} $\dot{a}$ \tilde{x} $\tilde{x}$
f'' $f''$ \ddot{a} $\ddot{a}$ \bar{x} $\bar{x}$
\Sigma^{*} $\Sigma^{*}$ \hat{x} $\hat{x}$ \vec{x} $\vec{x}$

If the decorated letter is $i$ or $j$ then some decorations need \imath or \jmath, as in vec{\imath}. If you need boldface for vectors: \boldsymbol{x}.

Entering \overline{x+y} produces $\overline{x+y}$, and \widehat{x+y} gives $\widehat{x+y}$.

## Dots

Use low dots in a list $\{0,1,2\,\ldots\}$, entered as \{0,1,2\,\ldots\}. Use entered dots in a su or product $1+\cdots+100$, entered as 1+\cdots+100. You can also get vertical dots \vdots and diagonal dots \ddots.

## Roman names

Enter \tan{x}, with a backslash, instead of tan{x}. These get the same treatment:

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

## Other symbols

plain $\LaTeX$ plain $\LaTeX$ plain $\LaTeX$
< $<$ \angle $\angle$ \cdot $\cdot$
\leq $\leq$ \measuredangle $\measuredangle$ \pm $\pm$
> $>$ \ell $\ell$ \mp $\mp$
\geq $\geq$ \parallel $\parallel$ \times $\times$
\neq $\neq$ 45^{\circ} $45^{\circ}$ \div $\div$
\ll $\ll$ \cong $\cong$ \ast $\ast$
\gg $\gg$ \ncong $\ncong$ \mid $\mid$
\approx $\approx$ \sim $\sim$ \nmid $\nmid$
\asymp $\asymp$ \simeq $\simeq$ n! $n!$
\equiv $\equiv$ \nsim $\nsim$ \partial $\partial$
\prec $\prec$ \oplus $\oplus$ \nabla $\nabla$
\preceq $\preceq$ \ominus $\ominus$ \hbar $\hbar$
\succ $\succ$ \odot $\odot$ \circ $\circ$
\succeq $\succeq$ \otimes $\otimes$ \star $\star$
\propto $\propto$ \oslash $\oslash$ \surd $\surd$
\doteq $\doteq$ \upharpoonright $\upharpoonright$ \checkmark $\checkmark$

## Variable-sized operators

The summation $\sum_{j=0}^3 j^2$ using \sum_{j=0}^3 j^2 and the integral $\int_{x=0}^3 x^2\,dx$ with \int_{x=0}^3 x^2\,dx.

These do the same:

plain $\LaTeX$ plain $\LaTeX$ plain $\LaTeX$
\int $\int$ \iiint $\iiint$ \bigcup $\bigcup$
\iint $\iint$ \oint $\oint$ \bigcap $\bigcap$

## Arrows

plain $\LaTeX$ plain $\LaTeX$
\rightarrow, \to $\rightarrow, \to$ \mapsto $\mapsto$
\nrightarrow $\nrightarrow$ \longmapsto $\longmapsto$
\longrightarrow $\longrightarrow$ \leftarrow $\leftarrow$
\Rightarrow $\Rightarrow$ \leftrightarrow $\leftrightarrow$
\nRightarrow $\nRightarrow$ \downarrow $\downarrow$
\Longrightarrow $\Longrightarrow$ \uparrow $\uparrow$
\leadsto $\leadsto$ \updownarrow $\updownarrow$

The right arrows in the first column have matching left arrows, such as \nleftarrow, and there are some other matches for down arrows, etc.

## Fences

plain $\LaTeX$ plain $\LaTeX$ plain $\LaTeX$
() $()$ \langle\rangle $\langle \rangle$ | | $| |$
[] $[]$ \lfloor\rfloor $\lfloor\rfloor$ \| \| $| |$
{} ${}$ \lceil\rceil $\lceil\rceil$

They will grow with the enclosed formula using \left and \right.

\left\langle i, 2^{2^i} \right\rangle

$\left\langle i,2^{2^i} \right\rangle$

Every \left must match a \right and they must end on the same line in the output. For a one-sided fence put a period \left. or \right. on the other side.

\left.\frac{df}{dx}\right|_{x_0}

$\left.\frac{df}{dx}\right|_{x_0}$

Fix the size with \big, \Big, \bigg, or \Bigg.

\Big[\sum_{k=0}^n e^{k^2}\Big]

$\Big[\sum_{k=0}^n e^{k^2}\Big]$

## Array, matrics

Make an array of mathematical text as you make a table of plain text.

\begin{array}{rcl}
0 &\leftrightarrow &0 \\
1 &\leftrightarrow &1 \\
2 &\leftrightarrow &4 \\
\vdots &           &\vdots
\end{array}

$\begin{array}{rcl} 0 &\leftrightarrow &0 \\ 1 &\leftrightarrow &1 \\ 2 &\leftrightarrow &4 \\ \vdots & &\vdots \end{array}$

Definition by cases is an array with two columns.

f_n=
\begin{cases}
a   &\text{if $$n=0$$} \\
r\cdot f_{n-1}  &\text{else}
\end{cases}

$f_n= \begin{cases} a &\text{if $$n=0$$} \\ r\cdot f_{n-1} &\text{else} \end{cases}$

A matrix is another array variant. With this abbreviation you need not specify column alignments.

\begin{pmatrix}
a   &b \\
c   &d
\end{pmatrix}

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

For the determinant use |A| inline and vmatrix in display.

## Spacing in mathematics

plain $\LaTeX$ plain $\LaTeX$
\rightarrow\,\leftarrow $\rightarrow\,\leftarrow$ \rightarrow\quad\leftarrow $\rightarrow\quad\leftarrow$
\rightarrow\:\leftarrow $\rightarrow\:\leftarrow$ \rightarrow\qquad\leftarrow $\rightarrow\qquad\leftarrow$
\rightarrow\;\leftarrow $\rightarrow\;\leftarrow$ \rightarrow\!\leftarrow $\rightarrow\!\leftarrow$

The left column spaces are in ratio $3:4:5$. The last in the right column is a negative space, opposite to \,. Get arbitrary spaces as in \hspace{0.5cm}.

## Calculus examples

f\colon\mathbb{R}\to\mathbb{R}

$f\colon\mathbb{R}\to\mathbb{R}$
9.8~\text{m}/\text{s}^2

$9.8~\text{m}/\text{s}^2$
\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}

$\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$
int x^2\,dx=x^3/3+C

$\int x^2\,dx=x^3/3+C$
\nabla=\boldsymbol{i}\frac{d}{dx}+\boldsymbol{j}\frac{d}{dy}+\boldsymbol{k}\frac{d}{dz}

$\nabla=\boldsymbol{i}\frac{d}{dx}+\boldsymbol{j}\frac{d}{dy}+\boldsymbol{k}\frac{d}{dz}$

## Discrete mathematics examples

There are four modulo forms: $m\bmod n$ is from m\bmod n, and $a\equiv b\pmod m$ is from a\equiv b\pmod m, and $a\equiv b\mod m$ is from a\equiv b\mod m, and $a\equiv b\pod m$ is from a\equiv b\pod m.

For combinations the binomial symbol $\binom{n}{k}$ is from \binom{n}{k}. This resizes to be bigger in a display.

For permutations use $n^{\underline{r}}$ from n^{\underline{r}}.

## Statistics examples

\sigma^2=\sqrt{\sum (x_i-\mu)^2/N}

$\sigma^2=\sqrt{\sum (x_i-\mu)^2/N}$
E(x)=\mu_X=\sum (x_i-P(x_i))

$E(x)=\mu_X=\sum (x_i-P(x_i))$

The probability density of the normal distribution $\frac{1}{\sqrt{2\sigma^2\pi}}\,e^{-\frac{(x-\mu)^2}{2\sigma^2}}$ comes from this:

\frac{1}{\sqrt{2\sigma^2\pi}}\,e^{-\frac{(x-\mu)^2}{2\sigma^2}}


## For more

See more comprehensive $\LaTeX$ symbols list at http://mirror.ctan.org/info/symbols/comprehensive.

1. Jim Hefferon, Saint Michael’s College, VT USA 2017-Jan-10 ## 林宏

Frank Lin

Hey, there! This is Frank Lin (@flinhong), one of the 1.4 billion 🇨🇳. This 'inDev. Journal' site holds the exploration of my quirky thoughts and random adventures through life. Hope you enjoy reading and perusing my posts.

## YOU MAY ALSO LIKE

Web Notes

2016.08.20

### Using Liquid in Jekyll - Live with Demos

Liquid is a simple templating language that Jekyll uses to process pages on your site. With Liquid you can output an modify variables, have logic statements inside your pages and loop over content.

Tutorials

2020.01.09

### Setup an IKEv2 server with StrongSwan

IKEv2, or Internet Key Exchange v2, is a protocol that allows for direct IPSec tunneling between two points. In IKEv2 implementations, IPSec provides encryption for the network traffic. IKEv2 is natively supported on some platforms (OS X 10.11+, iOS 9.1+, and Windows 10) with no additional applications necessary, and it handles client hiccups quite smoothly.

C Notes

2017.04.24

### Common sorting algorithms, understand and implemention in C

Understand the common sorting algorithms, just because recent take CS50 course.

## TOC 