\documentclass[12pt,letterpaper]{article}
\usepackage{amsmath,amsthm,amsfonts,amssymb,amscd}
\usepackage{fullpage}
\usepackage{lastpage}
\usepackage{enumerate}
\usepackage{fancyhdr}
\usepackage{mathrsfs}
\usepackage[margin=3cm]{geometry}
\setlength{\parindent}{0.0in}
\setlength{\parskip}{0.05in}
% Edit these as appropriate
\newcommand\course{CS 22}
\newcommand\semester{Spring 2017} % <-- current semester
\newcommand\hwnum{1} % <-- homework number
\newcommand\banner{B00123456} % <-- your banner id
% Define new commands here!
\newcommand\Z{\mathbb{Z}}
\newcommand\sumover[2]{\sum_{#1}^{#2}}
\newenvironment{answer}[1]{
\subsubsection*{Problem \hwnum.#1}
}{\newpage}
\pagestyle{fancyplain}
\headheight 35pt
\lhead{\banner\\\course\ --- \semester}
\chead{\textbf{\Large \LaTeX \ Workshop}}
\rhead{\today}
\headsep 10pt
\begin{document}
\section{Text mode and math mode}
This is a line
break.
This is not a line
break.
\begin{center}
This is centered text.
\end{center}
Use \textit{italics} and \textbf{bold} text for emphasis.
\footnote{This is a footnote.}
Here is a nice formula with superscripts: $x^n + y^n = z^n$.
Longer formulas should be displayed:
\[
\sum_{i = 1}^{100} i^2 = \frac{100 \cdot 101 \cdot 201}{6}.
\]
Formulas display differently in displayed and inline mode!
The same thing in inline mode is:
$\sum_{i = 1}^{100} i^2 = \frac{100 \cdot 101 \cdot 201}{6}$.
Anything with a $\sum$ or similar character should usually be
displayed.
Text mode and math mode are entirely different!
Commands and symbols that work in one may or may not work in the
other.
If you are in math mode and want to write text,
use \textbackslash{}\texttt{text}:
\[
x = 3 \text{ and } y = 5
\]
Note that spaces have to be explicitly included in the text environment.
Math mode eats up spaces.
Also keep in mind that quotation marks must be written specially:
``like this''.
\section{Special characters}
As you have seen,
backslash (\textbackslash{}) is used to indicate a command in \LaTeX.
Backslash and other characters have a special meaning in LaTeX.
These characters need to be escaped.
To get the regular character, usually just add a backslash
before it:
\[
\$ \quad \% \quad \& \quad \{ \quad \} \quad \_
\]
Some characters are a little more complicated
(you will probably not need some of these characters):
\[
\hat{ } \quad \backslash{} \quad \sim
\]
% This is a comment!
\section{Lists}
There are two sorts of lists.
Bulleted lists:
\begin{itemize}
\item This
\item is
\item a
\item bulleted
\item list.
\end{itemize}
Enumerated lists:
\begin{enumerate}
\item This
\item is
\item an
\item enumerated
\item list.
\end{enumerate}
This description environment isn't really a list,
but it's a useful way to
informatively split a proof into clear
components.
\begin{description}
\item[Reflexivity]
Proof that the relation is reflexive...
\item[Symmetry]
Proof that the relation is symmetric...
\item[Transitivity]
Proof that the relation is transitive...
\end{description}
\section{More symbols and useful commands}
Here are some useful math mode fonts:
\[
\mathbb{Z}^{+} \quad \mathbb{Q} \quad \mathbb{R} \quad \mathcal{P}
\]
Important commands:
\[
\frac{22}{7} + \sqrt{22 + 7} + \binom{22}{7}
\]
Use left and right parentheses correctly for big expressions:
\[
x = f\left( 1 + \frac{1}{1 + \frac{1}{1}}\right)
\]
This can be done with other types of delimiters:
\[
x = \left\{ \frac{1}{2}, \frac{2}{3}, \frac{3}{4} \right\}
\]
Quantifiers:
\[
\forall \quad \exists
\]
Set stuff:
\[
\in \quad \notin \quad \subseteq \quad \supseteq \quad
\nsubseteq \quad \varnothing \quad
\cup \quad \cap \quad
\left\{x \in \mathbb{N} \mid x \leq 5, x \geq 2 \right\}
\]
Miscellaneous:
\[
\times \quad \rightarrow \quad \ldots \quad \cdots
\]
Will be useful later:
\[
\neg \quad \vee \quad \wedge \quad 10 \equiv 3 \pmod{7}
\quad \implies \quad \iff
\]
\section{More on Typesetting Math}
In addition to inline math and display math,
there is aligned math:
\begin{align}
x &= 3 (5 y + 10) \\
&= 3 \cdot (5 y) + 3 \cdot 10 \\
&= 15y + 30
\end{align}
Notice that numbers automatically appear next to each line
in the align environment. This makes it super
convenient to refer to results you've already
typed up! Be careful though: all numbers
automatically shift if you delete a line of the equation.
If you want to get rid of the numbers, use the
align* environment:
\begin{align*}
x &= 3 (5 y + 10) \\
&= 3 \cdot (5 y) + 3 \cdot 10 & \text{by the distributive property}\\
&= 15y + 30
\end{align*}
Notice how we added a little note to justify a particular line.
If you include another \&, the align environment will place
what comes after in another column.
If you want to number a single equation, you can't do so in
normal display math mode. What you want is the equation
environment:
\begin{equation}
x = A \times B
\end{equation}
Notice how the numbering picks up right where we left off!
This is the proof environment:
\begin{proof}
This is a proof.
\end{proof}
\section{Other}
You can include graphics with the `includegraphics' package.
You can also create custom commands, provided they don't already exist.
Check out the shortcut for the set of integers, defined at the very top
of the LaTeX:
\[
\Z
\]
You can also create custom commands that take in a certain number of
arguments:
\[
\sumover{1}{n}i
\]
\end{document}
%