\RequirePackage{version}
\RequirePackage[newenum,newitem,neverdecrease]{paralist}
\RequirePackage{amsmath}
\RequirePackage{amssymb}
\RequirePackage{vmargin}
\RequirePackage{fancyhdr}
\RequirePackage{color}


%%%%% Questions and solutions %%%%%
\def\@myproof#1[#2]{\trivlist \item [\hskip\labelsep{\bf #1 {#2}: }]}
\def\@begproof#1{\@ifnextchar[{\@myproof{#1}}{\@myproof{#1}[\unskip$\,$]}}
\newenvironment{question}{\@question}{\@endquestion}
\definecolor{blu}{rgb}{0,0,0.5}
\newenvironment{Solutions}{\color{blu}\textbf{Solution:}}{}



%%%%% Margins %%%%%
\setpapersize[portrait]{USletter}

% Set page margins with header and footer
% Format: \setmarginsrb{left-margin}{top-margin}{right-margin}{bottom-margin}
% {head-height}{head-skip}{foot-height}{foot-skip}
\setmarginsrb{0.9in}{0.6in}{0.9in}{0.7in}{12pt}{12pt}{12pt}{16pt}


%%%%% Headers and Footers %%%%%
\pagestyle{plain}


%%%%% Modifications to paralist.sty %%%%%
\newcount\@markscnt\@markscnt=0

\let\@latexitem=\item
\let\@latextrivlist=\trivlist
\let\@paralistenumerate@\@enumerate@
\def\trivlist{\let\item=\@latexitem\@latextrivlist}

\def\@newitem@[#1]{\ifnum\@enumdepth=\@ne\advance\@markscnt #1\fi\def\marks{#1}\@latexitem}
\def\@newitem{\@ifnextchar[{\@newitem@}{\@latexitem}}
\def\@enumerate@{\@paralistenumerate@\let\item=\@newitem}

\def\@endquestion{%
    \ifnum\@enumdepth=\@ne
        \immediate\write\@auxout{\string\newlabel{TotalMarks}{{\the\@markscnt}{\thepage}}}%
    \fi\endenumerate}

\def\@question@#1[#2]{\setbox3=\hbox{#2}\def\marks{\hbox to\wd3{\hfil}}\enumerate[{[\marks]}~#1]}
\def\@question#1{\@ifnextchar[{\@question@{#1}}{\enumerate[#1]}}
\leftmargini 0pt


%%%%% Title page %%%%%
\def\course#1{\def\@course{#1}}
\def\duedate#1{\def\@duedate{#1}}
\def\anumber#1{\def\@anumber{#1}}
\def\dueword#1{\def\@dueword{#1}}
\def\assignmenttype#1{\def\@assignmenttype{#1}}

\dueword{due}
\assignmenttype{Assignment}

\AtBeginDocument{
    {\large
      \centerline{\@course}
      \centerline{\@assignmenttype{} \#\@anumber, \@dueword{} \@duedate}
    }\bigskip
}



%%%%% Standard useful macros %%%%%
\newcommand{\bN}{\mathbb{N}}
\newcommand{\bR}{\mathbb{R}}
\newcommand{\set}[1]{\{#1\}}
\newcommand{\setst}[2]{\left\{\; #1 \,:\, #2 \;\right\}}        % Set notation: { ... | ... }
\newcommand{\Union}{\bigcup}
\newcommand{\card}[1]{\lvert#1\rvert}
\DeclarePairedDelimiter{\ceil}{\lceil}{\rceil}
