%%%%%%%%% Letter Size Macros %%%%%%%%%

%%%%%%%%% Normal-sized section headings %%%%%%%%%%%

\makeatletter % so @ can be used

\renewcommand{\section}{\@startsection{section}{1}{\z@}%
                                      {-3.5ex \@plus -1ex \@minus -.2ex}%
                                      {2.3ex \@plus.2ex}%
                                      {\reset@font\normalsize\bfseries}}
\renewcommand{\subsection}{\@startsection{subsection}{2}{\z@}%
                                         {-3.25ex\@plus -1ex \@minus -.2ex}%
                                         {1.5ex \@plus .2ex}%
                                         {\reset@font\normalsize\bfseries}}

\makeatother % so @ can no longer be used

%%%%%%%%% Standard page layout %%%%%%%%%%%

\tolerance=4000 \hbadness=3000 \hfuzz=1pt \vfuzz=1pt
\renewcommand{\baselinestretch}{1.09} % line spacing
\setlength{\oddsidemargin}{.65cm} % page margins
\setlength{\evensidemargin}{.65cm}
\setlength{\textwidth}{6in}
\setlength{\topmargin}{1cm}
\setlength{\headheight}{0cm}
\setlength{\headsep}{0cm}
\setlength{\textheight}{8in}
\setlength{\footskip}{2cm}

%%%%%%%%% Packages %%%%%%%%%%%

\usepackage{epic}
\usepackage{eepic}
\usepackage{latexsym}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{verbatim}
\usepackage{moreverb}
\usepackage{enumerate}
\usepackage{url}
\usepackage{theorem}
\usepackage{calc}
\usepackage{index}
\usepackage{alltt}

%%%%%%%%% New environments and commands %%%%%%%%%%%

\newenvironment{outdented}% Outdented paragraphs
{\begin{list}{}
{\setlength{\leftmargin}{\parindent}%
\setlength{\rightmargin}{0cm}%
\setlength{\itemindent}{-\parindent}%
\setlength{\listparindent}{-\parindent}%
\setlength{\topsep}{0cm}%
\setlength{\partopsep}{0cm}%
\setlength{\parsep}{0cm}%
\setlength{\labelsep}{0cm}%
\setlength{\labelwidth}{0cm}}%
\item[]}%
{\end{list}}

\newenvironment{proof}%
{\begin{trivlist}\item[]{\bf Proof.  }}%
{  {\everymath{}$\Box$}\end{trivlist}}
\newenvironment{proofof}[1]%
{\begin{trivlist}\item[]{\bf Proof of #1.  }}%
{  {\everymath{}$\Box$}\end{trivlist}}

\newenvironment{mtabbing}% math tabbing environment
{\begin{tabbing}\hspace*{\leftmargini}\=\+\kill$}%
{$\end{tabbing}}
\newcommand{\TS}{{}$\=\+${}}% for use with mtabbing environment
\newcommand{\NL}{{}$\\${}}% for use with mtabbing environment
\newcommand{\TSN}{{}$\=${}}% for use with mtabbing environment (no \+)
\newcommand{\NT}{{}$\>${}}% for use with mtabbing environment

% For Centered mtabbing's, within displaymath's
\newcommand{\mtab}[1]{\mbox{\kern-2.3ex\vbox{
\topsep 0pt\begin{mtabbing}#1\end{mtabbing}\kern-1ex}}}

% arrange for lines of verbatim environments to be indented
\makeatletter
\def\verbatim@processline{\hspace{\leftmargini}\the\verbatim@line\par}
\makeatother

% arrange for verbatim environments to have \small text
\makeatletter
\def\verbatim@font{\normalfont\ttfamily\small
                   \hyphenchar\font\m@ne
                   \let\do\do@noligs
                   \verbatim@nolig@list}
\makeatother

\newenvironment{ctabbing}% centered tabbing environment
{\begin{center}
\begin{minipage}{10in}
\begin{tabbing}}%
{\end{tabbing}
\end{minipage}
\end{center}}

% alltt environment in which text has size \small
% manually indent each line with \hspace{\leftmargini}
% (would be nice to automate this)
\newenvironment{myalltt}%
{\small\alltt}%
{\endalltt}

% theorem-like environments

\theoremstyle{break}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{conjecture}[theorem]{Conjecture}
\newtheorem{notation}[theorem]{Notation}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{openproblem}[theorem]{Open Problem}
\newtheorem{example}[theorem]{Example}
\newtheorem{counterexample}[theorem]{Counterexample}
{\theorembodyfont{\normalfont}
\newtheorem{definition}[theorem]{Definition}}
\newenvironment{ilemma}{\begin{lemma}}{  $\Box$\end{lemma}}
\newenvironment{icorollary}{\begin{corollary}}{  $\Box$\end{corollary}}
\newenvironment{iproposition}{\begin{proposition}}{  $\Box$\end{proposition}}
\newenvironment{itheorem}{\begin{theorem}}{  $\Box$\end{theorem}}
\newcommand{\theoremnumber}[1]{\setcounter{theorem}{#1-1}}

\newcommand{\clearemptydoublepage}{\newpage{\pagestyle{empty}\cleardoublepage}}

\newcommand{\abr}{\allowbreak}
\newcommand{\gbr}{\penalty1000 } % Allow break grudgingly
\newcommand{\hquad}{\;\;} % Half quad in math mode

\newcommand{\oper}[1]{\!\!\!& #1 &\!\!\!}% For use with eqnarray
\newcommand{\moper}[1]{\!\!& #1 &\!\!}% Medium size operator
\newcommand{\boper}[1]{\!& #1 &\!}% Big size operator

\newcommand{\by}[1]{\qquad({\textrm{#1}})}% Proof justification in display
\newcommand{\bylemma}[1]{\by{Lemma \ref{#1}}}
\newcommand{\bytheorem}[1]{\by{Theorem \ref{#1}}}
\newcommand{\bycorollary}[1]{\by{Corollary \ref{#1}}}
\newcommand{\byproposition}[1]{\by{Proposition \ref{#1}}}

\newcommand{\den}[1]{[\![#1]\!]}% Denotation of

% Right adjusted labels
\newlength{\rlablen}% A command to right adjust #2 in a box the width of #1
\newcommand{\rlab}[2]{\settowidth{\rlablen}{#1}\makebox[\rlablen][r]{\rm #2}}

\newcommand{\tsub}[1]{_{\textstyle #1}}% Bigger sub and superscripts
\newcommand{\tsup}[1]{^{\textstyle #1}}

\newcommand{\fun}{\mathbin{\to}}% Functions and restriction
\newcommand{\map}[3]{{#1} \colon {#2} \fun {#3}}
\newcommand{\restr}{\mathord{\mid}}

\newcommand{\pair}[2]{\langle #1 , #2 \rangle}% Various tupling constructs
\newcommand{\triple}[3]{\langle #1 , #2, #3 \rangle}
\newcommand{\ntuple}[1]{\langle #1_1 , \ldots, #1_n \rangle}
\newcommand{\mtuple}[1]{\langle #1_1 , \ldots, #1_m \rangle}
\newcommand{\nproduct}[1]{#1_1 \times \cdots \times #1_n}
\newcommand{\nsum}[1]{#1_1 + \cdots + #1_n}
\newcommand{\nset}[1]{\{ #1_1 , \ldots, #1_n \}}
\newcommand{\nlist}[1]{#1_1 , \ldots, #1_n}
\newcommand{\tupof}[2]{\langle \, #1 \mid #2 \, \rangle}

\newcommand{\singseq}[1]{\langle #1 \rangle}% Sequences
\newcommand{\emptyseq}{\langle \, \rangle}

\newcommand{\setof}[2]{\{ \, #1 \mid #2 \, \}}% Sets
\newcommand{\singset}[1]{\{ #1 \}}
\newcommand{\powset}[1]{{\cal P} #1}
\newcommand{\union}{\bigcup}
\newcommand{\sub}{\subseteq}% Subset

\newcommand{\dle}{\sqsubseteq}% Domain theory
\newcommand{\dge}{\sqsupseteq}
\newcommand{\ole}{\preceq}
\newcommand{\oge}{\succeq}
\newcommand{\lub}{\bigsqcup}
\newcommand{\glb}{\bigsqcap}% Available in Alan Jeffrey's package
\newcommand{\meet}{\sqcap}
\newcommand{\join}{\sqcup}

\newcommand{\cle}{\mathrel{\raisebox{0ex}[1.5ex][.4ex]{% Curly relations
\raisebox{.25ex}{$\sqsubset$}%
\kern-1.75ex%
\raisebox{-.9ex}{$\sim$}}}}
\newcommand{\cge}{\mathrel{\raisebox{0ex}[1.5ex][.4ex]{%
\raisebox{.25ex}{$\sqsupset$}%
\kern-1.75ex%
\raisebox{-.9ex}{$\sim$}}}}

\newcommand{\eqtxt}[1]{\;\abr\mbox{#1}\abr\;}% Spacing in math
\newcommand{\eqtxtl}[1]{\;\abr\mbox{#1}\abr}
\newcommand{\eqtxtr}[1]{\abr\mbox{#1}\abr\;}
\newcommand{\eqtxtn}[1]{\abr\mbox{#1}\abr}

\newcommand{\casesdef}[4]{% Cases definition
\left\{ \begin{array}{ll}
#1 & #2 \\
#3 & #4
\end{array} \right.}

% macros for producing ascii symbols in typewriter font

\newcommand{\tildesym}{\symbol{'176}}       % produces ~
\newcommand{\underscoresym}{\symbol{'137}}  % produces _
\newcommand{\primesym}{\symbol{'047}}       % produces '
\newcommand{\quotesym}{\symbol{'042}}       % produces "
\newcommand{\uparrowsym}{\symbol{'136}}     % produces ^
