%  This is a simple style file for 6.042 created by Eric Lehman in Fall 2004.
%  Here is a summary of the commands, excluding mathematical symbols and
%  theorem environments, which are defined at the end of the file.
%
%  \generic{title}{date}
%  \lecture{topic}{date}
%  \recitation{number}{date}
%  \problemset{number}{release date}{due date}
%  \showsolutions
%  \hidesolutions
%  \begin{problem}[POINT VALUE]
%    \bparts
%    \ppart
%    \eparts
%  \end{problem}
%  \solution[EXTRA SPACE]{...}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%  require other packages

\RequirePackage{ifthen}
\RequirePackage{amsmath}
\RequirePackage{amsthm}
\RequirePackage{amssymb}
\RequirePackage{xspace}
\RequirePackage{graphics}
\RequirePackage[usenames,dvipsnames]{color}
\RequirePackage[pdflatex]{graphicx}
\RequirePackage[
     colorlinks, bookmarksopen, pdfpagemode=UseOutlines,
    linkcolor=blue, citecolor=blue,
    urlcolor=blue, backref, pagebackref]{hyperref}
\RequirePackage{palatino}
\RequirePackage{textcomp}
\RequirePackage{enumerate}

\newcommand{\stamp}{%
  {\scriptsize{revised \today, \the\time\ minutes}}}

\newcommand{\coursename}{6.042/18.062J Mathematics for Computer Science}
\newcommand{\coursestaff}{Srini Devadas and Eric Lehman}

%  page format

\setlength{\parindent}{3ex}
\setlength{\parskip}{\medskipamount}
\hoffset        = -1.0 in
\voffset        = -1.0 in
\paperheight    = 11.0 in
\paperwidth     =  8.5 in
\topmargin      = 0.75 in
\headheight     = \baselineskip
\headsep        = \baselineskip
\footskip       = 1.00 in
\textheight     = \paperheight
\addtolength{\textheight}{-\topmargin}
\addtolength{\textheight}{-\headheight}
\addtolength{\textheight}{-\headsep}
\addtolength{\textheight}{-\footskip}
\textwidth      = \paperwidth
\oddsidemargin  = 1.0 in
\evensidemargin = 1.0 in
\addtolength{\textwidth}{-\oddsidemargin}
\addtolength{\textwidth}{-\evensidemargin}
\linewidth      = \textwidth

%  generic papers, lectures, recitations, problem sets

\newcommand{\generic}[2]{
  \noindent \coursename \hfill #2 \newline
  \coursestaff \vspace{-1.5ex} \newline
  \mbox{} \hrulefill \mbox{}
  \vspace{0.25in}
  \begin{center}
    {\Large \textbf{#1}}
  \end{center}
  \thispagestyle{plain}
  \pagestyle{myheadings}
  \thispagestyle{empty}
  \markboth{#1}{#1}
  }

\newcommand{\lecture}[2]{
  \noindent \coursename \hfill #2 \newline
  \coursestaff \hfill Lecture Notes \vspace{-1.5ex} \newline
  \mbox{} \hrulefill \mbox{}
  \vspace{0.25in}
  \begin{center}
    {\Large \textbf{#1}}
  \end{center}
  \thispagestyle{plain}
  \pagestyle{myheadings}
  \thispagestyle{empty}
  \markboth{#1}{#1}}

\newcommand{\recitation}[2]{
  \noindent \coursename \hfill #2 \newline
  \coursestaff \vspace{-1.5ex} \newline
  \mbox{} \hrulefill \mbox{}
  \vspace{0.25in}
  \begin{center}
    \ifthenelse{\boolean{showsolutions}}
               {\Large \textbf{Notes for Recitation #1}}
               {\Large \textbf{Problems for Recitation #1}}
  \end{center}
  \thispagestyle{plain}
  \pagestyle{myheadings}
  \thispagestyle{empty}
  \markboth{Recitation #1}{Recitation #1}}

\newcommand{\problemset}[3]{
  \noindent \coursename \hfill #2 \newline
  \coursestaff \vspace{-1.5ex} \newline
  \mbox{} \hrulefill \mbox{}
  \vspace{0.25in}
  \begin{center}
    \ifthenelse{\boolean{showsolutions}}
            {\Large \textbf{Problem Set #1 Solutions}}
            {\Large \textbf{Problem Set #1}}
  \end{center}
  \begin{center}
              \textbf{Due:} #3
  \end{center}
  \thispagestyle{plain}
  \pagestyle{myheadings}
  \thispagestyle{empty}
  \markboth{Problem Set #1}{Problem Set #1}}

\newcommand{\quiz}[2]{
  \noindent \coursename \hfill #2 \newline
  \coursestaff \vspace{-1.5ex} \newline
  \mbox{} \hrulefill \mbox{}
  \vspace{0.25in}
  \begin{center}
    \ifthenelse{\boolean{showsolutions}}
               {\Large \textbf{Quiz #1 Solutions}}
               {\Large \textbf{Quiz #1}}
  \end{center}
  \thispagestyle{plain}
  \pagestyle{myheadings}
  \thispagestyle{empty}
  \markboth{Quiz #1}{Quiz #1}}

\theoremstyle{definition}

%\newtheorem{problem}{Problem}

%%% new lines: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newtheorem{problemthm}{Problem}
\newenvironment{problem}
  {\begin{problemthm}%
   \pdfbookmark[1]{Problem~\theproblemthm}{Problem\theproblemthm}}
  {\end{problemthm}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcounter{problempart}
\renewcommand{\theproblempart}{\alph{problempart}}
\newcommand{\bparts}{
    \begin{list}{\textbf{(\alph{problempart})}}{\usecounter{problempart}}}

%\newcommand{\ppart}{\item}

%%% new lines: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\ppart}
  {\item%
   \pdfbookmark[2]{(\theproblempart)}{Problem\theproblemthm\theproblempart}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\eparts}{\end{list}}

\newboolean{showsolutions}
\newcommand{\showsolutions}{\setboolean{showsolutions}{true}}
\newcommand{\hidesolutions}{\setboolean{showsolutions}{false}}
\newcommand{\solution}[2][\vspace{0in}]{\ifthenelse{\boolean{showsolutions}}{\textbf{Solution.} #2}{#1}}
\newcommand{\insolutions}[1]{\ifthenelse{\boolean{showsolutions}}{#1}{}}
\newcommand{\instatements}[1]{\ifthenelse{\boolean{showsolutions}}{}{#1}}

%  text highlighting

\setlength{\fboxsep}{2ex}
\newlength{\textboxwidth}
\setlength{\textboxwidth}{\linewidth}
\addtolength{\textboxwidth}{-2\fboxrule}
\addtolength{\textboxwidth}{-2\fboxsep}

\newcommand{\floatingtextbox}[1]{
  \begin{figure}[htbp]
  \textbox{#1}
  \end{figure}}

\newcommand{\textbox}[1]{
  \begin{center}\fbox{\begin{minipage}[t]{\textboxwidth}
  \setlength{\parindent}{3ex}
  \setlength{\parskip}{\medskipamount}
  \vspace{0.5ex} #1 \vspace{0.5ex}
  \end{minipage}}\end{center}}

\newcommand{\textboxtitle}[1]{
  \begin{center}
  {\textbf{\Large #1}}
  \end{center}}

\newcommand{\term}[1]{\textbf{\textit{#1}}}

%  theorems

\theoremstyle{plain}
\newtheorem{theorem}{Theorem}
\newtheorem*{theorem*}{Theorem}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem*{lemma*}{Lemma}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem*{corollary*}{Corollary}
\newtheorem{claim}[theorem]{Claim}
\newtheorem*{claim*}{Claim}
\newtheorem{falseclm}[theorem]{False Claim}
\newtheorem*{falseclm*}{False Claim}
\newtheorem{conjecture}[theorem]{Conjecture}
\newtheorem*{conjecture*}{Conjecture}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem*{proposition*}{Proposition}
\newtheorem{axiom}{Axiom}
\newtheorem*{axiom*}{Axiom}
\newtheorem{mathrule}{Rule}
\newtheorem*{mathrule*}{Rule}
\newtheorem{fact}{Fact}
\newtheorem*{fact*}{Fact}
\newtheorem{definition}{Definition}
\newtheorem*{definition*}{Definition}
\newtheorem{guess}{Guess}
\newtheorem*{guess*}{Guess}

\newenvironment{bogusproof}
  {\begin{proof}
   \renewcommand{\qedsymbol}{$\times$}}
  {\end{proof}}

%  mathematics macros

\newcommand{\rem}{\operatorname{\,rem\,}}
\newcommand{\set}[1]{\left\{#1\right\}}
\newcommand{\seq}[1]{\left\langle#1\right\rangle}
\newcommand{\size}[1]{\left|#1\right|}
\renewcommand{\implies}{\Rightarrow}
\renewcommand{\iff}{\Leftrightarrow}
\newcommand{\floor}[1]{\left\lfloor#1\right\rfloor}
\newcommand{\ceil}[1]{\left\lceil#1\right\rceil}
\newcommand{\pr}[1]{\Pr\left(#1\right)}
\newcommand{\paren}[1]{\left(#1\right)}
\newcommand{\ex}[1]{\operatorname{Ex}\left(#1\right)}
\newcommand{\true}{\ensuremath{T}}
\newcommand{\false}{\ensuremath{F}}
\newcommand{\edge}[2]{#1\text{---}#2}
\newcommand{\arc}[2]{#1\!\longrightarrow\!#2}
