%\def\filename{ueatest.dtx}
%\def\filedate{19 Mar 2004}
%\def\docdate{19 Mar 2004}
%\def\fileversion{1.01}
%\iffalse
% Doc-Source file to use with LaTeX2e
% Copyright (C) 2000 Nicola Talbot, all rights reserved.
%\fi
% \MakeShortVerb{\"}
%
%\title{\texttt{ueatest.cls} v \fileversion\ : \LaTeXe\ class file for typesetting course tests}
%\author{N.L.C. Talbot}
%\date{\docdate}
%\maketitle
%
% \section{Introduction}
% This is the documentation for \texttt{ueatest.cls}, a class file
% for typesetting course tests. 
%
% \section{Available Commands}
% The following commands are supplied with this class file:
%
% \DescribeMacro{\university}
% \noindent To specify the name of the university, do
% "\university{"\meta{university name}"}".  By default
% this is: University of East Anglia.
%
% \DescribeMacro{\school}
% \noindent To specify the name of the school, do
% "\school{"\meta{school name}"}".  By default this
% is: School of Computing Sciences.
%
% \DescribeMacro{\semester}
% \noindent To specify the semester, do 
% "\semester{"\meta{semester}"}".  By default 
% this is the current semester. (The Autumn semester
% is considered to be from August to January (inc), and
% the Spring semester is considered to be the 
% remainder of the year.)
%
% \DescribeMacro{\theyear}
% \noindent To specify the year (that appears in the footer)
% do "\theyear{"\meta{year}"}".  By default this is the current year.
%
% \DescribeMacro{\course}
% \noindent The course code and course name are specified
% using the command:\\
%"\course{"\meta{code}"}{"\meta{name}"}".\\
% For example:
%\begin{verbatim}
%\course{CMP-1A4Y}{Programming --- Languages and Software Construction}
%\end{verbatim}
%
% \DescribeMacro{\lecturer}
% \noindent The course lecturer(s) can be specified using the command:\\
%"\lecturer{"\meta{name}"}"
%
% \DescribeMacro{\marks}
% \noindent The command "\marks{"\meta{num}"}" will print
% [\meta{num} marks] (or [\meta{num} mark] if \meta{num} is 1) 
% in the margin\footnote{The right margin, irrespective of one- or two-sided printing}.
% If the text is too wide it will overlap the main text, so you may want to put it on
% a following blank line.
% The style can be modified by changing the definition of \DescribeMacro{\marklabel}"\marklabel"
% By default it is defined to be:\\[5pt]
% "[\themark\ \markname]"\\[5pt]
% where "\themark" is the number \meta{num} passed as the argument to "\marks" and
% "\markname" is either "mark" or "marks" depending on whether "\themark" is 1 or greater than 1,
% respectively.  So to change the marks to be displayed, say, in round brackets instead
% of square brackets, you would need to do:\\[5pt]
% "\renewcommand{\marklabel}{(\themark\ \markname)}"\\[5pt]
% To change it so that the marks are percentages, you can do:\\[5pt]
% "\renewcommand{\marklabel}{[\themark\%]}"\\[5pt]
% \DescribeMacro{\markformat}%
% The mark label is formatted according to the command
% "\markformat".  By default, "\markformat" is defined
% to be\\[5pt] "\marginpar{\makebox[\marginparwidth][r]{\marklabel}}"\\[5pt]
% but can be redefined.  For example, instead of placing the
% marks in the margin, you might want them flushright instead,
% in which case you could redefine "\markformat" as follows:\\[5pt]
%"\renewcommand{\markformat}{\hfill\marklabel}"\\[5pt]
% \DescribeMacro{\markscale}You can rescale your marks by changing the value of "\markscale".
% For example, if all your marks are out of 10, but you then decide to make them out of
% 100, you would need to multiply all current marks by 10:\\[5pt]
% "\renewcommand{\markscale}{10}"\\[5pt]
% \DescribeMacro{\markfrac}%
% You can also divide the marks by changing the value of "\markfrac".
% Both "\markscale" and "\markfrac" must be integers.
%
% \DescribeMacro{\date}
% \noindent The date is the current date by default, but
% can be changed using the command:
%"\date{"\meta{date}"}"
%
% \section{Example Documents} 
%
% \begin{enumerate}
% \item This example changes the marks so that they are displayed in sans-serif
% and aligns them flushright instead of in the margin.
%\begin{verbatim}
%\documentclass{ueatest}
%
%\course{CMPS-MC22}{Mathematics and Algorithms for Bioinformatics}
%\lecturer{SJH/GCC}
%
%\renewcommand{\markformat}{\hfill\textsf{\marklabel}}
%
%\begin{document}
%
%\begin{enumerate}
%\item First question.\marks{10}
%
%\item Second question.
%   \begin{enumerate}
%      \item First part.\marks{5}
%      \item Second part.\marks{5}
%   \end{enumerate}
%\end{enumerate}
%
%\end{document}
%\end{verbatim}
%
% \item In this example, the marks were originally out of 20,
% but it was then decided to change them to percentages.  This
% is easily done by setting "\markscale" to 5, and redefining
% "\marklabel"
%\begin{verbatim}
%\documentclass{ueatest}
%
%\course{CMPS-MC22}{Mathematics and Algorithms for Bioinformatics}
%\lecturer{SJH/GCC}
%
%\renewcommand{\marklabel}{[\themark\%]}
%\renewcommand{\markscale}{5}
%
%\begin{document}
%
%\begin{enumerate}
%\item First question.\marks{20}
%
%\item Second question.
%   \begin{enumerate}
%      \item First part.\marks{10}
%      \item Second part.\marks{5}
%      \item Third part.\marks{5}
%   \end{enumerate}
%\end{enumerate}
%
%\end{document}
%\end{verbatim}
%
% \item In this example, the marks were originally out of 75.
% To turn the marks into a percentage, they need to be multiplied
% by 4 and divided by 3. (This isn't guaranteed to work as integer
% division can cause rounding errors.)
%\begin{verbatim}
%\documentclass{ueatest}
%
%\course{CMPS-MC22}{Mathematics and Algorithms for Bioinformatics}
%\lecturer{SJH/GCC}
%
%\renewcommand{\marklabel}{[\themark\%]}
%\renewcommand{\markscale}{4}
%\renewcommand{\markfrac}{3}
%
%\begin{document}
%
%\begin{enumerate}
%\item First question.\marks{75}
%
%\item Second question.
%   \begin{enumerate}
%      \item First part.\marks{51}
%      \item Second part.\marks{18}
%      \item Third part.\marks{6}
%   \end{enumerate}
%\end{enumerate}
%
%\end{document}
%\end{verbatim}
% \end{enumerate}
%
% \section{Contact Details}
% Dr Nicola Talbot\\
% School of Computing Sciences\\
% University of East Anglia\\
% Norwich. NR4 7TJ.\\
% \url{http://theoval.cmp.uea.ac.uk/~nlct}
%
% \StopEventually{}
%
%\iffalse
%    \begin{macrocode}
%<*driver>
\documentclass{ltxdoc}
\usepackage[colorlinks,
            bookmarks,
            pdfauthor=Nicola Talbot,
            pdftitle={ueatest.cls : LaTeX2e class file for typesetting course tests}]{hyperref}
\OnlyDescription
\begin{document}\DocInput{ueatest.dtx}\end{document}
%</driver>
%    \end{macrocode}
%\fi
% \section{The Code}
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{ueatest}[2004/03/16 UEA course tests]
% 
\DeclareOption{a4paper}
   {\setlength\paperheight {297mm}%
    \setlength\paperwidth  {210mm}}
\DeclareOption{a5paper}
   {\setlength\paperheight {210mm}%
    \setlength\paperwidth  {148mm}}
\DeclareOption{b5paper}
   {\setlength\paperheight {250mm}%
    \setlength\paperwidth  {176mm}}
\DeclareOption{letterpaper}
   {\setlength\paperheight {11in}%
    \setlength\paperwidth  {8.5in}}
\DeclareOption{legalpaper}
   {\setlength\paperheight {14in}%
    \setlength\paperwidth  {8.5in}}
\DeclareOption{executivepaper}
   {\setlength\paperheight {10.5in}%
    \setlength\paperwidth  {7.25in}}
\DeclareOption{landscape}
   {\setlength\@tempdima   {\paperheight}%
    \setlength\paperheight {\paperwidth}%
    \setlength\paperwidth  {\@tempdima}}
\DeclareOption{10pt}{\def\@ptsize{0}}
\DeclareOption{11pt}{\def\@ptsize{1}}
\DeclareOption{12pt}{\def\@ptsize{2}}
\DeclareOption{oneside}{\@twosidefalse \@mparswitchfalse}
\DeclareOption{twoside}{\@twosidetrue  \@mparswitchfalse} % keep marginal notes on right
\DeclareOption{draft}{\setlength\overfullrule{5pt}}
\DeclareOption{final}{\setlength\overfullrule{0pt}}
\DeclareOption{leqno}{\input{leqno.clo}}
\DeclareOption{fleqn}{\input{fleqn.clo}}
\ExecuteOptions{a4paper,12pt,oneside,onecolumn,final}
%
\ProcessOptions
%
% This bit is an abridged version of article.cls
% ignore all sectioning commands, title page, table of contents etc
\input{size1\@ptsize.clo}
\setlength\lineskip{1\p@}
\setlength\normallineskip{1\p@}
\renewcommand\baselinestretch{}
\setlength\parskip{0\p@ \@plus \p@}
\@lowpenalty   51
\@medpenalty  151
\@highpenalty 301
\setcounter{topnumber}{2}
\renewcommand\topfraction{.7}
\setcounter{bottomnumber}{1}
\renewcommand\bottomfraction{.3}
\setcounter{totalnumber}{3}
\renewcommand\textfraction{.2}
\renewcommand\floatpagefraction{.5}
\setcounter{dbltopnumber}{2}
\renewcommand\dbltopfraction{.7}
\renewcommand\dblfloatpagefraction{.5}
\setlength\leftmargini  {2.5em}
\setlength\leftmarginii  {2.2em}
\setlength\leftmarginiii {1.87em}
\setlength\leftmarginiv  {1.7em}
\setlength\leftmarginv  {1em}
\setlength\leftmarginvi {1em}
\setlength\leftmargin    {\leftmargini}
\setlength  \labelsep  {.5em}
\setlength  \labelwidth{\leftmargini}
\addtolength\labelwidth{-\labelsep}
\@beginparpenalty -\@lowpenalty
\@endparpenalty   -\@lowpenalty
\@itempenalty     -\@lowpenalty
\renewcommand\theenumi{\arabic{enumi}}
\renewcommand\theenumii{\alph{enumii}}
\renewcommand\theenumiii{\roman{enumiii}}
\renewcommand\theenumiv{\Alph{enumiv}}
\newcommand\labelenumi{\theenumi.}
\newcommand\labelenumii{(\theenumii)}
\newcommand\labelenumiii{\theenumiii.}
\newcommand\labelenumiv{\theenumiv.}
\renewcommand\p@enumii{\theenumi}
\renewcommand\p@enumiii{\theenumi(\theenumii)}
\renewcommand\p@enumiv{\p@enumiii\theenumiii}
\newcommand\labelitemi{$\m@th\bullet$}
\newcommand\labelitemii{\normalfont\bfseries --}
\newcommand\labelitemiii{$\m@th\ast$}
\newcommand\labelitemiv{$\m@th\cdot$}
\newenvironment{description}
               {\list{}{\labelwidth\z@ \itemindent-\leftmargin
                        \let\makelabel\descriptionlabel}}
               {\endlist}
\newcommand\descriptionlabel[1]{\hspace\labelsep
                                \normalfont\bfseries #1}
\newenvironment{verse}
               {\let\\=\@centercr
                \list{}{\itemsep      \z@
                        \itemindent   -1.5em%
                        \listparindent\itemindent
                        \rightmargin  \leftmargin
                        \advance\leftmargin 1.5em}%
                \item[]}
               {\endlist}
\newenvironment{quotation}
               {\list{}{\listparindent 1.5em%
                        \itemindent    \listparindent
                        \rightmargin   \leftmargin
                        \parsep        \z@ \@plus\p@}%
                \item[]}
               {\endlist}
\newenvironment{quote}
               {\list{}{\rightmargin\leftmargin}%
                \item[]}
               {\endlist}
\setlength\arraycolsep{5\p@}
\setlength\tabcolsep{6\p@}
\setlength\arrayrulewidth{.4\p@}
\setlength\doublerulesep{2\p@}
\setlength\tabbingsep{\labelsep}
\skip\@mpfootins = \skip\footins
\setlength\fboxsep{3\p@}
\setlength\fboxrule{.4\p@}
\renewcommand\theequation{\arabic{equation}}
\newcounter{figure}
\renewcommand\thefigure{\@arabic\c@figure}
\def\fps@figure{tbp}
\def\ftype@figure{1}
\def\ext@figure{lof}
\def\fnum@figure{\figurename~\thefigure}
\newenvironment{figure}
               {\@float{figure}}
               {\end@float}
\newenvironment{figure*}
               {\@dblfloat{figure}}
               {\end@dblfloat}
\newcounter{table}
\renewcommand\thetable{\@arabic\c@table}
\def\fps@table{tbp}
\def\ftype@table{2}
\def\ext@table{lot}
\def\fnum@table{\tablename~\thetable}
\newenvironment{table}
               {\@float{table}}
               {\end@float}
\newenvironment{table*}
               {\@dblfloat{table}}
               {\end@dblfloat}
\newcommand\figurename{Figure}
\newcommand\tablename{Table}
\newlength\abovecaptionskip
\newlength\belowcaptionskip
\setlength\abovecaptionskip{10\p@}
\setlength\belowcaptionskip{0\p@}
\long\def\@makecaption#1#2{%
  \vskip\abovecaptionskip
  \sbox\@tempboxa{#1: #2}%
  \ifdim \wd\@tempboxa >\hsize
    #1: #2\par
  \else
    \hbox to\hsize{\hfil\box\@tempboxa\hfil}%
  \fi
  \vskip\belowcaptionskip}
\def\cal{\protect\pcal}
\newcommand{\pcal}{\@fontswitch{\relax}{\mathcal}}
\def\mit{\protect\pmit}
\newcommand{\pmit}{\@fontswitch{\relax}{\mathnormal}}
\newcommand\@pnumwidth{1.55em}
\renewcommand\footnoterule{%
  \kern-3\p@
  \hrule width .4\columnwidth
  \kern 2.6\p@}
\long\def\@makefntext#1{%
    \parindent 1em%
    \noindent
    \hbox to 1.8em{\hss\@makefnmark}#1}
\setlength\columnsep{10\p@}
\setlength\columnseprule{0\p@}
\pagenumbering{arabic}      % Arabic page numbers
\if@twoside
\else
  \raggedbottom
\fi

\newcommand{\today}{\ifcase\month \or January\or February\or March\or April\or May\or June\or July\or August\or September\or October\or November\or December\fi\ \the\day, \the\year}

% Now get on with the rest of it

\RequirePackage{calc}

\setlength{\oddsidemargin}{-0.50 cm}
\setlength{\evensidemargin}{-0.50 cm}
\setlength{\topmargin}{-1.5 cm}
\setlength{\textwidth}{16.3cm}
\setlength{\marginparwidth}{1.5 cm}
\setlength{\marginparsep}{0 cm}
\setlength{\textheight}{24.5 cm}
\setlength{\headsep}{0.25cm}
\setlength{\headheight}{1 cm}
\setlength{\footskip}{1cm}

% Remove the colon from the figure label
\renewcommand{\@makecaption}[2]{%
  \vskip\abovecaptionskip
  \sbox\@tempboxa{#1 #2}%
  \ifdim \wd\@tempboxa >\hsize
    #1 #2\par
  \else
    \global \@minipagefalse
    \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
  \fi
  \vskip\belowcaptionskip}
  
% Put third level enums in brackets
%\renewcommand{\labelenumiii}{(\theenumiii)}

% Now define the page styles

\def\ps@ueatest{%
\def\@oddhead{}
\def\@evenhead{}
\def\@oddfoot{\textit{\@ccode\ \coursetest}\hfill\thepage\hfill\textit{\@semester\ \@theyear}}
\def\@evenfoot{\textit{\@semester\ \@theyear}\hfill\thepage\hfill\textit{\@ccode\ \coursetest}}}

% Define the commands specific to this class file

\newcommand{\coursetest}{Course Test}

\newcommand{\@theyear}{\the\year}
\newcommand{\theyear}[1]{\renewcommand{\@theyear}{#1}}
 
\def\@ccode{}
\newcommand{\@cname}{}
\newcommand{\course}[2]{\renewcommand{\@ccode}{#1}\renewcommand{\@cname}{#2}}

\newcommand{\@university}{University of East Anglia}
\newcommand{\@University}{UNIVERSITY OF EAST ANGLIA}
\newcommand{\university}[1]{\renewcommand{\@university}{#1}
\renewcommand{\@University}{\uppercase{#1}}}

\newcommand{\@school}{School of Computing Sciences}
\newcommand{\school}[1]{\renewcommand{\@school}{#1}}

\newcommand{\@lecturer}{}
\newcommand{\lecturer}[1]{\renewcommand{\@lecturer}{#1}}

\edef\@semester{\ifnum\month>7\relax Autumn\else \ifnum\month=1\relax Autumn\else Spring\fi\fi}
\newcommand{\semester}[1]{\renewcommand{\@semester}{#1}}

\newcounter{mark}
\newcommand{\markscale}{1}
\newcommand{\markfrac}{1}
\newcommand{\markname}{\ifnum\c@mark=1\relax mark\else marks\fi}
\newcommand{\marklabel}{[\themark\ \markname]}
\newcommand{\markformat}{\marginpar{\makebox[\marginparwidth][r]{\marklabel}}}
\newcommand{\marks}[1]{\setcounter{mark}{#1*\markscale/\markfrac}\markformat}

\pagestyle{ueatest}

\AtBeginDocument{%
\mbox{}\hfill
\begin{tabular}{r}
\textbf{\@University}\\[10pt]
\textit{\@school}
\end{tabular}\\[20pt]
\underline{\bfseries\@ccode\ --- \@cname }\\[6pt]
\underline{\bfseries\MakeUppercase{\coursetest}}\par
}

\AtEndDocument{%
\par
\vfill
\@lecturer\par
\@date\par
}
%    \end{macrocode}
%\Finale
%\endinput

