Objective: Experiment with mathematical notation in LaTeX.
Getting Started: Basic Equations¶
Inline vs Display Style¶
To add math to your documents, you first have to enter math mode. Math can be displayed inline or in math blocks (called display style). To render equations in inline style, enclose them in a pair of dollar signs $...$.
Inline: Using $x + y = z$ will display the equation in the line.
To render equations in display style, LaTeX offers several options. We suggest using \[...\] to start.
Display: Using \[ x + y = z \] will display the equation centered on its own line as below.
Simple Operators, Subscripts, Superscripts & More¶
To render simple equations, you also need to know syntax and commands for operators, relations, subscripts, superscripts, and fractions.
Operators & Relations:
+, -, =, >, < work as expected. Here are some other commands:
| Command | Display | Command | Display |
|---|---|---|---|
\times | \cdot | ||
\div | \pm | ± | |
\geq | \leq | ||
\neq | \approx |
Subscript: use the underscore (_) / Superscript: use the carret (^)
Example: $x^n+1$ gives but $x^{n+1}$ gives
Fractions:
To display a fraction, use the command \frac followed by the numerator and denominator in curly brackets.
Example: \frac{1}{x} gives
Exercise 1¶
Open a blank document in Overleaf and recreate this text in your document using LaTeX commands:
A quadratic equation is an equation of the form and such equations can be solved using the quadratic formula:
Commands needed: \frac{}{}, \pm, \sqrt{}
Challenge Exercise
Recreate these equations in your document:
Next Steps: Greek Letters, Integrals & More¶
Greek Letters¶
Many equations and formulas use Greek letters. The command is simple - just the backslash and the name of the letter. Capitalize the command to get the capital letter. Here are some examples:
| Command | Display | Command | Display |
|---|---|---|---|
\alpha | \mu | ||
\beta | \pi | ||
\Gamma | \rho | ||
\delta | \sigma | ||
\Delta | \Phi | ||
\lambda | \omega | ||
\Lambda | \Omega |
Limits, Integrals, Products & Sums¶
There are also commands for common operations that take upper and lower bounds:
Limits:
\[
lim_{x \to \infty} f(x)
\]results in
Integrals
\[
\int_{a}^{b} x^2 dx
\]results in
Products
\[
\prod_{i=a}^{b} f(i)
\]results in
Sums
What about summation ()?
Exercise 2¶
Recreate these equations in your Overleaf document:
Commands needed: \pi, \infty, \frac{}{}, \sum_{}^{}
Challenge Exercise
Recreate this text in your document:
Suppose that the measurable sets are “almost disjoint” in the sense that if . Prove that
Commands needed: \mu, \cap, \neq, \cup, \infty, \sum_{}, \geq
More Advanced: Math Packages¶
amsmath & amssymb Packages¶
LaTeX has many packages that you can use to extend its capabilities. The amsmath and amssymb packages provide you with additional symbols and commands for structuring equations.
To include them, add these commands to the preamble of your LaTeX document:
\usepackage{amsmath}
\usepackage{amssymb}
amsmath: Equations Environment¶
Use the \begin{equation}...\end{equation} command to include a numbered equation in display mode.
\begin{equation}
(I - A \otimes A) vec(X) = vec(Q)
\end{equation}results in
amsmath: Align Environment¶
The command \begin{align}...\end{align} will allow you to align a series of equations around a common element, which you can identify with the ampersand (&).
\begin{align}
\frac{d}{dx} \sin x &= \cos x \\
\frac{d}{dx} \cos x &= -\sin x \\
\frac{d}{dx} \tan x &= \sec^2 x
\end{align}results in
amsmath: Cases Environment¶
The amsmath package also offers the \begin{cases}...\end{cases} command, which enables you to display an equation with multiple cases.
\begin{equation*}
f(n) = \begin{cases}
0 & n=0 \\
1 & n=1 \\
f(n-1) + f(n-2) & \text{otherwise}
\end{cases}
\end{equation*}results in
amssymb¶
The amssymb package provides access to more options for mathematical symbols including additional fonts such as Blackboard-Bold.
More fonts:
\mathbb{R} gives for the set of real numbers.
More symbols:
\approxeq
\nleq
Alternate versions of symbols:
in plain LaTeX: \emptyset
with amssymb: \varnothing
Matrices¶
To create a matrix in your document, you can use the the {array} environment in plain LaTeX or the simpler {matrix} environment in the amsmath package.
\[
\begin{matrix}
a & b & c \\
d & e & f \\
\end{matrix}
\]results in a matrix with no brackets:
{pmatrix}
{bmatrix}
{vmatrix}
Exercise 3¶
Part A
Recreate these matrices in your Overleaf document:
Commands needed: \begin{bmatrix}...\end{bmatrix}, \begin{pmatrix}...\end{pmatrix}, \alpha, \beta, \gamma, \lambda, \mu, \nu, \rho, \sigma, \tau
Part B
Recreate this equation in your document:
Commands needed: \begin{equation*}...\end{equation*}, \int_{}, \Sigma, \sum_{}^{}, \frac{}{}, \partial, \rho, \text{}, \in, \infty, \mathbb{}