LaTeX (pronounced "lay-tech", or sometimes "la-tech") is a markup language that is the standard for typesetting mathematics.

The way most people (including myself) learn LaTeX is by taking existing examples, tweaking them, and seeing what happens. To get started, you can open up and play with my LaTeX Homework Template that I have posted as a gist on GitHub. In fact, if you just click the link below, the template will open in Overleaf, which is an awesome and free online LaTeX editor.

You can insert mathematical expressions within your text (i.e., "inline") by using code of the form:

` $mathematical-expression-here$`

The pair of dollar signs that frame your mathematical expression are called *delimiters* and indicate where the expression begins and ends. You must have an opening and closing delimiter.

For instance, this sentence -- which includes the equation $x^{2}+y^{2} = r^{2}$ -- is typeset as

` For instance, this sentence -- which includes the equation $x^{2}+y^{2} = r^{2}$ -- is typeset as`

Notice that I didn't enclose every individual symbol with dollar signs, but rather the entire string of symbols.

You can also have your mathematical expressions separated from the text and placed on their own line for emphasis. For instance, if you wanted to type:

Here's some fancy mathematics that I don't really understand $$\log \zeta(s) = s\int_{2}^{\infty} \frac{\pi(x)}{x(x^{s}-1)}~dx = \log \prod_{p} (1-p^{-s})^{-1}.$$ Man, that's complicated!

then you'd use the code

```
Here's some fancy mathematics that I don't really understand
\[
\log \zeta(s) = s\int_{2}^{\infty} \frac{\pi(x)}{x(x^{s}-1)}~dx = \log \prod_{p} (1-p^{-s})^{-1}.
\]
Man, that's complicated!
```

Here are a few things to keep in mind:

- All inline mathematical notation must be framed by dollar signs.
- All displayed mathematical notation (i.e., on its own line and centered) is of the form
`\[ math-stuff \]`

. - All special symbols in LaTeX are of the form
`\some-command`

. Once you've used LaTeX enough, you can almost guess what the command is for a certain symbol.

Here are a few more examples that illustrate some of the mathematical notation we may want to use:

Expression you want | Code you type |
---|---|

$\int_a^b f(x)\; dx=F(b)-F(a)$ | `$\int_a^b f(x)\; dx=F(b)-F(a)$` |

$n \in \mathbb{N} \subseteq \mathbb{Z}$ | `$n \in \mathbb{N} \subseteq \mathbb{Z}$` |

$\sum_{i=1}^n i^2=1^2+2^2+ \cdots +n^2$ | `$\sum_{i=1}^n i^2=1^2+2^2+ \cdots +n^2$` |

$\sqrt{2} \notin \mathbb{Q}$ | `$ \sqrt{2} \notin \mathbb{Q}$` |

$2\in \{2,3,4\} \cap \{1,2,3\}$ | `$2\in \{2,3,4\} \cap \{1,2,3\}$` |

$f:A\to B$ | `$f:A\to B$` |

$f(x_1)\neq f(x_2)$ | `$f(x_1)\neq f(x_2)$` |

$\{a_n\}_{n=1}^{\infty}$ | ` $\{a_n\}_{n=1}^{\infty}$` |

$(f\circ g)(x)=f(g(x))$ | ` $(f\circ g)(x)=f(g(x))$` |

$\frac{a}{b}+\frac{c}{d}\neq \frac{a+b}{c+d}$ | ` $\frac{a}{b}+\frac{c}{d}\neq \frac{a+b}{c+d}$` |

Greek letters are typeset using `\name`

. For example, `\theta`

produces $\theta$ (as long as you also include the appropriate delimiters).

In order to produce a left or right brace, the brace needs to be preceded by a backslash. For example, to obtain $\mathbb{N}=\{1,2,3,\ldots\}$ we type `$\mathbb{N}=\{1,2,3,\ldots\}$`

and notice the use of `\{`

and `\}`

, which are needed to obtain the braces for the set.

Using LaTeX allows you to do fancy things like the following: $$\begin{align*} \sum_{i=1}^{k+1}i & = \left(\sum_{i=1}^{k}i\right) +(k+1) \newline & = \frac{k(k+1)}{2}+k+1 & (\text{by inductive hypothesis}) \newline & = \frac{k(k+1)+2(k+1)}{2} \newline & = \frac{(k+1)(k+2)}{2} \newline & = \frac{(k+1)((k+1)+1)}{2}. \end{align*}$$ which is typeset using

```
\begin{align*}
\sum_{i=1}^{k+1}i & = \left(\sum_{i=1}^{k}i\right) +(k+1) \newline
& = \frac{k(k+1)}{2}+k+1 & (\text{by inductive hypothesis}) \newline
& = \frac{k(k+1)+2(k+1)}{2} \newline
& = \frac{(k+1)(k+2)}{2} \newline
& = \frac{(k+1)((k+1)+1)}{2}.
\end{align*}
```

To correctly typeset double quotation marks in a full-fledged LaTeX document, you should use the following syntax; otherwise, the left pair of quotes will be backwards.

` ``stuff you are quoting"`

To obtain the symbols on the left, look for the key on your keyboard in the upper left corner that also has the the tilde (~) on it. You'll need to hit this key twice. Using incorrect quotation marks is one of the most common mistakes that I see in documents written using LaTeX.

A really cool tool for looking up LaTeX symbols is Detexify, which allows you to draw a picture of the symbol for which you are looking. Also, Dave Richeson of Dickinson College has put together a really great "cheat sheet", which you can find here.

If you want to see a really, really, really long list of symbols, go here.

Lastly, you may find the following resources useful:

Writing a LaTeX document is much more complicated than just starting to write. There are a whole host of things that you need to put at the top of your document and this can be rather intimidating at first. The big picture is that the content of your document comes after the line `\begin{document}`

. All of the stuff before this line is called the *preamble* and when you first start learning LaTeX, you should just ignore this stuff. Below, I've included some templates to get you started. In the beginning, don't worry too much about all of the complicated stuff in the preamble.

The .tex file is where you type the content of your file. You won't see the output until you *compile* it. If you've done everything correctly, the output after compiling will be a PDF. I highly recommend compiling often to see what you've got so far and to make it easier to find your syntax errors if you have any.

When you are typing the content of your document, you will partition your content into various *environments*. Examples of environments include: `theorem, proof, align*, itemize, enumerate`

, but there are lots more. Every environment begins with `\begin{environment-name}`

and ends with `\end{environment-name}`

. For example, see the example above that uses the `align*`

environment. As another example, if you wanted to write the statement of the theorem that divides is transitive, you would write:

```
\begin{theorem}
Let $a,b,c\in \mathbb{Z}$. If $a\mid b$ and $b\mid c$, then $a\mid c$.
\end{theorem}
```

*Note:* LaTeX ignores whitespace. What this means is that extra spaces and carriage returns (i.e., hitting the space bar or return/enter key repeatedly) have no impact on the output of the .tex document. You can adjust vertical spacing using commands like: `\newline, \bigskip, \medskip, \smallskip, \vspace{1cm}, \vfill`

. If you experiment with these commands, you'll be able to see what impact they have.

There are a growing number of online LaTeX editors. My favorite is Overleaf (formerly named WriteLaTeX). While there are several benefits of using an online editor, if you use LaTeX enough, you'll eventually want to install it locally on your own computer.

If you have a Mac, installing and using LaTeX is easy. All you need to do is go here and download the latest version of the MacTeX distribution (filename should be MacTeX.mpkg.zip). Once you have downloaded the package, double-click the installer (if it doesn't run automatically). If you follow the instructions during the installation, you will be provided with the LaTeX "backend" (which you can safely ignore) and the "frontend" editor TeXShop (which will be located in a folder called TeX in your Applications folder). TeXShop will be the default application for editing any file with a .tex extension. After editing a tex file, click "Typeset" and if you don't have any errors, TeXShop will render the corresponding PDF. I recommend clicking "Trash Aux Files" in the Console window after you are done editing. If you have questions about using TeXShop on a Mac, please ask!

To get up and running with LaTeX on a computer running Windows, you need to install two things. First, install the MiKTeX "backend", located here. Click the "download" link at the top of the list under MiKTeX Releases and following the instructions. Next, download TeXnicCenter by going here. Download the latest version and proceed according to the instructions. TeXnicCenter will now be your default application for editing any file with a .tex extension. You can safely ignore the MiKTeX "backend".

Most Linux distributions (e.g., Ubuntu, Debian, Fedora, etc.) use a package manager to install and update software. (Don't use a web browser to look for LaTeX online. Your computer already knows where to go online to find LaTeX and how to install it.) These instructions assume you are using Ubuntu, but similar actions will work on any Linux distro with a modern package management system. Using your package manager ("Ubuntu Software Center" or similar in your applications menu) and assuming you have an internet connection, you need to search for and install two things:

- A LaTeX backend: For the most basic install, search for and install "texlive-base". For a more comprehensive install, search for an install "texlive-full".
- A LaTeX editor: Search for and install "Kile". Kile is the editor of choice for many Linux users writing LaTeX.
- After Ubuntu installs these, you should find Kile in your applications menu and it should be capable of calling the various LaTeX programs automatically.

This page is an adaptation of Andy Schultz's Quick LaTeX Guide and Elisha Peterson's LaTeX Help. Thanks to Jason B. Hill for providing instructions for installing LaTeX on a computer running Linux. The mathematical symbols on this page were typeset using MathJax.

Mathematics & Teaching

Northern Arizona University

Flagstaff, AZ

Website

928.523.6852

Twitter

Instagram

Facebook

Strava

GitHub

arXiv

ResearchGate

LinkedIn

Mendeley

Google Scholar

Impact Story

ORCID

MAT 220: Math Reasoning

MAT 411: Abstract Algebra

This website was created using GitHub Pages and Jekyll together with Twitter Bootstrap.

Unless stated otherwise, content on this site is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.

The views expressed on this site are my own and are not necessarily shared by my employer Northern Arizona University.

The source code is on GitHub.