Typing Mathematics
LaTeX is a typesetting language used heavily in mathematics. You must use it if
-
you are writing a document in Markdown, and
-
you want to insert a mathematics formula into your document.
You can type formulas on the keyboard using LaTeX. You must decide if you want an inline or display formula .
-
Create inline equation by placing the formula inside
$ ... $-
The formula shows up in the middle of a paragraph of text.
-
$a^2 + b^2 = c^2$produces\(a^2 + b^2 = c^2\)
-
You can mix math and non-math text in a single sentence
Let $f(x) = 2x - 1$, then observe that $f'(x)=2$
-
-
Create display equation by putting the formula inside
$$ ... $$-
The formula is displayed in a new paragraph, centered, and sometimes slightly larger.
-
$$\sin^2 x + \cos^2 x = 1$$produces the text \[\sin^2 x + \cos^2 x = 1\] -
Example
$$x=\frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$$produces the text \[x=\frac{-b \pm \sqrt{b^2 - 4ac}}{2a}\]
-
Basic Formulas
Basic math formula syntax is given below, with examples.
Note: Only the LaTeX formulas are given below.
When used in a document the formulas must be enclosed inside $...$ or $$...$$.
-
Many symbols are exactly what you expect from the keyboard.
-
+and-become \(+\) and \(-\) -
numbers like
8become \(8\).
-
-
Normal letters are interpreted as variables. They are italicised, and spaces are ignored.
-
xbecomes \(x\) -
3 x + 2becomes \(3 x + 2\) -
x and ybecomes \(x and y\)
-
-
Use
\cdotto get a dot for multiplication.-
2\cdot 3 = 6becomes \(2\cdot 3 = 6\) -
x\cdot x^2 = x^3becomes \(x \cdot x^2 = x^3\)
-
-
Use
\frac{num}{denom}for fractions. Use\dfrac{num}{denom}to create the same fraction, but using more space-
\frac{a}{c} + \frac{b}{c} = \frac{a+b}{c}becomes \(\frac{a}{c} + \frac{b}{c} = \frac{a+b}{c}\) -
\dfrac{a}{c} + \dfrac{b}{c} = \dfrac{a+b}{c}becomes \(\dfrac{a}{c} + \dfrac{b}{c} = \dfrac{a+b}{c}\)
-
-
Use
^to create an exponent. If you need to put more than one character in the exponent, enclose the exponent in{...}-
2^a \cdot 2^b = 2^{a + b}becomes \(2^a \cdot 2^b = 2^{a + b}\) -
2^{10}becomes \(2^{10}\), whereas2^10becomes \(2^10\)
-
-
Use
_to create an subscript. If you need to put more than one character in the subscript, enclose it in{...}A_{i,j}becomes \(A_{i,j}\)
-
Use
\sqrt{...}to create a square root. You can create a nth root using\sqrt[n]{...}-
\sqrt{9} = 3becomes \(\sqrt{9}=3\) -
\sqrt[3]{8} = 2becomes \(\sqrt[3]{8} = 2\)
-
-
You can get a nice version of most named functions by putting a
\before the function name. This includes\ln,\log,\sin,\cos,\tan,\sec,\csc,\cot-
\ln(e^3) = 3becomes \(\ln(e^3) = 3\) -
\log_10(1000) = 3becomes \(\log_10(1000) = 3\)
-
-
You can type many common symbols using their name, like
\pibecomes \(\pi\),\Deltabecomes \(\Delta\), and so on. A more complete table of common greek symbols is also given below. -
You can combine any of the above
-
\cos(3\pi) = -1becomes \(\cos(3\pi) = -1 \) -
\tan^{-1}(-1) = -\frac{\pi}{4}becomes \(\tan^{-1}(-1) = -\frac{\pi}{4}\)
-
-
You can type strict inequalities using
<and>.- Use
\leqfor \(\leq\) and\geqfor \(\geq\). - Use
|...|for absolute values.
- Use
Calculus Formulas
-
\liminserts a limit. In inline mode, subscripts are typeset compactly. In display mode, they are written below the limit as normal.-
$\lim_{x \to 2} f(x)$becomes \(\lim_{x \to 2} f(x)\) -
$$\lim_{x \to 2} f(x)$$becomes \(\displaystyle\lim_{x \to 2} f(x)\)
-
-
Use the
'symbol when typesetting derivatives like \(f'\), and use brackets[...]when writing \(\dfrac{d}{dx}[2x]\). Otherwise, derivatives are typed using the same LaTeX tools from before.-
f'(x) = 2\cos(2x)becomes \(f'(x) = 2\cos(2x)\) -
\frac{dy}{dx}becomes \(\frac{dy}{dx}\) -
\frac{d}{dx}[2x]becomes \(\frac{d}{dx}[2x]\) -
\frac{d}{dx}[2x]becomes \(\frac{d}{dx}[2x]\) -
If you are taking the derivative of some functions in display mode, your brackets will look too short. You can use
\left[ ... \right]instead, and they will scale appropriately -
$$\frac{d}{dx}\left[\frac{1}{x}\right]$$becomes \(\displaystyle\frac{d}{dx}\left[\frac{1}{x}\right]\)
-
-
\intinserts an integral symbol. You must add thedxyourself.-
\int x dxbecomes \(\int x dx\), which is not correct, since there should be a space betweenxand thedx -
\,inserts a small space. -
\int x \,dxbecomes \(\int x \,dx\) which is much clearer. -
\intis formatted differently based on inline versus display mode.-
$\int_1^2 x^2 \,dx$becomes \(\int_1^2 x^2 \,dx\) -
$$\int_1^2 x^2 \,dx$$becomes \(\displaystyle \int_1^2 x^2 \,dx\)
-
-
-
\suminserts a summation symbol. Note that this looks like a Greek\Sigma, but actually the\sumcommand is more intelligent in the placement of limits.-
$\sum_{n=1}^{\infty} \frac{1}{n}$becomes \(\sum_{n=1}^{\infty} \frac{1}{n}\) -
$$\sum_{n=1}^{\infty} \frac{1}{n}$$becomes \(\displaystyle\sum_{n=1}^{\infty} \frac{1}{n}\)
-
-
Multivariable Calculus uses the same main concepts, with a few extra symbols.
-
Partial derivatives can be written using standard LaTeX, plus
\partialfor the partial derivative symbol \(\partial\) -
f_x(2,1)becomes \(f_x(2,1)\) -
\frac{\partial}{\partial x}[ 2xy ]= 2ybecomes \(\frac{\partial}{\partial x}[ 2xy ] = 2y\) -
Double and triple integrals can be typeset using
\iintfor \(\iint\) and\iiintfor \(\iiint\). -
\iint_D f(x,y)\,dAbecomes \(\iint_D f(x,y)\,dA\) -
\iiint_V f(x,y,z)\,dVbecomes \(\iiint_V f(x,y,z)\,dV\) -
For path integrals, you may want to make some letters bold, and write others in script.
-
Use
\mathbf{...}for math bold font.\mathbf{F}becomes \(\mathbf{F}\) -
Use
\mathcal{...}for math calligraphy font.\mathcal{C}becomes \(\mathcal{C}\) -
\int_{\mathcal{C}} \mathbf{F}\cdot d\mathbf{r}becomes \(\int_{\mathcal{C}} \mathbf{F}\cdot d\mathbf{r}\)
-
Additional Symbols
Mathematicians frequently use symbols for definitions and shorthands. You can start with an in depth list of LaTeX math symbols, or consult the commonly used symbols below.
- Common lowercase Greek letters in mathematics:
| \( \alpha\) | \( \beta\) | \( \gamma\) | \( \delta\) | \( \theta\) | \( \epsilon\) | \( \eta\) |
|---|---|---|---|---|---|---|
\alpha |
\beta |
\gamma |
\delta |
\theta |
\epsilon |
\eta |
| \( \lambda\) | \( \mu\) | \( \nu\) | \( \xi\) | \( \rho\) | \( \sigma\) | \( \tau\) |
|---|---|---|---|---|---|---|
\lambda |
\mu |
\nu |
\xi |
\rho |
\sigma |
\tau |
| \( \phi\) | \( \varphi\) | \( \chi\) | \( \psi\) | \( \omega\) | ||
|---|---|---|---|---|---|---|
\phi |
\varphi |
\chi |
\psi |
\omega |
\(\phantom{\omega}\) | \(\phantom{\omega}\) |
-
Common uppercase greek letters in mathematics:
\( \Gamma \)\Gamma, \( \Delta \)\Delta, \( \Lambda \)\Lambda, \( \Phi \)\Phi, \( \Psi \)\Psi, \( \Omega \)\Omega -
Natural language arguments
- \(\implies\)
\implies, \(\iff\)\iff
- \(\implies\)
-
Logic and Quantifiers
- \(\exists\)
\exists, \(\forall\)\forall - \(\land\)
\land, \(\lor\)\lor, \(\neg\)\neg, \(\rightarrow\)\rightarrow - \(\equiv\)
\equiv
- \(\exists\)
-
Sets
- \(\cup\)
\cup, \(\cap\)\cap, \(\overline{A}\)\overline{A} - \(x\in A\)
x \in A - Use
\{and\}to type open and close set brackets \({\ }\) - \(\subset\)
\subset, \(\subseteq\)\subseteq, \(\subsetneq\)\subsetneq - \(3 \in\mathbb{N}\)
3\in\mathbb{N}
- \(\cup\)
-
Other Comparisons
- \(\prec\)
\prec, \(\preceq\)\preceq - \(\sqsubset\)
\sqsubset, \(\sqsubseteq\)\sqsubseteq - \(\neq\)
\neq, \(\gg\)\gg, \(\ll\)\ll
- \(\prec\)
See also Section 3.10 of the Not So Short Guide to LaTeX
Linear Algebra
Create matrices using the \begin{bmatrix} ... \end{bmatrix} environment
- List out the entries from left to right, and top to bottom
- Separate columns using & and separate rows using \\
For example, the code
\begin{bmatrix}
1 & 2 & 3 \\
4 & 5 & 6
\end{bmatrix}
creates the matrix \(\begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{bmatrix}\)
Create a system of equations using the \begin{cases} ... \end{cases} environment.
- List the equations inside the environment
- Include a
\\after each equation - Place a
&symbol next to the equal signs to make the equations line up
For example, the code
\begin{cases}
2x - y &= 5 \\
x + y &= 1 \\
x &=-2 \\
y &= 3
\end{cases}
produces the output
\(\begin{cases} 2x - y &= 5 \\ x + y &= 1 \\ x &=-2 \\ y &= 3 \end{cases}\)
Create an aligned sequence of equations using the \begin{align} ... \end{align} environment.
- This is like the 'cases' environment, but you can use multiple & symbols to specify multiple points to align.
For example
\begin{align}
2&x - &y &= 5 \\
&x + &y &= 1 \\
&x & &=-2 \\
& &y &= 3
\end{align}
produces the output
\(\begin{align} 2&x - &y &= 5 \\ &x + &y &= 1 \\ &x & &=-2 \\ & &y &= 3 \end{align}\)
Learning More
In these notes, I have emphasized Markdown due to its greater simplicity and accessibility. But LaTeX is in many ways a more powerful and flexible language.
You can quickly use and learn about LaTeX using Overleaf.
-
Overleaf is popular browser-based LaTeX editor.
-
Learn LaTeX in 30 Minutes is a brief introduction to writing whole documents in LaTeX.
-
Writing Mathematics in LaTeX describes in detail how to write mathematics in LaTeX. However, many examples are embedded in LaTex (rather than Markdown) documents.
You can also install a LaTeX compiler on your personal computer.
- MiKTeX is a LaTeX distribution for Windows, Linux, and MacOS