Section A.1 Introduction to LaTeX
Objectives
- Use Overleaf and LaTeX to typeset mathematics.
Example A.1.1. LaTeX example.
In LaTeX, the following code generates the text below. Can you guess what the commands mean by looking at the output?
Code:
Let's prove that \[ \sum_{i=1}^n i = \dfrac{n(n+1)}{2}\] using mathematical induction. The base case for $n = 1$ is clearly true, since $1 = \frac{1(2)}{2}$. Now assume that the claim is true for $n = k$; that is, \[ \sum_{i=1}^k i = 1 + 2 + \cdots + k = \dfrac{k(k+1)}{2}.\]
Output:
Let's prove that
\begin{equation*}
\sum_{i=1}^n i = \dfrac{n(n+1)}{2}
\end{equation*}
using mathematical induction.
The base case for \(n = 1\) is clearly true, since \(1 = \frac{1(2)}{2}\text{.}\)
Now assume that the claim is true for \(n = k\text{;}\) that is,
\begin{equation*}
\sum_{i=1}^k i = 1 + 2 + \cdots + k = \dfrac{k(k+1)}{2}\text{.}
\end{equation*}
\section{introduction}
line.
Press CTRL + Enter
to compile the document. The output should appear on the right.


\begin{document}
line is said to be the preamble of the documentβhere you will usually issue commands to LaTeX about global formatting options, packages you want installed, and so on.
In fact if you look at your First Project document, in line 14 there is an error message, denoted by the red X. Hover your cursor over it to see the message: Undefined control sequence
. The issue here is that the command \dfrac{ }{ }
that we used to generate
amsmath
package so we have access to all its commands, including \dfrac{ }{ }
. Just add the line \usepackage{amsmath}
to the preamble. It can be anywhere, but it is generally good practice to place all \usepackage
commands together, so type it in line 3. Now compile again by pressing CTRL + Enter
and the error message should disappear. The output on the right should be correct as well.
Most mathematics documents start by loading the packages
-
amsmath
for general mathematical features -
amsthm
for theorem-like environments -
amssymb
for even more symbols
$ $
around text renders that text as mathematics. Placing \[ \]
around text (or double dollar signs $$ $$
)renders that as display mathematics, centered in its own line. Have a look at this website for a list of commonly-used math symbols and try using Overleaf to typeset a number of results from these notes or another math textbook. Have fun and explore! This is where your LaTeX journey begins.
Next Steps and Resources.
This video is a very nice introduction to LaTeX by David Richeson and I highly recommend you take the time to watch it (35 minutes).
Here are some other helpful resources:
- David Richeson also has a PDF quick guide to LaTeX available on his website.
- Overleaf also has an introductory guide.
- Detexify for searching commands for symbols.
- TeXworks, if you would like to install LaTeX on your computer. (optional! only if you really want to...)