\documentclass[12pt]{article}
\usepackage{url,amsmath,setspace,amssymb}
\usepackage{listings}

\setlength{\oddsidemargin}{.25in}
\setlength{\evensidemargin}{.25in}
\setlength{\textwidth}{6.25in}
\setlength{\topmargin}{-0.4in}
\setlength{\textheight}{8.5in}

\newcommand{\heading}[5]{
   \renewcommand{\thepage}{#1-\arabic{page}}
   \noindent
   \begin{center}
   \framebox[\textwidth]{
     \begin{minipage}{0.9\textwidth} \onehalfspacing
       {\bf COM S 6830 -- Cryptography} \hfill #2

       {\centering \Large #5
       
       }\medskip

       {\it #3 \hfill #4}
     \end{minipage}
   }
   \end{center}
}

\newcommand{\handout}[3]{\heading{#1}{#2}{Instructor:
Rafael Pass}{TA: Dustin Tseng}{Handout #1: #3}}

\newcommand{\proof}{{\bf Proof. }} %% To begin a proof write \proof
\newcommand{\qed}{\mbox{}\hspace*{\fill}\nolinebreak\mbox{$\rule{0.6em}{0.6em}$}} %%to end your proof write $\qed$.
\newcommand{\ma}{{\mathcal A}}
\newcommand{\mf}{{\mathcal F}}
\newcommand{\hs}{\heartsuit}
\newcommand{\cs}{\clubsuit}
\newcommand{\noi}{\noindent}
\newtheorem{lemma}{Lemma}
\newtheorem{theorem}[lemma]{Theorem}
\newtheorem{definition}{Definition}
\newtheorem{proposition}{Proposition}
\bibliographystyle{plain}
\DeclareMathOperator{\E}{\mathbb{E}}      % expectation operator (probability operator already defined)

\begin{document}
\handout{2}{Sep 4, 2009}{\LaTeX}
\section{A Section Title}
A paragraph of text. The easiest way to learn {\LaTeX} is to read the source of this file.
We can type variables like $x$ and $y$,
functions like $f(x, y)$, sets like $\{ (x, y) \mid f(x, y) = 0 \}$.
We can also write equations in display mode (instead of inline):
\[ f(x, y) = \sin(x) \cos(y) \]

\section{Formatting Text}
We can organize text with sections, subsections, and paragraphs. For example:
\subsection{This is a Subsection}
\paragraph{This is the start of a labeled paragraph.} Followed by more text!

To start a plain new paragraph, just type an empty newline.
Sometimes bullets might help:
\begin{itemize}
  \item An idea
  \item Another idea
\end{itemize}
Or you might want to number them
\begin{enumerate}
  \item First idea
  \item Second idea
\end{enumerate}
Or you want to name the different ideas:
\begin{description}
  \item[To do 1:] Go to class.
  \item[To do 2:] Learn \LaTeX.
  \item[To do 3:] Hand-in beautifully typed homework to Dustin.
\end{description}

We might want a table. Say three columns that are left, center, and right justified.
Lets also center the table, and separate the columns with lines.
\begin{center}
  \begin{tabular}{|l|c|r|}
    \hline eeny & meeny & miny \\ % next row
    \hline moe & moe & moe  \\
    \hline
  \end{tabular}
\end{center}
Finally, we might want to allude some famous quote:
\begin{quote}
  So do all who live to see such times, but that is not for them to decide.
  All we have to decide is what to do with the homework that is given to us.
  \flushright -- Gandalf the Grey
\end{quote}

\section{Math Equations}
Here are subscripts and superscripts:
$x_1$, $y^2$, $e^{xy}$, $e^{x_1}$, $e^{e^x}$, $x_{t_1}$.
Again, it is probably easiest to learn by example
(including the use of macros in the source):

\newcommand{\set}[1]{\left\{ #1 \right\}} % macro for set notation
\newcommand{\inv}[1]{\frac{1}{#1}}        % macro for typesetting 1 over something

\[ \Pr[ X \le 1 ] \ge 1/2 \]
\[ \set{ a+b \mid a \in \Re, a \le \inv{2}, b \ge \frac{3}{a+4} }\]
\[ \E[ X \in \set{2, 3}] = 0.32 \]
\[
  f(x) =
  \begin{cases}
    1 & \mbox{if $x \ge 0$} \\
    0 & \mbox{otherwise}
  \end{cases}
\]
\begin{align*}
  f(x^2) &\ne f(x+x) & \mbox{just because} \\
  &=   f(2x)  & \mbox{by high school algebra} \\
         &\ne g \circ f(x)
\end{align*}
\begin{theorem}
  Assuming $\mathsf{P} \ne \mathsf{NP}$, we show that
  \[ 2 + 2 = 4 \]
\end{theorem}
\proof
We can break 2 into $1+1$, and so:
\begin{align*}
  2+2 &= (1+1) + (1+1) \\
  &= ((1+1)+1)+1 \\
  &= (2 + 1) + 1 = 3 + 1 = 4
\end{align*}
\qed

Now I will include the source of this file:
\lstset{basicstyle=\ttfamily \scriptsize, stringstyle=\ttfamily, language=, breaklines=false}
\lstinputlisting{latexExample.tex}
\end{document}



