% Ryan Adams
% Department of Computer Science
% Princeton University
% v0.03, 6 Dec 2019 -- For Princeton COS 302
% v0.02, 9 Sept 2018 -- For Princeton COS 324
% v0.01, 31 August 2013
% Based on HMC Math Dept. template by Eric J. Malm.
\NeedsTeXFormat{LaTeX2e}[1995/01/01]
\ProvidesClass{cos302}
[2018/09/09 v0.03 Princeton COS302 Assignment Class]

\RequirePackage{ifpdf}

\newif\ifhmlset@submit
\DeclareOption{submit}{%
  \hmlset@submittrue%
}
\DeclareOption{nosubmit}{%
  \hmlset@submitfalse%
}

\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ExecuteOptions{nosubmit}
\ProcessOptions\relax

\LoadClass[10pt,letterpaper]{article}

\newif\ifhmlset@header

\hmlset@headertrue

\RequirePackage{mathpazo}
\RequirePackage{palatino}
\RequirePackage{amsmath}
\RequirePackage{amssymb}
\RequirePackage{amsthm}
\RequirePackage{fullpage}
\RequirePackage{mdframed}
\RequirePackage[colorlinks=true,allcolors=orange]{hyperref}
\RequirePackage{bm}
\RequirePackage{newtxtext}
\RequirePackage{newtxmath}
\RequirePackage{listings}
\RequirePackage{courier}
\RequirePackage{graphicx}
\RequirePackage{xcolor}
\RequirePackage[shortlabels]{enumitem}
\RequirePackage{pdfpages}

\setlist[itemize]{noitemsep, topsep=0pt}
\setlist[enumerate]{topsep=0pt}

\newtheoremstyle{hmlplain}
                {13pt}% Space above
                {3pt}% Space below
                {}% Body font
                {}% Indent amount
                {\bfseries}% Theorem head font
                {\\*[3pt]}% Punctuation after theorem head
                {.5em}% Space after theorem head
                {}% Theorem head spec (can be left empty, meaning `normal')

\def\titlebar{\hrule height2pt\vskip .25in\vskip-\parskip}

\newcommand{\headerblock}{%
  \noindent\begin{minipage}{0.3\textwidth}
  \begin{flushleft}
  \ifhmlset@submit
    \mbox{\hmlset@name}\\
    \mbox{\tt \hmlset@email}\\
    \mbox{\hmlset@course}
  \fi
  \end{flushleft}
  \end{minipage}
  \noindent\begin{minipage}{0.4\textwidth}
  \begin{center}
    \mbox{\Large\hmlset@assignment}\protect\\
    Due: \hmlset@duedate
  \end{center}
  \end{minipage}
  \noindent\begin{minipage}{0.3\textwidth}
  \begin{flushright}
  \ifhmlset@submit
    Discussants: \hmlset@discussants
    \fi
  \end{flushright}
  \end{minipage}
  %\vspace{0.1cm}
  \begin{center}
  Upload at: \url{\hmlset@dropboxurl}
  \end{center}
  \titlebar
}

\ifhmlset@header\AtBeginDocument{\headerblock}\fi

\def\hmlset@name{}
\def\hmlset@email{}
\def\hmlset@course{}
\def\hmlset@assignment{}
\def\hmlset@duedate{}
\def\hmlset@discussants{}
\def\hmlset@extraline{}
\def\hmlset@dropboxurl{}

% commands to set header block info
\newcommand{\name}[1]{\def\hmlset@name{#1}}
\newcommand{\email}[1]{\def\hmlset@email{#1}}
\newcommand{\course}[1]{\def\hmlset@course{#1}}
\newcommand{\assignment}[1]{\def\hmlset@assignment{#1}}
\newcommand{\duedate}[1]{\def\hmlset@duedate{#1}}
\newcommand{\discussants}[1]{\def\hmlset@discussants{#1}}
\newcommand{\extraline}[1]{\def\hmlset@extraline{#1}}
\newcommand{\dropboxurl}[1]{\def\hmlset@dropboxurl{#1}}

\definecolor{verylightgray}{rgb}{0.92,0.92,0.92}
\definecolor{palegreen}{rgb}{0.455,0.573,0.482}

\lstdefinestyle{latex}{
   language=[LaTeX]TeX,
   backgroundcolor=\color{verylightgray},
   numbersep=5pt,
   xleftmargin=.25in,
   xrightmargin=.25in,
   texcsstyle=*\bf\color{blue},
   numbers=none,
   breaklines=true,
   keywordstyle=\color{red},
   commentstyle=\color{palegreen}
   }
\lstdefinestyle{markdown}{
   language=[],
   backgroundcolor=\color{verylightgray},
   numbersep=5pt,
   xleftmargin=.25in,
   xrightmargin=.25in,
   %texcsstyle=*\bf\color{blue},
   numbers=none,
   breaklines=true,
   keywordstyle=\color{red},
   commentstyle=\color{palegreen}
   }
\lstdefinestyle{python}{
   language=Python,
   backgroundcolor=\color{verylightgray},
   numbersep=5pt,
   xleftmargin=.25in,
   xrightmargin=.25in,
   %texcsstyle=*\bf\color{blue},
   numbers=none,
   breaklines=true,
   keywordstyle=\color{red},
   commentstyle=\color{palegreen},
   showstringspaces=false
   } 

\setlength{\parindent}{0em}
\setlength{\parskip}{1em}

\theoremstyle{hmlplain}
\newmdtheoremenv[skipabove=\topsep,skipbelow=\topsep,nobreak=true]{problem}{Problem}
%\newmdtheoremenv[skipabove=\topsep,skipbelow=\topsep,nobreak=true]{solution}%
%{Solution}
