\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage[usenames]{color}
\usepackage[all]{xy}
%% set margins
\topmargin=0in
\oddsidemargin=0in
\evensidemargin=0in
\textwidth=6.5in
\textheight=8.5in
%% define a command to make colored text
\newcommand{\com}[1]{\textcolor{blue}{[#1]}}
%% these commands create theorem environments.
%% the [theorem] parameter makes it so Theorems, Lemmas and Propositions
%% are numbered together, i.e., Theorem 1, Lemma 2, Proposition 3, Theorem 4
%% rather than Theorem 1, Lemma, Proposition 1, Theorem 2.
\newtheorem{theorem}{Theorem}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
%% some macros for dealing with 2x2 matrices
\def\mat#1#2#3#4{\left( \begin{array}{cc} #1 & #2 \\ #3 & #4 \end{array} \right)}
\def\vec#1#2{\left( \begin{array}{c} #1 \\ #2 \end{array} \right)}
%% some more commands
\DeclareMathOperator{\End}{End}
\newcommand{\Z}{\mathbf{Z}}
\newcommand{\R}{\mathbf{R}}
\let\wt\widetilde
\let\bs\backslash
\begin{document}
This note gives a few guidlines you should following when using latex, and some examples on how to
do certain common things (like commutative diagrams). Look at the source of this file to see how
the examples are done.
\section{Some things to do and to avoid}
What follows are mainly opinions of style, but I think they're widely agreed upon.
1. Do not begin sentences (or phrases) with math, and do not put math next to math. This is just to make
things easier to read. You should not write:
\begin{quote}
Suppose $X$ is a topological space and $x$ is a point in $X$. Since $x \in X$, $\pi_1(X, x)$ is
defined. $\pi_1(X, x)$ is a group.
\end{quote}
Problems: in the second sentence, $x \in X$ and $\pi_1(X, x)$ occur directly next to each other but are
not part of the same equation; also, the final sentence begins with math, which is no good. To fix these
problems without changing the structure of the sentences, I'd write
\begin{quote}
Suppose $X$ is a topological space and $x$ is a point in $X$. Since $x \in X$, we have that $\pi_1(X, x)$
is defined. Then $\pi_1(X, x)$ is a group.
\end{quote}
The idea is just to put in some filler words/phrases to separate the math. This makes the math more
spaced out and easier to read, though it can make the writing a bit dry. It's best to try to structure
sentences to avoid these filler words while still following the rule.
2. ``Romanize'' the names of operators and multi-letter functions. Write $\sin(x)$ and not $sin(x)$.
You can define commans in latex to typeset your own operator names correctly, for example $\End(V)$.
3. Use the correct size of parenthesis, braces, brackets, etc. The commands $\bs$left and $\bs$right
as well as $\bs$big and $\bs$bigg are useful for this. Some examples:
\begin{displaymath}
\left( x+\left( y+\tfrac{a}{b} \right)^2 \right)^{-1}
\end{displaymath}
\begin{displaymath}
\left\{ \frac{x}{y} \,\middle\vert\, \textrm{$y$ is not a power of 2} \right\}
\end{displaymath}
(Here the $\bs$, in the source is to add some space around the middle line.) Different size parentheses:
\begin{displaymath}
\big( \Big( \bigg(
\end{displaymath}
4. If you're going to put two equations in one displaymath environment, put some space between them. You
can do this with $\bs$quad or $\bs$qquad (or other commands like $\bs$hskip). So, do not write:
\begin{displaymath}
b=1+\sum_{i=1}^{10} a_i, c=x+y+z
\end{displaymath}
but instead:
\begin{displaymath}
b=1+\sum_{i=1}^10 a_i, \qquad c=x+y+z
\end{displaymath}
5. Change the margins! The default margins are much too big. Copy the
lines from the header of this file, or do it yourself.
6. Put big equations in displaymath environments and not inline. Example:
\begin{displaymath}
\sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6}.
\end{displaymath}
\section{Matrices}
Matrices are perhaps most easily done use the array environment, with the $\bs$left and $\bs$right commands to
get parentheses/brackets around them. Examples:
\begin{displaymath}
\left[ \begin{array}{ccc} 1 & 2 & 3 \\ x & y & z \\ p & q & r \end{array} \right], \qquad
\left( \begin{array}{cc} A & B \\ C & D \end{array} \right)
\end{displaymath}
I use a macro $\bs$mat and $\bs$vec for doing rank 2 matrices and vectors:
\begin{displaymath}
\mat{A}{B}{C}{D} \cdot \vec{x}{y}.
\end{displaymath}
\section{Commutative diagrams}
There are various packages to do commutative diagrams. I usually use xypic. I think it typically comes standard,
so you shouldn't need to download anything to use it, just put the appropriate usepackage command at the top of
your tex file. Here are some examples.
\begin{displaymath}
\xymatrix{
A \ar[d] & B \ar[l] \\ C \ar[r] & D \ar[u] }
\end{displaymath}
\begin{displaymath}
\xymatrix{
A \ar@{-->}[rd]_{\exists f} \ar[r]^g & B \ar[d]^h \\ & D }
\end{displaymath}
\begin{displaymath}
\xymatrix{
A \ar[rr]^f \ar[rd] && B \ar[ld] \\ & C }
\end{displaymath}
\section{Cases}
Here's how to make a formula with cases:
\begin{displaymath}
f(x)=\begin{cases}
\phi(x) & \textrm{for $x \in [0, 1]$} \\
\psi(x) & \textrm{for $x \in [1, 2]$} \\
\eta(x) & \textrm{for $x \in [2, 3]$}
\end{cases}
\end{displaymath}
\section{Multi-line equations}
Here's how to put a bunch of equations together, nicely aligned.
\begin{displaymath}
\begin{split}
\left[ \int_{-\infty}^{\infty} e^{-t^2} dt \right]^2
&= \int_{-\infty}^{\infty} \int_{-\infty}^{\infty} e^{-(x^2+y^2)} dx dy \\
&= \int_0^{\infty} \int_0^{2 \pi} e^{-r^2} r d \theta dr \\
&= 2 \pi \int_0^{\infty} r e^{-r^2} dr \\
&= \pi
\end{split}
\end{displaymath}
\end{document}