%%% =================================================================== %%% @LaTeX-file{ %%% filename = "uwaexam.dtx", %%% version = "0.99", %%% date = "1999/05/08", %%% time = "23:42:00 EST", %%% checksum = "53607 1131 4957 50371" %%% author = "Greg Gamble", %%% address = "Centre for Discrete Mathematics & Computing, %%% Department of Computer Science %%% & Electrical Engineering, %%% The University of Queensland, %%% Queensland 4072, %%% Australia", %%% telephone = "+61 7 336 52425," %%% FAX = "+61 7 336 54999, %%% copyright = "Copyright (C) 1999 Greg Gamble, %%% all rights reserved. Copying of this file is %%% authorised only if either: %%% (1) you make absolutely no changes to your copy, %%% including name; OR %%% (2) if you do make changes, you first rename it %%% to some other name.", %%% email = "gregg@csee.uq.edu.au (Internet)", %%% codetable = "ISO/ASCII", %%% keywords = "latex, amslatex, ams-latex, installation", %%% supported = "yes", %%% abstract = "This is class \cls{uwaexam}. It is built on the %%% standard \latex/ \cls{article} class %%% with option \opt{a4paper}. %%% It provides a document class for typesetting %%% exams at the University of Western Australia %%% with defaults suitable for the Department %%% of Mathematics & Statistics." %%% docstring = "The checksum field above contains a CRC-16 %%% checksum as the first value, followed by the %%% equivalent of the standard UNIX wc (word %%% count) utility output of lines, words, and %%% characters. This is produced by Robert %%% Solovay's checksum utility.", %%% } %%% =================================================================== % % \iffalse %<*driver> \documentclass{amsdtx} \newenvironment{ldemo}% {\begin{minipage}[l]{0.45\linewidth}} {\end{minipage}\hfill} \newenvironment{rdemo}% {\begin{minipage}[c]{0.50\linewidth}% \begin{quote}\slshape} {\end{quote}% \end{minipage}} \EnableCrossrefs \CodelineIndex \RecordChanges \begin{document} \title{The \cls{uwaexam} class} \author{Greg Gamble} \date{Version \fileversion, \filedate} \hDocInput{uwaexam.dtx} \end{document} % % \fi % % \maketitle % \tableofcontents % \markboth{THE \cls{UWAEXAM} CLASS}{} % % \changes{v0.9}{99/03/29}{First release} % \changes{v0.95}{99/04/04}{Automatic count of pages and questions % is now filled in on top of first page. % Command \cn{mks} added for assignment % of marks to questions and parts of % questions. (The original idea of % using the optional argument of \cn{item} % for this purpose was found to be unwieldy.) % Horizontal lines now appear between % questions and information now appears % about what to expect on the next page. % Instead of three different questions % environments, there is now only one, % namely the \env{qenum} environment, % emulating the \env{enumerate} environment.} % \changes{v0.96}{99/04/09}{Support for multiple \cn{coursenum}s % provided. Numbering bug in % \env{qenum} environment when any % form of \env{trivlist} environment % was used, fixed. Echoing of marks % allocated to questions implemented.} % \changes{v0.97}{99/04/14}{Mark totalling implemented. Continuation % information now appears at the top % of pages where a question continues % from the previous page. The \cn{section} % command now sets its heading flush % left correctly inside the % \env{qenum} environment.} % \changes{v0.98}{99/04/22}{The \env{instructions} environment % is now set by \cn{maketitle}. It % should now precede the \cn{maketitle} % command, and a warning is now emitted % if this is not the sequence. The % commands \cn{pagebreak} and % \cn{newpage} have been modified % slightly to check if \cn{item} or % \cn{section} is next and if so, issue % an \cn{endqitem} first. Also, % \cn{section} issues an \cn{endqitem} first. % A user of the \cls{uwaexam} class % should now never need to actually use % \cn{endqitem} explicitly. A % \cn{goodbreak} was added to % \cn{endqitem} to help \latex/ find % a pagebreak between questions. A % \opt{library} option was added to % make larger left margins for % binding. Bugs in the setting of % \cn{topmargin} were fixed, and % \cn{textheight} and \cn{textwidth} % were made slightly ($0.4\,$cm) % larger.} % \changes{v0.99}{99/05/08}{Added an optional argument to % \cn{coursenum}. Improved the documentation.} % % \makeatletter % \DoNotIndex{\@Alph,\@M,\@UX@rightmark,\@UXdisable,\@UXnewpage} % \DoNotIndex{\@UXnext,\@UXpagebreak,\@UXsection,\@alph,\@arabic} % \DoNotIndex{\@author,\@auxout,\@beginparpenalty,\@clubpenalty} % \DoNotIndex{\@course@in@rhead,\@course@in@title,\@@coursenum} % \DoNotIndex{\@coursenum,\@date,\@definecounter} % \DoNotIndex{\@dept,\@deptcode,\@donoparitem} % \DoNotIndex{\@duration,\@empty,\@endqitem,\@fnsymbol,\@gobbletwo} % \DoNotIndex{\@ifnextchar,\@inlabelfalse,\@inlabeltrue,\@inmatherr} % \DoNotIndex{\@institution,\@itemlabel,\@itempenalty,\@labels} % \DoNotIndex{\@lhead@xtra,\@librarytrue,\@makefnmark,\@makefntext} % \DoNotIndex{\@maketitle,\@minipagefalse,\@nbitem,\@ne} % \DoNotIndex{\@newlistfalse,\@ncoursenums,\@nobreakfalse} % \DoNotIndex{\@noitemargfalse,\@noitemargtrue,\@outerparskip} % \DoNotIndex{\@plus,\@prev@qenumctr,\@prev@qenummksctr,\@q@item} % \DoNotIndex{\@qenumctr,\@qenumdepth,\@qenummksctr} % \DoNotIndex{\@rightmark,\@roman,\@s,\@set@course@in@rhead} % \DoNotIndex{\@set@course@in@title,\@setinstructions,\@setinstructionsa} % \DoNotIndex{\@startsection,\@tempboxa,\@textsuperscript,\@thanks} % \DoNotIndex{\@thefnmark,\@title,\@toodeep,\@topsep,\@totalleftmargin} % \DoNotIndex{\@xp,\c@footnote,\c@qenumi,\c@qenumii,\c@qenumiii} % \DoNotIndex{\c@qenumiv,\c@section,\g@addto@macro,\hb@xt@,\if@inlabel} % \DoNotIndex{\if@library,\if@newlist,\if@nobreak,\if@noitemarg} % \DoNotIndex{\if@noparitem,\p@,\p@qenumii,\p@qenumiii,\p@qenumiv} % \DoNotIndex{\protected@write,\q@item,\skip@,\thr@@,\tw@,\z@} % \makeatother % % \newcommand{\sltt}[1]{{\slshape\texttt{#1}}} % \section{Introduction} % The file \fn{uwaexam.dtx} is the master file for the \latex/ % class, \cls{uwaexam}, which provides a class for exam preparation % at the University of Western Australia, with defaults % suitable for \latex/ users in the Department of Mathematics \& % Statistics Australia. It is built on the standard % \latex/ \cls{article} class with option \opt{a4paper}. % % \StopEventually{ % \begin{thebibliography}{9} % \addcontentsline{toc}{section}{\numberline{}Bibliography} % \bibitem{AmSLaTeX} American Mathematical Society, % \emph{\amslatex/ Version 1.2 User's Guide} (Jan.\ 1995). % Filename: \fn{amsldoc.dvi}. % \bibitem{source2e} J.~Braams, D.~Carlisle, A.~Jeffrey, L.~Lamport, % F.~Mittelbach, C.~Rowley, and R.~Sch\"opf, % \emph{The \LaTeXe\ Sources} (Jun.\ 1996). % Filename: \fn{source2e.dvi}. % \bibitem{uwamaths} G.~Gamble, % \emph{The \pkg{uwamaths} package}, % (Version 2.1, Nov.\ 1997). % Filename: \fn{uwamaths.dvi}. % Describes a general purpose package of macros for the % Mathematics Department of the % University of Western Australia. % \bibitem{Companion} M.~Goossens, F.~Mittelbach, and A.~Samarin, % \emph{The \latex/ Companion} (Addison-Wesley, 1994). % \bibitem{TeX} D.~E.~Knuth, % \emph{The \tex/book} % (Addison-Wesley, 1984). Describes \tex/ in detail. % \bibitem{LaTeX} L.~Lamport, % \emph{\latex/ -- A Document Preparation System} % (Addison-Wesley, first ed., 1985). Describes \latex/ 2.09. % \bibitem{LaTeXe} L.~Lamport, % \emph{\latex/ -- A Document Preparation System} % (Addison-Wesley, second ed., 1994). Updated for \LaTeXe. % \bibitem{clsguide} The \latex/3 Project, % \emph{\LaTeXe\ for class and package writers} (Jun.\ 1996). % Filename: \fn{clsguide.dvi}. % \end{thebibliography} % \DisableCrossrefs % \addcontentsline{toc}{section}{\numberline{}Index} % \PrintIndex % \addcontentsline{toc}{section}{\numberline{}Change History} % \PrintChanges % } % % \section{Implementation} % The usual name, date, and version information. % \begin{macrocode} \typeout{uwaexam 0.99} \NeedsTeXFormat{LaTeX2e} \ProvidesClass{uwaexam}[1999/05/08 v0.99] % \end{macrocode} % We build the class \cls{uwaexam} on top of \latex/'s % \cls{article} class with options \opt{a4paper}, % \opt{12pt}, and \opt{oneside}; but we % prefer to use a little more of the page. % % We also provide a \opt{library} option, which essentially % makes the left margin $1\,$cm larger and the right margin $1\,$cm % smaller, so that the University of Western Australia's % library has the $4\,$cm left margin it requires for binding. % \begin{macrocode} \DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}} \newif\if@library \DeclareOption{library}{\@librarytrue} \ProcessOptions\relax \LoadClass[a4paper,12pt,oneside]{article} % \end{macrocode} % The \cn{calclayout} command determines the value of % \cn{textheight}, \cn{topmargin} and \cn{oddsidemargin}, % from the values of \cn{paperheight}, \cn{textheight}, % \cn{textbodyheight}, \cn{textheight}, \cn{headheight}, % \cn{headsep}, \cn{footskip} and \cn{textwidth}. % It is loosely based on a command from the \cls{amsbook} class. % When the \opt{library} option is selected the text is % shifted right $1\,$cm so that the left margin is the % University of Western Australia library's required $4\,$cm % (so long as the user has \emph{not} changed the setting of % \cn{textwidth} below). % \begin{macrocode} \def\calclayout{\global\textheight\textbodyheight \global\advance\textheight -\headheight \global\advance\textheight -\headsep \global\advance\textheight -\footskip \global\oddsidemargin\paperwidth \global\advance\oddsidemargin -\textwidth \global\divide\oddsidemargin\tw@ \global\advance\oddsidemargin -1truein \global\evensidemargin\oddsidemargin \global\topmargin\paperheight \global\advance\topmargin -\textbodyheight \global\divide\topmargin\tw@ \global\advance\topmargin -1truein\relax \if@library \global\addtolength{\evensidemargin}{-1cm} \global\addtolength{\oddsidemargin}{1cm} \fi} % \end{macrocode} % Now we set the page parameters. We introduce a new % dimensional parameter \cn{textbodyheight} which is the % sum of \cn{headheight}, \cn{headsep}, \cn{textheight} and % \cn{footskip}, i.e.\ \cn{textbodyheight} is % \cn{pageheight} minus the top and bottom margins. We set % \cn{headsep} to zero so that any continuations appearing % at the top of the page (which are set in the page header) % appear immediately above the page text. The parameter % \cn{headheight} is initially set to 4 \cn{baselineskip} % and increased by 1 \cn{baselineskip}, by the % \cn{maketitle} command for each additional \cn{coursenum} % over two. We make no change to the \cls{article} class's % setting of \cn{footskip}. We set \cn{textbodyheight} to be % $4\,$cm less than \cn{paperheight} and \cn{textwidth} to be % $6\,$cm less than \cn{paperwidth}. With these settings the % \cn{calclayout} command centres the text so that the top % and bottom margins are each $2\,$cm and the left and % right margin are each $3\,$cm, except when the % \opt{library} option is applied in which case, the left % margin is increased by $1\,$cm and the right margin is % decreased by $1\,$cm. In this way, we comply with the wishes of % the University of Western Australia library which specifies that % the margin near the binding must be at least $4\,$cm % and other margins at least $2\,$cm, and the pagebreaks % occur in the same place when the option \opt{library} is % not selected. The setting of \cn{evensidemargin} (the left % margin on even-numbered pages) is ignored unless the user chooses % the \opt{twoside} option. We do a \cn{calclayout} after % setting the parameters, just in case the user for whatever % reason fails to use the \cn{maketitle} command. % It is not expected that the user will need to change the % page parameters in any way, but if she must the only % \emph{safe} ones to adjust are \cn{textbodyheight} and % \cn{textwidth}, and perhaps \cn{headsep} and % \cn{footskip}. One changes \cn{paperheight} and % \cn{textheight} ordinarily by choosing a % \cn{documentclass} option e.g.\ \opt{letterpaper} (the % default is \opt{a4paper}). % \begin{macrocode} \newdimen\textbodyheight \textbodyheight\paperheight \addtolength{\textbodyheight}{-4cm} \setlength{\textwidth}{\paperwidth} \addtolength{\textwidth}{-6cm} \normalsize \setlength{\headheight}{4\baselineskip} \setlength{\headsep}{0pt} \calclayout \setlength{\marginparsep}{4mm} \setlength{\marginparwidth}{12mm} % \end{macrocode} % We ensure that the \amslatex/ packages % \pkg{amsmath} \cite{AmSLaTeX} and \pkg{amsfonts} are loaded. % You get still more if you use % the \pkg{uwamaths} package \cite{uwamaths}. % \begin{macrocode} \RequirePackage{amsmath}\relax \ifx\relax\mathfrak \@xp\@gobbletwo \else \let\mathfrak\relax \fi \RequirePackage{amsfonts}\relax % \end{macrocode} % The following \amslatex/ command tells \latex/ to allow breaks % within maths displays but to avoid them as much as possible. % \begin{macrocode} \allowdisplaybreaks[1] % \end{macrocode} % Now we set up macros for the titlepage and headlines. % Firstly, we provide \cn{institution}, \cn{deptandcode}, % \cn{coursenum}, which define the \emph{institution} (by % default: \emph{University of Western Australia}), the % \emph{department} and \emph{department numerical code} (by % default: \emph{Mathematics} and \emph{539}), and the % \emph{course number} (which has two arguments, one of % which is optional). The optional argument for % \cn{coursenum} is used for specifying a course's % abbreviated \emph{name}, if there is one; and the main % argument is the course's 3-digit number, e.g.\ suppose the % course was known as \emph{Mathematics 1CS} and had full % numerical code \emph{539.170}, one would specify this % with: % \begin{quote}\slshape % \verb+\coursenum[1CS]{170}+ % \end{quote} % If on the other hand, the course does not have an % abbreviated name, (in the above example, the course is % known as simply: \emph{Mathematics 170}) one just omits % the optional argument: % \begin{quote}\slshape % \verb+\coursenum{170}+ % \end{quote} % (which is exactly equivalent to typing: % {\slshape\verb+\coursenum[170]{170}+}). % Ordinarily, of these, the user will only need to % use \cn{coursenum} and occasionally \cn{deptandcode}. If a % course has more than one number, \cn{coursenum} may be % used several times; each time, using the \emph{department} and % \emph{code} values from the most recent \cn{deptandcode} % command, i.e.\ for a course with numbers in two different % departments, say, the second \cn{coursenum} command should % be preceded by an appropriate \cn{deptandcode} command. % \begin{macrocode} \newcommand*{\institution}[1]{\def\@institution{#1}} \newcommand*{\deptandcode}[2]{\def\@dept{#1}\def\@deptcode{#2}} \def\coursenum{\@ifnextchar [\@coursenum\@@coursenum} \def\@@coursenum#1{\@coursenum[#1]{#1}} \def\@coursenum[#1]#2{% \@xp\@xp\@xp\g@addto@macro\@xp\@xp\@xp\@course@in@title% \@xp\@xp\@xp{\@xp\@xp\@xp\@set@course@in@title\@xp\@xp\@xp{% \@xp\@dept\@xp}\@xp{\@deptcode}{#1}{#2}}% \@xp\@xp\@xp\g@addto@macro\@xp\@xp\@xp\@course@in@rhead% \@xp\@xp\@xp{\@xp\@xp\@xp\@set@course@in@rhead\@xp\@xp\@xp{% \@xp\@dept\@xp}\@xp{\@deptcode}{#2}}% \global\advance\@ncoursenums by1\relax \ifnum\@ncoursenums >2 \global\addtolength{\headheight}{1\baselineskip} \g@addto@macro\@lhead@xtra{\\\ } \fi} \institution{University of Western Australia} \deptandcode{Mathematics}{539} \newcount\@ncoursenums \@ncoursenums=0 \let\@lhead@xtra\@empty \global\addtolength{\headheight}{1\baselineskip} \let\@course@in@title\@empty \let\@course@in@rhead\@empty % \end{macrocode} % Now we provide the command \cn{duration}, which is the % time-length of the \emph{exam}, and by default % we set to: \emph{Three hours}. (The reason we chose not to % call the command \cn{time} is that \cn{time} is already a % \tex/ command!) % \begin{macrocode} \newcommand*{\duration}[1]{\def\@duration{#1}} \duration{Three hours} % \end{macrocode} % Now we define defaults for \cn{title} which is used to define % the type of examinations being held, and the \cn{date}. % \begin{macrocode} \title{\ifnum\month<7 First Semester Examinations% \else Annual Examination% \fi} \date{\ifnum\month<7 June \else November \fi \the\year} % \end{macrocode} % We don't set the \cn{author} of an exam in the paper % itself \dots\ but we retain it and type it out when the % document is typeset. Since the \cn{author} is not set at % the beginning of the paper, this also removes \latex/'s usual % warning if \cn{author} is absent. % \begin{macrocode} \def\author#1{\typeout{Paper prepared by #1.}} % \end{macrocode} % Now we provide an \env{instructions} environment, which is % just a doublespaced \env{center} environment. % \begin{macrocode} \newbox\instructionsbox \newenvironment{instructions}% {\ifx\maketitle\relax \ClassWarning{uwaexam} {instructions should precede \protect\maketitle}% \fi \global\setbox\instructionsbox=\vtop \bgroup \center\normalfont\doublespacing\normalsize} {\endcenter\hrulefill\egroup \vskip\@outerparskip \ifx\@setinstructions\relax \@setinstructionsa \fi} \def\@setinstructions{\@setinstructionsa \global\let\@setinstructions\relax} \def\@setinstructionsa{% \ifvoid\instructionsbox \else \skip@20\p@ \advance\skip@-\lastskip \advance\skip@-\baselineskip \vskip\skip@ \box\instructionsbox \prevdepth\z@ % because \instructionsbox is a vtop \fi} % \end{macrocode} % Now we define the \cn{maketitle} command to set these on % the first page of the exam. % \begin{macrocode} \renewcommand\maketitle{\par \calclayout \begingroup \renewcommand\thefootnote{\@fnsymbol\c@footnote}% \def\@makefnmark{\rlap{\@textsuperscript{\normalfont\@thefnmark}}}% \long\def\@makefntext##1{\parindent 1em\noindent \hb@xt@1.8em{% \hss\@textsuperscript{\normalfont\@thefnmark}}##1}% \@maketitle \endgroup \setcounter{footnote}{0}% \global\let\thanks\relax \global\let\maketitle\relax \global\let\@maketitle\relax \global\let\@thanks\@empty \global\let\@author\@empty \global\let\title\relax \global\let\author\relax \global\let\date\relax \global\let\and\relax } \def\@set@course@in@title#1#2#3#4{% \\\vspace*{0pt} \\\vspace*{0pt}\hfill\MakeUppercase{#1\ #3}% \hfill\llap{#2.#4}} \def\@maketitle{\cleardoublepage \thispagestyle{firstpage}% \skip@-\headheight \ifnum\@ncoursenums >2\relax \advance\skip@\@ncoursenums\baselineskip \advance\skip@-2\baselineskip \fi \vspace*{\skip@} \begingroup \singlespacing\normalsize \begin{center} \@institution \end{center} \MakeUppercase{\@title}\hfill\MakeUppercase{\@date} \@course@in@title\par \begin{flushright} \begin{tabular}{l@{}} This paper contains:\\ \pageref{q:@last} pages.\\ \ref{q:@last} questions. \end{tabular} \end{flushright} \begin{center} Time allowed : \MakeUppercase\@duration \end{center} \@setinstructions \endgroup% } % \end{macrocode} % Now we modify the \cn{section} command to typeset headers % such as: \verb+PART A+. We do not use \cn{part} here, % since \cn{part} was used for subquestions % in the plain \tex/ \fn{exam.tex} previously. % It is assumed that a new \cn{section} will not occur in % the middle of a question, and so an \cn{endqitem} is issued. % The \cn{sectionmark} command is also disabled. % The other sectioning commands of the \cls{article} class % are disabled, including \cn{part} which was used for subquestions % in the plain \tex/ \fn{exam.tex} previously. They % issue a warning message if used. % \begin{macrocode} \newdimen\linespacing \normalsize \setlength{\linespacing}{\baselineskip} \newdimen\normalparindent \setlength{\normalparindent}{18pt} \def\sectionname{PART} \renewcommand{\thesection}{\sectionname\ \@Alph\c@section} \def\section{\endqitem\@UXsection} \def\@UXsection{\@startsection{section}{1}% {-\@totalleftmargin}{.7\linespacing\@plus\linespacing}{.5\linespacing}% {\normalfont}} \renewcommand{\sectionmark}[1]{} \def\@UXdisable#1{\@xp\def\noexpand#1{\ClassWarning{uwaexam}% {Disabled command \noexpand#1}}} \@UXdisable\part \@UXdisable\subsection \@UXdisable\subsubsection \@UXdisable\paragraph \@UXdisable\subparagraph % \end{macrocode} % To get nice page headers we use the % \pkg{fancyhdr} package. % \begin{macrocode} \RequirePackage{fancyhdr} \renewcommand{\headrulewidth}{0pt} \def\@UX@rightmark{\@xp\@rightmark\topmark{}{}} \lhead{\ \\ \bfseries\@title\\ \bfseries\@date \normalfont\@lhead@xtra \\\ \\% \@UX@rightmark} \chead{} \def\@set@course@in@rhead#1#2#3{\\\bfseries#1 : #2.#3} \rhead{\thepage. \@course@in@rhead \ifcase\@ncoursenums\\\ \\\ \or\\\ \fi\\\ \\\ } \cfoot{\leftmark} \pagestyle{fancy} \fancypagestyle{firstpage}{% \ifnum\@ncoursenums >2\relax \addtolength{\topmargin}{\baselineskip} \addtolength{\topmargin}{-\@ncoursenums\baselineskip} \else \addtolength{\topmargin}{-\baselineskip} \fi \fancyhf{} \fancyfoot[C]{\leftmark}} % \end{macrocode} % We make available some spacing macros. % The amounts of stretch are those specified % for $12\,$pt by the \emph{\latex/ Companion} \cite{Companion}. % Other font sizes differ from these only marginally. % See the \pkg{uwamaths} package \cite{uwamaths} % where the same macros are defined, for further discussion % of these macros. % \begin{macrocode} \newcommand{\singlespacing}{\renewcommand{\baselinestretch}{1}} \newcommand{\oneandhalfspacing}{\renewcommand{\baselinestretch}{1.24}} \newcommand{\doublespacing}{\renewcommand{\baselinestretch}{1.66}} % \end{macrocode} % We provide a \env{qenum} environment (\emph{q}uestion % \emph{enum}erate) which is based on \latex/'s \env{enumerate} % environment. By nesting \env{qenum} environments, one gets % parts and subparts of questions. % % We need to modify \latex/'s \cn{item} command % within \env{qenum}; in particular, we use the optional % argument for \emph{marks}. In order that \cn{item} will % work as usual for other \env{list} and \env{trivlist} environments, % we first save \latex/'s definition of \cn{item} as \cn{normalitem} % and redefine \cn{list} and \cn{trivlist} to first restore \cn{item} % as \cn{normalitem}. % Since \cn{part} was used for subquestions, and % \cn{partpart} was used for subsubquestions % in the plain \tex/ \fn{exam.tex} previously, inside the % \env{qenum} environment each is \cn{let} to \cn{item}. % \begin{macrocode} \let\normalitem\item \let\normallist\list \let\normaltrivlist\trivlist \def\list{\let\item\normalitem \normallist} \def\trivlist{\let\item\normalitem \normaltrivlist} \newcount\@qenumdepth \@qenumdepth=0 \@definecounter{qenummks} \setcounter{qenummks}{0} \@definecounter{qenumi} \@definecounter{qenummksi} \@definecounter{qenumii} \@definecounter{qenummksii} \@definecounter{qenumiii} \@definecounter{qenummksiii} \@definecounter{qenumiv} \@definecounter{qenummksiv} \def\qenum{\ifnum \@qenumdepth >\thr@@ \@toodeep% \else \edef\@prev@qenumctr{% qenum\romannumeral\the\@qenumdepth}% \edef\@prev@qenummksctr{% qenummks\romannumeral\the\@qenumdepth}% \advance \@qenumdepth \@ne \edef\@qenumctr{qenum\romannumeral\the\@qenumdepth}% \edef\@qenummksctr{% qenummks\romannumeral\the\@qenumdepth}% \@xp\list\csname label\@qenumctr \endcsname {\usecounter\@qenumctr% \let\item\q@item% \let\part\item \let\partpart\item% \setcounter{\@qenummksctr}{0}% \def\makelabel##1{\hss\llap{##1}}}% \fi} \def\endqenum{\addtocounter{\@prev@qenummksctr}% {\csname the\@qenummksctr\endcsname}% \typeout{Total marks \ifnum \@qenumdepth >1 \csname p@\@prev@qenumctr\endcsname% \csname the\@prev@qenumctr\endcsname: \else on paper: \fi \arabic{\@prev@qenummksctr}.}% \ifnum \@qenumdepth =1 \penalty\@M \addvspace\itemsep \hrulefill\\[-3ex] \vspace*{0pt}\hrulefill\par \label{q:@last} \protected@write\@auxout{}% {\string\newlabel{@total@mks}{{\arabic{qenummks}}{}}}% \markboth{}{} \fi% \endlist} \renewcommand\theqenumi{\@arabic\c@qenumi} \renewcommand\theqenumii{(\@alph\c@qenumii)} \renewcommand\theqenumiii{(\@roman\c@qenumiii)} \renewcommand\theqenumiv{(\@Alph\c@qenumiv)} \newcommand\labelqenumi{\theqenumi.} \newcommand\labelqenumii{\theqenumii} \newcommand\labelqenumiii{\theqenumiii} \newcommand\labelqenumiv{\theqenumiv} \renewcommand\p@qenumii{\theqenumi} \renewcommand\p@qenumiii{\theqenumi\theqenumii} \renewcommand\p@qenumiv{\p@qenumiii\theqenumiii} \settowidth\leftmargini{7.\hspace{\labelsep}} \settowidth\leftmarginii{(f)\hspace{\labelsep}} \settowidth\leftmarginiii{(vii)\hspace{\labelsep}} \settowidth\leftmarginiv{(F)\hspace{\labelsep}} % \end{macrocode} % Here follows \cn{q@item} our replacement for \cn{item}. % Essentially, we disable the optional argument, and warn % the user if they attempt to use it, add an \cn{hrulefill} % when the \env{qenum} depth is at the top level and % spit out \latex/ \cn{markboth} commands at appropriate % points (the bottommost \cn{markboth} command on a page is % set in the \cn{footline}. % \begin{macrocode} \let\endqitem\relax \def\q@item{\@inmatherr\item \endqitem% \@ifnextchar[\@q@item{\@noitemargtrue \@q@item[]}} \def\@endqitem{\let\endqitem\relax \ifnum \@qenumdepth =1 \markboth{SEE OVER}{\ }% \else \markboth{QUESTION \csname p@\@prev@qenumctr\endcsname% \csname the\@prev@qenumctr\endcsname\ CONTINUES OVER THE PAGE} {\csname p@\@prev@qenumctr\endcsname% \csname the\@prev@qenumctr\endcsname\ (Continued)}% \fi \if@newlist\else% \ifnum \@qenumdepth =1 \penalty\@M \addvspace\itemsep \hrulefill\penalty\z@ \goodbreak \else \vspace*{0pt} \penalty\@M \fi \fi} \def\@q@item[#1]{\let\endqitem\@endqitem \if@noparitem \@donoparitem \else\if@inlabel \indent \par \fi \ifhmode \unskip\unskip \par \fi \if@newlist \if@nobreak \@nbitem% \else% \addpenalty\@beginparpenalty \addvspace\@topsep \addvspace{-\parskip}% \fi \else \addpenalty\@itempenalty \addvspace\itemsep \fi \global\@inlabeltrue \fi \everypar{\@minipagefalse \global\@newlistfalse \if@inlabel \global\@inlabelfalse {\setbox\z@ \lastbox \ifvoid\z@ \kern -\itemindent \fi} \box\@labels \penalty\z@ \fi \if@nobreak \@nobreakfalse \clubpenalty \@M \else \clubpenalty\@clubpenalty \everypar{}% \fi} \if@noitemarg \@noitemargfalse \else\ClassWarning{uwaexam} {There is no optional argument for an ^^J\noexpand\item of the qenum environment. Use \noexpand\mks to allocate marks. ^^JOptional argument ignored} \fi \refstepcounter\@qenumctr \addtocounter{\@prev@qenummksctr}% {\csname the\@qenummksctr\endcsname} \setcounter{\@qenummksctr}{0} \sbox\@tempboxa{\makelabel{\@itemlabel}}% \global\setbox\@labels \hbox{\unhbox\@labels \hskip\itemindent \hskip -\labelwidth \hskip -\labelsep \ifdim \wd\@tempboxa >\labelwidth \box\@tempboxa% \else \hbox to\labelwidth {\unhbox\@tempboxa}% \fi% \hskip\labelsep}% \ignorespaces% \markboth{QUESTION \csname p@\@qenumctr\endcsname% \csname the\@qenumctr\endcsname\ CONTINUES OVER THE PAGE} {\csname p@\@qenumctr\endcsname% \csname the\@qenumctr\endcsname\ (Continued)}} % \end{macrocode} % Now we create the \cn{mks} command that typesets the marks % allocated to a question or part of a question. Also, the % command \cn{totalmks} gives the total marks allocated for % the paper; this can be used in the \env{instructions} % environment, for example. % \begin{macrocode} \def\mks#1{\ifnum #1=1\relax\def\@s{}\else\def\@s{s}\fi% \ \hphantom{[#1 mark\@s]} \addtocounter{\@qenummksctr}{#1}% \typeout{Marks for \csname p@\@qenumctr\endcsname% \csname the\@qenumctr\endcsname: #1.}% \hbox{}\nobreak\vspace*{0pt}\hfill\llap{[#1 mark\@s]}\par} \def\totalmks{\ref{@total@mks}} % \end{macrocode} % We redefine \cn{pagebreak} and \cn{newpage} to look ahead. % If they are followed by an \cn{item} or a \cn{section} then issue % an \cn{endqitem} first. The command \cn{endqitem} does any % business required between \cn{item}s of a \env{qenum} % environment. % \begin{macrocode} \let\normalpagebreak\pagebreak \def\pagebreak{\futurelet\@UXnext\@UXpagebreak} \def\@UXpagebreak{\ifx\@UXnext\item \endqitem% \else\ifx\@UXnext\section \endqitem\fi% \fi\normalpagebreak} \let\normalnewpage\newpage \def\newpage{\futurelet\@UXnext\@UXnewpage} \def\@UXnewpage{\ifx\@UXnext\item \endqitem% \else\ifx\@UXnext\section \endqitem\fi% \fi\normalnewpage} % \end{macrocode} % We set the normal spacing at \cn{oneandhalfspacing}, to % make for easy reading. % \begin{macrocode} \oneandhalfspacing % \end{macrocode} % That's it. % \begin{macrocode} \endinput % \end{macrocode} % \section{A sample exam} % Well that's it for the code. What follows is a typical % example in \sltt{slanted typewriter text}, interspersed % with comments and snapshots of what it will look like when % typeset. Some lines are preceded by a \sltt{\%}, % meaning the line is commented out; if these lines are % uncommented the effect will be the same (or in the case of % \cn{date} and \cn{title}, similar); usually, you will % \emph{not} need these lines at all, they are included so % users can see how to change some values from their defaults. % % Usually one will open the exam with the following sequence % \begin{quote}\slshape % \verb+\documentclass{uwaexam}+\\ % \verb+\usepackage{uwamaths}+\\ % \verb+\begin{document}+ % \end{quote} % though using the \pkg{uwamaths} package is not essential. % If the exam is destined for binding then one should use % the \opt{library} option i.e.\ the \cn{documentclass} line % should read: % {\slshape\verb+\documentclass[library]{uwaexam}+} % % Next, if needed, come \cn{institution}, \cn{title} and % \cn{date}. Normally none of these is necessary \dots\ but % occasionally, (e.g.\ setting a Mid-semester exam) it will % be necessary to specify \cn{title} and \cn{date}. The % values of \cn{title} and \cn{date} are automatically % determined to be \sltt{First Semester Examinations} % and \sltt{June YEAR}, respectively, during the first % six months of the year, and \sltt{Annual Examination} and % \sltt{November YEAR}, respectively, during the last six % months of the year, where \sltt{YEAR} is whatever the % current year is. % \begin{quote}\slshape % \verb+%\institution{University of Western Australia}+\\ % \verb+%\title{First Semester Examinations}+\\ % \verb+%\date{June 1999}+ % \end{quote} % Then one specifies the course number(s) for the exam. % The following lines specify that the exam is for the % course \sltt{Mathematics 1CS} with number \sltt{539.170}. % (Of course, substitute the appropriate value for \sltt{170}.) % Normally, one need not specify \cn{deptandcode}. % \begin{quote}\slshape % \verb+%\deptandcode{Mathematics}{539}+\\ % \verb+\coursenum[1CS]{170}+ % \end{quote} % The first argument of \cn{coursenum} is its abbreviated \emph{name}, % e.g.\ 1CS (might abbreviate \emph{1st Year Calculus and Statistics}, % and it's optional, since many courses are simply known by their % number. So: {\slshape\verb+\coursenum{170}+} would have % specified course \sltt{Mathematics 170} with number % \sltt{539.170}. % % A course may have several numbers, and those numbers may % be in different departments. Let's, for argument's sake % suppose that the above course is also known as % \sltt{Agriculture 175} (with number \sltt{704.175}). % We would specify this by: % \begin{quote}\slshape % \verb+\deptandcode{Agriculture}{704}+\\ % \verb+\coursenum{175}+ % \end{quote} % Now, if different, from \sltt{Three hours} we need to % specify the \cn{duration}: % \begin{quote}\slshape % \verb+%\duration{Three hours}+ % \end{quote} % Next comes the \env{instructions} environment. Here is an % example that also demonstrates how one can use the % \cn{totalmks} command. % \begin{quote}\slshape % \verb+\begin{instructions}+\\ % \verb+ All questions may be attempted. Each question+\\ % \verb+ is worth 10 marks.+\\ \ \\ % \verb+ There is a total of \totalmks\ marks available.+\\ % \verb+\end{instructions}+\\ % \end{quote} % Now issue a \cn{maketitle}: % \begin{quote}\slshape % \verb+\maketitle+ % \end{quote} % This sets all the data following % {\slshape\verb+\begin{document}+} that we have seen so % far, in the top of the first page, which should look % something like what's enclosed in the following box: % \makeatletter % \newcommand{\doublespacing}{\renewcommand{\baselinestretch}{1.66}} % \def\@institution{University of Western Australia} % \def\@title{First Semester Examinations} % \def\@date{June 1999} % \def\@dept{Mathematics}\def\@deptcode{539} % \def\@course@in@title{% % \\\vspace*{0pt}\hfill\MakeUppercase{Mathematics\ 1CS}% % \hfill\llap{539.170}\\\vspace*{0pt} % \\\vspace*{0pt}\hfill\MakeUppercase{Agriculture\ 175}% % \hfill\llap{704.175}} % \def\@duration{Three hours} % \def\@setinstructions{% % \center\normalfont\doublespacing\normalsize% % All questions may be attempted. % % There is a total of ? marks available. % \endcenter\hrulefill \vskip\@outerparskip} % \[\fbox{% % \begin{minipage}{0.95\linewidth} % \begin{center} % \@institution % \end{center} % \MakeUppercase{\@title}\hfill\MakeUppercase{\@date}\\\vspace*{0pt} % \@course@in@title\par % \begin{flushright} % \begin{tabular}{l@{}} % This paper contains:\\ % ? pages.\\ % ? questions. % \end{tabular} % \end{flushright} % \begin{center} % Time allowed : \MakeUppercase\@duration % \end{center} % \@setinstructions % \bigskip % \end{minipage}}\] % \makeatother % An abbreviation of the above is also set in the page headers % of subsequent pages. The question marks \texttt{?} % appearing in 3 places above (against the number of pages, % number of questions and for \cn{totalmks}) occur because % each uses a \cn{label} and so won't be filled in until a % second \latex/ pass. (These \cn{label}s are intended to be % \emph{internal}. If you must know, the number of pages and % the number of questions are \verb+\pageref{q:@last}+ and % \verb+\ref{q:@last}+, respectively; and \cn{totalmks} is % \verb+\ref{@total@mks}+. Essentially, if you avoid using % \verb+@+ in your \cn{label}s you will be safe.) % % Now for the exam proper. The essential ingredients are % the \env{qenum} environment which works like % \env{enumerate} (\env{qenum} may also be nested to four % levels like \env{enumerate}), and the command \cn{mks} % which sets the marks awarded to a question or part of % a question. Usually the right place to put \cn{mks} is % at the end of the text of an \cn{item}. The example below % demonstrates the use of \env{qenum} and \cn{mks} (the % result is on the left and the code to get that result % appears on the right). % \makeatletter % \def\theenumi{\@arabic\c@enumi} % \def\theenumii{(\@alph\c@enumii)} % \def\theenumiii{(\@roman\c@enumiii)} % \def\theenumiv{(\@Alph\c@enumiv)} % \def\labelenumi{\theenumi.} % \def\labelenumii{\theenumii} % \def\labelenumiii{\theenumiii} % \def\labelenumiv{\theenumiv} % \def\p@enumii{\theenumi} % \def\p@enumiii{\theenumi\theenumii} % \def\p@enumiv{\p@enumiii\theenumiii} % \settowidth\leftmargini{7.\hspace{\labelsep}} % \settowidth\leftmarginii{(f)\hspace{\labelsep}} % \settowidth\leftmarginiii{(vii)\hspace{\labelsep}} % \settowidth\leftmarginiv{(F)\hspace{\labelsep}} % \def\mks#1{\ifnum #1=1\relax\def\@s{}\else\def\@s{s}\fi% % \hbox{}\nobreak\vspace*{0pt}\hfill\llap{[#1 mark\@s]}\par} % \def\endqitem{\penalty\@M \addvspace\itemsep\hrulefill\penalty\z@} % \def\endqenum{\penalty\@M \addvspace\itemsep\hrulefill\\[-3ex] % \vspace*{0pt}\hrulefill\par} % \makeatother % \[\begin{ldemo}% % \begin{enumerate} % \item $x_1,x_2,\dots,x_n$ % are given by % \[\bar x % = \frac{1}{n} % \sum^n_{i = 1} % x_i % \ \mbox{and}\ % s^2_x % = \frac{1}{(n - 1)} % \sum^n_{i=1} % (x_i - \bar x)^2 % \] % respectively. % % If a linear transformation % $u_i = ax_i + b$, % $i = 1$, $2$, \dots, $n$, % is made of the data, % show that % \begin{enumerate} % \item $\bar u = a\bar x + b$ % and \mks{1} % \item $s^2_u = a^2 s^2_x$. % \mks{2} % \item If $s^2_x = 9$ and % $a = -4$, calculate % the standard deviation % of the $u_i$s. \mks{1} % \end{enumerate} % \endqitem % \item% % \begin{enumerate} % \item Define the following concepts: % \begin{enumerate} % \item The \textbf{sample space} % $S$ of an experiment; % \item An \textbf{event}; % \item A \textbf{random variable} % on $S$. % \end{enumerate} \mks{4} % \item A rare disease $D$ has an % incidence of $0.1\%$. % If a person has $D$ then a % diagnostic test signals that % fact with probability $0.99$ % (the sensitivity). % However on a disease free person, % the test indicates absence of the % disease with probability $0.98$ % (the specificity). % \begin{enumerate} % \item A person is selected at % random and tested. % What is the probability % that the test result % is positive? \mks{2} % \item A person tests positive. % Find the probability that % he/she actually has $D$. % \mks{4} % \end{enumerate} % \end{enumerate} % \endqenum % \end{enumerate} % \end{ldemo}\begin{rdemo} % \verb+\begin{qenum}+\\ % \verb+ \item $x_1,x_2,\dots,x_n$+\\ % \verb+ are given by+\\ % \verb+ \[\bar x +\\ % \verb+ = \frac{1}{n}+\\ % \verb+ \sum^n_{i = 1}+\\ % \verb+ x_i +\\ % \verb+ \ \text{and}\ +\\ % \verb+ s^2_x +\\ % \verb+ = \frac{1}{(n - 1)} +\\ % \verb+ \sum^n_{i=1} +\\ % \verb+ (x_i - \bar x)^2+\\ % \verb+ \]+\\ % \verb+ respectively.+\\ % \verb++\\ % \verb+ If a linear transformation +\\ % \verb- $u_i = ax_i + b$, -\\ % \verb+ $i = 1$, $2$, \dots, $n$, +\\ % \verb+ is made of the data, +\\ % \verb+ show that+\\ % \verb+ \begin{qenum}+\\ % \verb- \item $\bar u = a\bar x + b$ -\\ % \verb+ and \mks{1}+\\ % \verb+ \item $s^2_u = a^2 s^2_x$.+\\ % \verb+ \mks{2}+\\ % \verb+ \item If $s^2_x = 9$ and +\\ % \verb+ $a = -4$, calculate +\\ % \verb+ the standard deviation +\\ % \verb+ of the $u_i$s. \mks{1}+\\ % \verb+ \end{qenum}+\\ % \verb+ \item%+\\ % \verb+ \begin{qenum}+\\ % \verb+ \item Define the following concepts:+\\ % \verb+ \begin{qenum}+\\ % \verb+ \item The \textbf{sample space}+\\ % \verb+ $S$ of an experiment;+\\ % \verb+ \item An \textbf{event};+\\ % \verb+ \item A \textbf{random variable}+\\ % \verb+ on $S$. +\\ % \verb+ \end{qenum} \mks{4}+\\ % \verb+ \item A rare disease $D$ has an +\\ % \verb+ incidence of $0.1\%$. +\\ % \verb+ If a person has $D$ then a +\\ % \verb+ diagnostic test signals that +\\ % \verb+ fact with probability $0.99$ +\\ % \verb+ (the sensitivity). +\\ % \verb+ However on a disease free person,+\\ % \verb+ the test indicates absence of the+\\ % \verb+ disease with probability $0.98$ +\\ % \verb+ (the specificity).+\\ % \verb+ \begin{qenum}+\\ % \verb+ \item A person is selected at+\\ % \verb+ random and tested.+\\ % \verb+ What is the probability+\\ % \verb+ that the test result+\\ % \verb+ is positive? \mks{2}+\\ % \verb+ \item A person tests positive.+\\ % \verb+ Find the probability that +\\ % \verb+ he/she actually has $D$.+\\ % \verb+ \mks{4}+\\ % \verb+ \end{qenum}+\\ % \verb+ \end{qenum}+\\ % \verb+\end{qenum}+ % \end{rdemo}\] % There are a number of features that the above % demonstration of the \env{qenum} environment does not % show: it does not show the echoing and automatic totalling % of marks that is logged when one \latex/s the document, % nor does it show what appears in the page headers and footlines. % % Finally, as usual, the \latex/ file should be terminated % with a % \begin{quote}\slshape % \verb+\end{document}+ % \end{quote} % \section{How to deal with bad pagebreaks} % The standard \latex/ way to force a pagebreak is to insert % either a \cn{pagebreak} or a \cn{newpage}. These have been % slightly modified to do some extra work when followed by % an \cn{item} or a \cn{section} to do what you expect. % % What if the \cn{item} coming after a \cn{pagebreak} or \cn{newpage} % is somehow hidden? e.g.\ the \cn{item} is in a file that % is \cn{input} or \cn{include}d. In such cases, one needs % to explicitly tell \latex/ that the previous \cn{item} is % finished by issuing an \cn{endqitem} before the % \cn{pagebreak} or \cn{newpage}, as in the following % example: % \begin{quote}\slshape % \verb+\endqitem+\\ % \verb+\pagebreak+\\ % \verb+\input{FileContainingNextItem}+ % \end{quote} % Very occasionally, one might get a bad page break at or % near the end of a question, e.g.\ the horizontal rule separator % may end up on the top of a page or after just one or two % lines of text immediately after continuation information. % In order to help \latex/ find a better pagebreak do % the following: position a line % \begin{quote}\slshape % \verb+\enlargethispage*{2\baselineskip}+ % \end{quote} % (replace 2 with something larger, if you need it) % a little before the intended position of the pagebreak, % and then % \begin{quote}\slshape % \verb+\pagebreak+ % \end{quote} % at the point where you would like the pagebreak to occur, % which for the example mooted above, would be immediately % before an \cn{item}. % \section{Embedding exam solutions and selection from a question pool} % The \pkg{uwamaths} package \cite{uwamaths} provides % \env{exquestion}, \env{solution} and \env{answer} environments, % so that one can embed the solutions to questions in the same file % as the exam. Putting a \cn{nosolntrue} in the preamble of % the document causes all the \env{solution} environments to % be treated as comments, i.e.\ in this way, by commenting or % not commenting out the \cn{nosolntrue} one can produce a % \emph{marker}'s copy and a \emph{student}'s copy of an % exam, using the same file. % % There is also an \env{exitem} % environment which behaves like \emph{labelled} \cn{item}s: % the idea is that one can create a \emph{pool} of questions % and with a selector command (\cn{exlist}) one can select % the \env{exitem}'s one wants (the remainder, not selected, % are treated as comments). With the \env{exitem} % environment, one can build up a file with a large pool of % questions over a number of years, and then simply by % modifying the list of labels given to \cn{exlist} produce % different exams. If any of the above has piqued your % interest check out the section on % \emph{Exercise question and answer environments} in % \cite{uwamaths}. % \CheckSum{994} % \Finale