\documentclass{article}

\usepackage{fullpage} % Include this if you want to cram lots of things on a page
 
\usepackage{amsmath} % these are standard macro packages of the American Mathematical Society
\usepackage{amssymb}
%\usepackage{stmaryrd}

\usepackage{epsfig} % if you want figures

\usepackage{fancyhdr} % These 4 lines are needed to set up the running  header
\fancyhead[LE,RO]{\LaTeX\ sample document}
\fancyhead[RE,LO]{\thepage}
\pagestyle{fancy}

\newcommand{\matlab}[1]
{\centerline{\parbox{.9\textwidth}{\noindent\textsc{\bf MATLAB:} #1}}}

\newcommand{\code}[1]{\texttt{#1}}

\newcommand {\x}{\V{x}}
\newcommand {\y}{\V{y}}
\newcommand {\V}[1]{\mbox{\boldmath$#1$}}

\begin{document}
\title{\LaTeX~sample document}
\author{Risi Kondor}
\maketitle
\mbox{}
\section*{Basic terms}
\vspace{12pt}
\subsection*{Number fields}

\begin{tabular}{l l}
\(\mathbb{N}\) & Natural numbers\\
\(\mathbb{Z}\) & Integer numbers\\ 
\(\mathbb{R}\) & Real numbers\\
\(\mathbb{C}\) & Complex numbers\\ 
\end{tabular}
\\

\subsection*{Vectors}
A row vector $\x$ and a column vector $\y$:
\begin{equation*}
  \begin{tabular}{ccc}
    $\x=\left(x_1,x_2,\ldots,x_N\right)$ & \qquad \qquad \qquad &
    $\y=\left(\begin{array}{c}y_1\\ y_2\\ \vdots \\ y_N\end{array}\right)$.\\ %\\
    %row vector & & column vector
  \end{tabular}
\end{equation*}
The set of $N$ dimensional real vectors is denoted $\mathbb{R}^N$, so $\x,\y\in\mathbb{R}^N$.
The $i$'th element of $\x$ is denoted $\left[\x\right]_i$ or sometimes (like above) 
just $x_i$. \\

\matlab{To define a row vector with elements $1,2,3$,  
type \code{x=[1,2,3]}. To define a column vector with the same elements, 
type \code{y=[1;2;3]}.}
\mbox{}

\subsection*{Matrices}

An $N\times M$ matrix:
\begin{equation*}
  A=\left(
  \begin{array}{cccc} 
    a_{11}& a_{12} & \ldots & a_{1M} \\ 
    a_{21}& a_{22} & \ldots & a_{2M} \\ 
    \vdots& & \ddots  & \vdots \\ 
    a_{N1}& a_{N2} & \ldots & a_{NM} \\ 
  \end{array}
  \right).
\end{equation*}
Note that the first index is the row index and the second index is the column index. 
The set of $N\times M$ real matrices is denoted $\mathbb{R}^{N\times M}$, so 
$A\in\mathbb{R}^{N\times M}$.
The $(i,j)$-element of $A$ is denoted $\left[A\right]_{i,j}$ or sometimes (like above) 
just $a_{ij}$.

\matlab{To define a matrix $A=\left(\begin{tabular}{cc}1&2\\3&4\end{tabular}\right)$, 
type \code{A=[1,2;3,4]}}.

%\subsection*{Other things you might need}

\section{Numbered section}
\subsection{Numbered subsection}
\subsubsection{Numbered subsubsection}

\section*{Section}
\subsection*{Subsection}
\subsubsection*{Subsubsection}

Unnumbered equation:
\begin{equation*}
  e^{-\left(x-x'\right)^2/(2\sigma^2)}.
\end{equation*}

\noindent Numbered equation:
\begin{equation}\label{my favorite equation}
  e^{i\pi}=-1
\end{equation}
Equation \ref{my favorite equation} is the most beautiful thing in the universe, as 
explained in \cite{greatAcademic}. 
If you have a citation database, you can also use \code{bibtex}. It is always good to include some figures, too, 
especially pretty ones like Figure \ref{fig: tree}. 

\begin{figure}[htbp] % these letters are preferences for where the figure should go: here, top, bottom, ...
  \centering
  \includegraphics[width=.4\textwidth]{three-regular.ps}
  \caption{Part of a three-regular tree}
  \label{fig: tree}
\end{figure}
If your you want to align equations, use \code{eqnarray}
\begin{eqnarray}
  1&=&\alpha_1+\alpha_2\\
  -1&=& \alpha_1-\alpha 2.  
\end{eqnarray}
If the reason you need a multiline display is that your equation is too long, you can also use 
\code{multline} to split it:
\begin{multline*}
K(i,j) =K^{(k)}_{\text{R}}(\,d(i,j))\;=\;
\frac{1}{2}\:{\pi(k - 1)}\int_0^\pi \frac{
e^{-\beta\left(1-{\scriptstyle \frac{2\sqrt{k-1}}{k}}\cos x\right)}}
{k^2-4\,(k -  1)\,\cos^2 x} \: \cdot\\ 
\tanh\left( \frac{1}{1+\frac{1}{1+\arctan \beta}} \right) 
\sin x\left[\,(k - 1)\sin(d +  1)\,x -\sin(d -  1)\,x\,\right]\,dx
\end{multline*}
Don't forget to put a little bit of space , for example \verb#\,# before the $dx$!  

To include text fixed with and with no formatting, use the \code{verbatim} package. 
If you need just a few symbols, like in this sentence, use the special form \verb^\verb#<text goes here>#^. 

Single line feeds in text mode are ignored, doble line feeds break the paragraph. 
Multiple spaces next to each other are treated as a single space, while math mode ignores spaces 
altogether. You need special commands like \verb#\,\#, \verb#\:#, \verb#\;#, \verb#\quad#, 
\verb#\!#, \verb#\hspace{}#, 
\verb#\hskip{}# and \verb#\fill# if you need to adjust the spacing.

Beginners often revel in vertical fractions, writing things like $e^{-\frac{x^2}{2\sigma^2}}$. 
A more serious abuse of the system is to use text mode for mathematics, for example 2x instead of $2x$, 
or math mode for text as in $R_{empirical}(f)$. The latter should be written \verb#R_{\text{{empirical}}(f)#, 
producing $R_{\text{empirical}}(f)$.

Delimiters often come in pairs, to get the sizes right, use \verb#\left# and \verb#\right#. 
In fact, you should always use them for $()$, $[]$, etc., even when you want the base size, 
because they help with spacing, too. It may help to define macros such as  
\begin{equation*}
  \verb^newcommand{\br}[1]{\left(#1\right)}^
\end{equation*}
allowing you to write \verb#\br{ }# instead of \verb#\left( \right)# every time. 
For conditional probabilities $p\left(x\mid y\right)$, sets, etc. you need \verb#\mid#, too. 
If the sizes stil don't come out right, you'll have to start playing around with \verb#\bigl#, 
\verb#\Bigl#, \verb#\biggl# and their right hand counterparts. 

\section*{Some useful symbols}

\centerline{
\begin{tabular}{|l|l|}
\hline 
Operators & $ \cdot\ \times\ \pm\ \mp\ \ast\ \circ\ \cup\ \cap\ \setminus$ \\
\hline 
Relation symbols & $\leq\ \geq\ \neq\ \not<\ \approx\ \sim\ \propto\ \in\ \ni\ \subset\ \subseteq\  \supset\ \supseteq$ \\
\hline
Delimiters & $ \Biggl(\biggl(\Bigl(\bigl(()\bigr)\Bigr)\biggr)\Biggr) \quad  
\Biggl[\biggl[\Bigl[\bigl[[]\bigr]\Bigr]\biggr]\Biggr] \quad 
\Biggl\{\biggl\{\Bigl\{\bigl\{\{\}\bigr\}\Bigr\}\biggr\}\Biggr\}\quad 
\Biggl\vert\biggl\vert\Bigl\vert\bigl\vert\vert\vert\bigr\vert\Bigr\vert\biggr\vert\Biggr\vert \quad 
\Biggl\Arrowvert\biggl\Arrowvert\Bigl\Arrowvert\bigl\Arrowvert
\Arrowvert\Arrowvert\bigr\Arrowvert\Bigr\Arrowvert\biggr\Arrowvert\Biggr\Arrowvert$\\
\hline
Arrows & $\to\ \mapsto\ \leftarrow\ \Leftarrow\ \Rightarrow\ \Longleftarrow\ \downarrow$\\
\hline
Dots & $1,2,\ldots,n\ \vdots\ \ddots$\\
\hline
Special & $\infty\ \blacksquare$\\  
\hline
Summation & $\displaystyle \sum\ \quad \sum_{i=1}^m$\\
\hline
Products & $\displaystyle \prod\ \quad \prod_{i=1}^m$\\
\hline
Integration & $\displaystyle \int_{0}^\infty f(x)\,dx$\\
\hline
\end{tabular}
}
\mbox{}\vspace{12pt}
\begin{thebibliography}{9}
\bibitem{greatAcademic} I. M. Haughty, Mathematics with not much meaning but great \ae sthetic appeal. 
Proceedings of winter skiing trip. March 29, 2003.
\end{thebibliography}

\end{document}

