%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% IMPORTANT!!! %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Everything you need to edit comes after the line that says %%
%% "\begin{document}" below. Do not edit anything above that %%
%% line... unless you're familiar with LaTeX and you know %%
%% what you're doing. %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[11pt,fleqn]{article}
\usepackage[latin1]{inputenc}
\usepackage{enumerate}
\usepackage[hang,flushmargin]{footmisc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\theoremstyle{definition}
\newtheorem{theorem}{Theorem}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{example}[theorem]{Example}
\setlength{\oddsidemargin}{0px}
\setlength{\textwidth}{460px}
\setlength{\voffset}{-1.5cm}
\setlength{\textheight}{20cm}
\setlength{\parindent}{0px}
\setlength{\parskip}{10pt}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\begin{center}
{\Huge
\LaTeX{} class 2
}\\
Clive Newstead, Tuesday 11th July 2017
\end{center}
\section{Math mode}
By default, \LaTeX{} is in \textit{text mode}, which is used for typing words and sentences. If you want to type mathematical notation, you have to enter \textit{math mode}. This can be done in a few ways.
\subsection{In-line equations}
The easiest is by using dollar sign: one dollar sign enters math mode, and the next exits math mode---this gives an in-line equation. For example, you could write $E=mc^2$ or $a+b=c$. Notice how the variables appear italicised and the spacing is nice. Compare with: a+b=c.
All mathematical variables, symbols, equations and so on, should be entered in math mode. For example, three times two is $3 \times 2$, three plus two is $3 + 2$, and three divided by two is $\frac{3}{2}$ or $\dfrac{3}{2}$. You can do square roots $\sqrt{x^2+1}$ and cube roots $\sqrt[3]{x^3+1}$ and $n$th roots $\sqrt[n]{x^n+1}$. Exponents are easy, but make sure you use braces if needed: compare $a^b+1$ and $a^{b+1}$.
Notice that spaces are ignored in math mode do nothing: $abcdef$ versus $a b c d e f$. To make a space appear, put a backslash before it: $a\ b\ c\ d\ e\ f$. There are smaller and larger spaces too: $a\, b\; c\ d \quad e \qquad f$.
\subsection{Displayed equations}
Sometimes, either for emphasis or for readability, equations are put on their own line. This can be done using double dollar signs instead of single dollar signs. For example
$$\forall n \in \mathbb{N},\ \sum_{k=0}^n k = \frac{n(n+1)}{2}$$
If you want to enter text mode after you've already entered math mode, you can do using the `text' command, for example
$$\sum_{k=0}^n k = \frac{n(n+1)}{2} \text{ for all } n \in \mathbb{N}$$
If you want it to be enumerated, you can use the `equation' environment:
\subsection{Aligned equations}
If you have a chain of equations, you can make them line up nicely using the `align*' environment, which is another way of entering math mode. For example:
\begin{align*}
(n+1)!-n! & = (n+1) \cdot n! - n! && \text{by definition of factorial} \\
& = (n+1-1) \cdot n! && \text{common factor of $n!$} \\
& = n \cdot n! && \text{cancelling the $1$s}
\end{align*}
\end{document}