% \iffalse meta-comment % % % IMPORTANT NOTICE: % % Please do not request updates from us directly. Distribution is % done through Mail-Servers and TeX organizations. % % You are not allowed to change this file. % % You are NOT ALLOWED to distribute this file alone. You are NOT % ALLOWED to take money for the distribution or use of either this % file or a changed version, except for a nominal charge for copying % etc. % \fi % % \CheckSum{1240} %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z %% Digits \0\1\2\3\4\5\6\7\8\9 %% Exclamation \! Double quote \" Hash (number) \# %% Dollar \$ Percent \% Ampersand \& %% Acute accent \' Left paren \( Right paren \) %% Asterisk \* Plus \+ Comma \, %% Minus \- Point \. Solidus \/ %% Colon \: Semicolon \; Less than \< %% Equals \= Greater than \> Question mark \? %% Commercial at \@ Left bracket \[ Backslash \\ %% Right bracket \] Circumflex \^ Underscore \_ %% Grave accent \` Left brace \{ Vertical bar \| %% Right brace \} Tilde \~} % % % \changes{3.0a}{1994/02/13}{First version for LaTeX2E and docstrip} % % \title{Typesetting of Exams for \LaTeX{} version 2e} % % \author{% % Copyright (C) 1994 by Hans van der Meer % } % % \maketitle % \tableofcontents % % \StopEventually{} ^^A % % \section{Identification} % % This document classes can only be used with \LaTeXe, so we make % sure that an appropriate message is displayed when another \TeX{} % format is used. % \begin{macrocode} %<*exam> \NeedsTeXFormat{LaTeX2e}[1993/12/01] % \end{macrocode} % % We store the date, version and name of this file in three control % sequences, for future use. % \begin{macrocode} \def\fileversion{3.0a} \def\filedate{1994/02/13} \def\filename{exam.dtx} % \end{macrocode} % % Announce the Class name and its version: % \begin{macrocode} \ProvidesClass{exam}[\filedate\space Production of exams] % \end{macrocode} % % And display it on the terminal (and the log file): % \begin{macrocode} \typeout{Standard Document Class `exam' <\filedate>.} % \end{macrocode} % % \section{Declaration of Class Options} % % In this part we define the options for this class that are additional % to those of its parent class. % % \subsection{Switching answers on and off} % % The flag |\ifanswers| governs the production of answers in the % typesetting of problems. With the |answers| options in the % optional argument of the document class this option is turned on. % At the same time an output stream is allocated on which a log of the % problems chosen will appear. % % \begin{macro}{\ifanswers} % \begin{macrocode} \newif\ifanswers \DeclareOption{answers}{\answerstrue\newwrite\listfile} % \end{macrocode} % \end{macro} % % \subsection{Typesetting a Catalogue of Problems} % % The flag |\ifseries| initiates the production of a problem collection. % In order to show the answers too the |\ifanswer| flag is set, but % note that in this case no log of problems is produced. % Consequently on output to the problem log a test on |\ifseries| % is always necessary. % % \begin{macro}{\ifseries} % \begin{macrocode} \newif\ifseries \DeclareOption{series}{\seriestrue\answerstrue} % \end{macrocode} % \end{macro} % % \section{Loading of Parent Class} % % Since the \emph{exam class} is implemented as a modification % of an existing document class, we must load the parent class. % However in order to make changes in parent class easy the % name of this class is parametrized in macro |\parentclass|. % Obvious candidates are \emph{article} and \emph{report}. % % \begin{macro}{\parentclass} % \begin{macrocode} \newcommand\parentclass{artikel1} % \end{macrocode} % \end{macro} % % The options of the |\documentclass| call which are not specific for the % \emph{exam class} must be passed to the parent class. % We take the opportunity to select some defaults, e.g.\ the % point size and the production of a titlepage (not automatically % added if the parent class is \emph{article}. % After this we process the local options and load the parent class. % % \begin{macrocode} \DeclareOption*{\PassOptionsToClass{\CurrentOption}{\parentclass}} \PassOptionsToClass{titlepage,12pt}{\parentclass} \ProcessOptions \LoadClass{\parentclass} % \end{macrocode} % % \subsection{Loading Additional Packages} % % This is the place where additional packages can be loaded. % % \section{Producing an Exam} % % First we need a counter for exams, since in one run more than % one exam can be produced. % By stepping this counter we will effect the automatic reset of % the counter that numbers the problems and keep the scores. % % \begin{macro}{\examnum} % \begin{macrocode} \newcounter{examnum} % \end{macrocode} % \end{macro} % % Exams are produced within the |exam| environment. This environment takes % 2 parameters. The first is optional and is used for the initialization % of the random generator.\footnote{Not in use if a series % is run} The default value is 0, which effectively shuts off the % randomness. % The second parameter must be present, but may be empty. % It fixes the date for which the exam is planned; an empty argument % fills this with the current date. % % \begin{environment}{exam} % \begin{macrocode} \newenvironment{exam}[2][0]{% \stepcounter{examnum}% \@ifemptyarg{#2}{}{\date{#2}}% % \end{macrocode} % % When a series is run we start with a titlepage.\footnote{% % If not inhibited by the |notitlepage| option.} % In the other cases production of the titlepage is deferred to the end of % the exam, so that we may print the number of problems it contains. % When an exam with answers is in production we write a few % messages to the problem log (date and starting value of the % random generator). % % \begin{macrocode} \ifseries\SRset{0}\maketitle\else\SRset{#1}% \ifanswers \immediate\openout\listfile=\jobname.lst \immediate\write\listfile{\Exam\space\@date}% \immediate\write\listfile{Random generator = \SRvalue}% \fi\fi % \end{macrocode} % % At each separate exam the first page gets the number one. % % \begin{macrocode} \setcounter{page}{1}}{% % \end{macrocode} % % At the end of the exam, if necessary, % a list of problems and a titlepage are produced. % % \begin{macrocode} \ifseries\else \ifanswers\makelist\fi \maketitle \fi} % \end{macrocode} % \end{environment} % % \subsection{Problem listing} % % The next macro typesets the list of problems chosen. % It also contains the score values for each problem and % a cumulative total of them. % The typesetting of this list is extremely primitive. % One minor note: the reading of the list is bracketed by % |\makeatletter| and |\makeatother| in order not to choke % in the |@| characters in its macro calls. % % \begin{macro}{\makelist} % \begin{macrocode} \newcommand\makelist{% \immediate\closeout\listfile \immediate\openin\listfile=\jobname.lst \newpage \begin{ttfamily} \parskip=\z@skip\parindent=\z@ \obeylines \makeatletter \InputIfFileExists{\jobname.lst}% {}{\typeout{ERROR! File \jobname.lst not found}}% \makeatother \end{ttfamily} \immediate\closein\listfile \newpage} % \end{macrocode} % \end{macro} % % \section{Choice of Problems} % % We start with a counter |\problemnum| with which the problems % of the exam are neatly numbered. This counter is automatically % reset each time a new |exam| environment is entered. % A second representation of the current problem is collected % in token register |\problemid|. % % \begin{macro}{\problemnum} % \begin{macro}{\problemid} % \begin{macrocode} \newcounter{problemnum}[examnum] \newtoks\problemid % \end{macrocode} % \end{macro} % \end{macro} % % Each question resides in its own file, which is called up % |\question|. Of its three parameters the first is % optional and provides a means of communication with the % problem itself. To achieve this the first % argument of |\question| is cached % in macro |\parameter|. As most uses of this mechanism % boil down to a choice between several alternatives, the % number~1 is provided as a convenient default value. % The second parameter is the name of the (sub)directory % where the file named in the third parameter can be found. % The second parameter doubles up as section name in the % series production.\footnote{It is silently assumed % that all problems of a given category reside in a common % directory.} % % \begin{macro}{\question} % \begin{macrocode} \newcommand\question[3][]{% \renewcommand\parameter{#1}% % \end{macrocode} % % When a series is run we look for the start of a new section and % perform the appropriate actions if indeed a new section is found. % I.e.\ eject the page and then reset the section name % and the problem counter. % Note the use of uppercase in order to smooth out differences % in typing. % The identification of the problem is set to its file name and, % in the case of a series, is mentioned in the output. % Then the problem number is incremented. % % \begin{macrocode} \ifseries \uppercase{\def\@namesection{#2}}% \ifx\namesection\@namesection \else \newpage \global\let\namesection=\@namesection \addcontentsline{toc}{subsection}{\namesection}% \setcounter{problemnum}{0}% \fi \fi \problemid={\uppercase{#3}}% \ifseries \noindent\underbar{\emph{File\,:}~\texttt{\the\problemid}}\par \nobreak\medskip\nobreak \fi \stepcounter{problemnum}% % \end{macrocode} % % The reading of the problem itself is surrounded by calculations % on the score that this question will bring. % Scores are mentioned on the console except when a series is run. % In a problem all contributions from the various parts of the % problem are collected in counter |scorecounter|. % At the end of the problem |totalscore| is % updated with this value.\footnote{% % Note the resets for |totalscore| with |examnum| % and |scorecounter| with |problemnum| in their declaration.} % The code guards against typing errors in the name of the file. % % \begin{macrocode} \IfFileExists{\mainfolder#2:#3}{\@@input \mainfolder#2:#3}% {\typeout{ERROR! File \mainfolder#2:#3 not found \on@line}}% \ifseries\else \addtocounter{totalscore}{\value{scorecounter}}% \typeout{\Problem\ \theproblemnum: % score=\thescorecounter (\thetotalscore)}% \fi % \end{macrocode} % % If appropriate a summary of this problem is written to the problem log. % % \begin{macrocode} \ifseries\else\ifanswers \immediate\write\listfile{\hbox to\textwidth{% \hbox to1cm{\theproblemnum:~\hfil}% \hbox to8cm{#2:#3\hfil}% \hbox to3cm{score=\thetotalscore (\thescorecounter)\hfil}% \hfil}}% \fi\fi} % \end{macrocode} % \end{macro} % % Macro |\namesection| gets its initial value here: % % \begin{macro}{namesection} % \begin{macrocode} \newcommand\namesection{} % \end{macrocode} % \end{macro} % % \subsection{Parametrized Problems} % % A parametrized problem gets its parameter from the first % argument of macro |\question|, as already have been mentioned. % The mechanism is definition of macro |\parameter| to % the value of that argument. We initialize this macro % in order to guarantee safe use of |\renewcommand| later on. % % \begin{macro}{\parameter} % \begin{macrocode} \newcommand\parameter{} % \end{macrocode} % \end{macro} % % It is recommended that the macro |\parameterproblem| is % placed right at the start of the file that contains the problem. % This macro will typeset its second argument in a framed box. % Usually it tells the reader which options are available; that is, % only if a series is run, otherwise `silence' is the word. % The first argument is optional and can be used as default value % for |\parameter|. The default value for this default is the % number~1, as already has been mentioned above. % % The description is placed in a framed parbox, hanging with an indent % from the intro text. % % \begin{macro}{\parameterproblem} % \begin{macrocode} \newcommand\parameterproblem[2][1]{% \ifseries \begin{center}% \fbox{\parbox{.9\linewidth}{% \hangafter1 \settowidth{\hangindent}{\emph{Parameter \Problem\,:}~}% \strut\emph{Parameter \Problem\,:}~#2}}% \end{center}\addvspace{5mm}% \fi % \end{macrocode} % % If the value of |\parameter| is empty, then nothing has been passed % from command |\question|. As we have a parametrized problem here, % this is most likely an error. Therefore a warning is sent to the console. % In order to go on with the processing |\parameter| gets a default % value, either the one given in the call of |\parameterproblem| % or the `default-default'. % % \begin{macrocode} \ifx\parameter\@empty \typeout{ERROR! Missing parameter \on@line}% \def\parameter{#1}% supplies a default \fi} % \end{macrocode} % \end{macro} % % \section{Typesetting a Problem} % % Each problem must be enclosed in an environment |problem|. % Within this environment a default setup exists. % By supplying code in token register |\everyproblem| one % can influence the typesetting of each problem. % % \begin{macro}{\everyproblem} % \begin{macrocode} \newtoks\everyproblem % \end{macrocode} % % The |problem| environment also has one optional parameter % for specific adjustments of the options setting. % Execution of options occurs in the order: % default setup, possible modification by |\everyproblem| and % final customization through the optional parameter. % This mechanism provides for maximum flexibility. % \end{macro} % % \begin{environment}{problem} % \begin{macrocode} \newenvironment{problem}[1][]{% % \end{macrocode} % % Calling of options is guarded by a mechanism that makes them % active when necessary. Only when the switch |\if@tagsforbid| % is set false has calling of such an option any effect. % % Choose by default for keeping the whole problem on a page, % execute any code in the token register and honor the % option calls from the user. Finally shut off option processing. % % \begin{macrocode} \@tagsforbidfalse\compact\the\everyproblem#1\@tagsforbidtrue % \end{macrocode} % % In order to keep everything on page we will enclose % the problem in a vbox, coded in % macro |\@boxing|. Otherwise |\@boxing| is a noop and % \TeX's pagebuilder can choose its breakpoint freely. % % The problem is typeset with a standard opening % programmed in |\problemstart|, completing the % opening manoeuvres of the environment. % % \begin{macrocode} \@boxing\bgroup\noindent\problemstart\ignorespaces}% % \end{macrocode} % % After processing the body of the problem some postprocessing follows % and the possible vbox is closed by an |\egroup|. % % In particular a visual separation from the next problem is added. % In the case of series production the origin date % of the problem is added too.\footnote{Only if it has been % provided to it by the proper macro call, of course.} % The origin date is then cleared for the next problem. % % \begin{macrocode} {\par\nobreak\smallskip\nobreak \hbox to\linewidth{\hrulefill \ifseries\emph{\footnotesize\thinspace\the\@problemdate}\fi}% \egroup\par\bigskip\@resetproblemdate} % \end{macrocode} % \end{environment} % % \subsection{Code for Options to Problem} % % The options to |problem| are |\compact| or |\split|. % These options govern the possibility for the problem % to be split between successive pages or the necessity % to keep everything on page; the last one being the % favoured behaviour in this implementation. % Note the |\noident| before the |\vbox| that prevents % an unwanted shift to the right. % % \begin{macro}{\compact} % \begin{macro}{\split} % \begin{macrocode} \newcommand\compact{\@chktag\compact\def\@boxing{\noindent\vbox}\fi} \newcommand\split{\@chktag\split\def\@boxing{}\@empty\fi} % \end{macrocode} % \end{macro} % \end{macro} % % \subsubsection{Coding Environments Options} % % The |\@chktag| macro is provided to the code just in case % it is not already present in the system. % Note the open ended |\if...\else| which will be closed % by a |\fi| in the option definition. % % \begin{macro}{\if@tagsforbid} % \begin{macro}{\@chktag} % \begin{macrocode} \newif\if@tagsforbid \@tagsforbidtrue \providecommand\@chktag[1]{% \if@tagsforbid\@warning{tag \string#1\space ignored here}\else} % \end{macrocode} % \end{macro} % \end{macro} % % \subsection{Numbering the Problem} % % A problem gets a standard opening clause, coded in % macro |\@problemstart|. The opening code is used to % format the first paragraph with a nice indentation.\footnote{% % This indentation is also used in the left margin in multiple % choice listings in order to limit the variation in margins.} % % \begin{macro}{\@problemstart} % \begin{macro}{\problemstart} % \begin{macrocode} \newcommand\@problemstart{% \textbo{\Problem\,\ifnum\value{problemnum}<10 \phantom{0}\fi \theproblemnum}.\enskip} \newcommand\problemstart{% \hangafter-2\settowidth\hangindent{\@problemstart}% \noindent\llap{\@problemstart}} % \end{macrocode} % \end{macro} % \end{macro} % % \subsection{Date of Origin} % % The user may specify an original date or date of last change % for the problem to be printed when a series is produced. % The global assignments are here just in case things happen in % a deeper nested level. % % \begin{macro}{\@problemdate} % \begin{macro}{\problemdate} % \begin{macro}{\@resetproblemdate} % \begin{macrocode} \newtoks\@problemdate \newcommand\problemdate[1]{\global\@problemdate={#1}\ignorespaces} \newcommand\@resetproblemdate{\global\@problemdate={}} % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} % % \subsection{Score Values} % % Associated with each problem are of course the benefits the % student receives for a good answer to (part of) the problem. % The |\score| macro exists for this purpose. % If answers are not included, just an empty square is printed % into which the teacher can express his satisfaction with % the answer given. When answers are included in the printout % the each call |\score{value}| shows up in the right margin % of the document.\footnote{At the end of each problem a summary % of its total score plus a grand total are presented % on the console.} % % These counters collect the values. Note that |\totalscore| % is reset for each new exam and |\scorecounter| for each problem. % % \begin{macro}{\totalscore} % \begin{macro}{\scorecounter} % \begin{macrocode} \newcounter{totalscore}[examnum] \newcounter{scorecounter}[problemnum] % \end{macrocode} % \end{macro} % \end{macro} % % The next commands are used for the production of the box % for the score value. % % \begin{macro}{\scoreboxsize} % \begin{macro}{\scorebox} % \begin{macrocode} \newcommand\scoreboxsize{7mm} \newcommand\scorebox[1]{% \fbox{\vbox to\scoreboxsize{\vss\hbox to\scoreboxsize{\hss#1\hss}\vss}}} % \end{macrocode} % \end{macro} % \end{macro} % % Finally the next code puts the score box on paper. % It takes the value of the score as its argument and adds % it to the running sum for this problem. % % \begin{macro}{\score} % \begin{macrocode} \newcommand\score[1]{% \addtocounter{scorecounter}{#1}% \rightnote[-\normalbaselineskip]{\scorebox{\ifanswers#1\fi}}% \ignorespaces} % \end{macrocode} % \end{macro} % % \subsubsection{Placing a Note in the Margin} % % We do not use |\marginpar| for the placement of the score values, % because we do not want these items wandering around, as % \LaTeX's |\marginpar|'s sometimes do. % The optional argument to the |..note| macros specifies % a vertical amount to be skipped in the placement of the note. % We use |\providecommand| because we may have them % incorporated already in other packages. % Note the |\noident| before the |\vadjust| that also % leaves vmode for the benefit of the |\vadjust|. % % \begin{macro}{\leftnote} % \begin{macro}{\rightnote} % \begin{macro}{\@rlnote} % \begin{macrocode} \providecommand\leftnote[1][\z@skip]{\@rlnote l{#1}} \providecommand\rightnote[1][\z@skip]{\@rlnote r{#1}} \providecommand\@rlnote[3]{% \noindent\vadjust{\vbox to\z@{% \vskip#2\leftskip\z@skip\rightskip\z@skip\noindent \if#1l\llap{#3\hskip\marginparsep}% \else\hfill\rlap{\hskip\marginparsep#3}\fi \vss\vskip\z@skip}}} % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} % % \section{Answers} % % In this section various ways of typesetting answers are provided. % % We start with two definitions for long and short stretches of white % space. These are meant for leaving room for the students answer. % % \begin{macro}{\longwhite} % \begin{macro}{\shortwhite} % \begin{macrocode} \newcommand\longwhite{25mm} \newcommand\shortwhite{8mm} % \end{macrocode} % \end{macro} % \end{macro} % % \subsection{Intro to Answer} % % Just as with the typesetting of the problem, we provide % a macro to start an answer. Note how the text is % parametrized in order to keep switching to other % languages simple. % % \begin{macro}{\answerstart} % \begin{macrocode} \newcommand\answerstart{\emph{\Answer}:\enspace} % \end{macrocode} % \end{macro} % % \subsubsection{Switching Answer On and Off} % % Macro call |\answer| holds the answer and shows it when % answers are requested. The optional argument specifies % a width for the hbox into which the typesetting takes places. % The answer is centered; change it with |\hfil|'s. It will % be implemented in terms of the next macro. % \begin{macro}{\answer} % \begin{macrocode} \newcommand\answer[2][]{\altanswer[#1]{}{#2}} % \end{macrocode} % \end{macro} % % \subsection{Alternating Some Stuff and Answer} % % With |\altanswer| the text alternates between two possibilities: % the first one when suppressing answers, the second % for the opposite case. Optional width argument and placement % same as for |\answer|. % % \begin{macro}{\altanswer} % \begin{macrocode} \newcommand\altanswer[3][]{% \@ifemptyarg{#1}% {\mbox{\ifanswers#3\fi}}% {\leavevmode\hbox to#1{\hss\ifanswers#3\else#2\fi\hss}}% } % \end{macrocode} % \end{macro} % % \subsection{Problem with a Short Answer} % % A question ``Give a short answer to \ldots'' is formatted % in |\shortanswer|. Usually the answer will fit on one line. % In the exam a row of dots is produced, otherwise the answer will show. % The optional argument provides the width of the box into which % the data are typeset. % % \begin{macro}{\shortanswer} % \begin{macrocode} \newcommand\shortanswer[2][.75\linewidth]{\par \ifanswers \addvspace{\smallskipamount}% \noindent\answerstart\parbox[t]{#1}{#2}% \else \addvspace{\shortwhite}% \noindent\answerstart\hbox to#1{\dotfill}\fi \par} % \end{macrocode} % \end{macro} % % \subsection{Problem with a Long Answer} % % For elaborate questions, problems, etc.\ an environment is available. % The |longanswer| takes as optional argument the length % of white to be reserved for the student. % % Code for opening of the environment. % It opens a box in order to let the answer disappear % and places a rule in order to guarantee sufficient % white space. % % \begin{environment}{longanswer} % \begin{macrocode} \newenvironment{longanswer}[1][\longwhite]{ \par\addvspace{\medskipamount}% \noindent\answerstart\par\nobreak \ifanswers\else \hrule\@height#1\@width\z@\par \setbox\z@\vbox\bgroup \leavevmode \fi} % \end{macrocode} % % Aftermath of |longanswer|. If necessary close the box % and empty it to get rid of the answer. % \begin{macrocode} {\ifanswers\else\egroup\setbox\z@\hbox{}\fi} % \end{macrocode} % \end{environment} % % \section{Multiple Choice Questions} % % Multiple choice problems must be placed % in an |choice| environment, a modification % of |itemize|. % % \subsection{Remembering and Counting Items} % % We will make it possible to shuffle the items of a multiple % choice problem randomly. These items are held in a series % of token registers declared below. % % We need a counter into which to keep the number of items % at any time loaded into the token registers declared above. % Also we provide for resetting, incrementing and decrementing % of this register. Note the global assignments. % % \begin{macro}{\loadcounter} % \begin{macro}{\resetloadcounter} % \begin{macro}{\incloadcounter} % \begin{macro}{\decloadcounter} % \begin{macrocode} \newcount\loadcounter \newcommand\resetloadcounter{\global\loadcounter\z@} \newcommand\incloadcounter{\global\advance\loadcounter\@ne} \newcommand\decloadcounter{\global\advance\loadcounter\m@ne} % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} % \end{macro} % % \subsection{Adapting List Parameters} % % We want a specific behaviour when the list of items is typeset. % However, we cannot be sure at which listlevel this will occur. % Therefore we predeclare a replacement for |\@listi|, |@listii|, % or whatsoever, and swap the |\@list..| at the right time. % Note the choice for the leftside margin, derived from the % width of the text with which the problem starts. This choice % diminishes the number of different margins. It is easily adapted % to your own taste. % % \begin{macro}{\@listk} % \begin{macrocode} \newcommand\@listk{% \settowidth{\leftmargin}{\@problemstart}% \topsep\medskipamount \partopsep\z@ \itemsep\smallskipamount \parsep\z@} % \end{macrocode} % \end{macro} % % \subsection{Typesetting Multiple Choice} % % The multiple choice environment |choice| takes one argument, % the modifier options to the environment typesetting. % Here the options are |\random| and |\ordered|; the names % speak for themselves. Note that random permutation is not % executed if a series is run. Furthermore the counter % for the number of items loaded is reset. % % \begin{environment}{choice} % \begin{macrocode} \newenvironment{choice}[1][]{% \@tagsforbidfalse\ifanswers\ordered\else\random\fi#1\@tagsforbidtrue \resetloadcounter % \end{macrocode} % % The following code is taken from \LaTeX's |itemize|. % I did not find a more elegant way to bend this environment % to my whims. % % \begin{macrocode} \ifnum\@itemdepth>3 \@toodeep \else \advance\@itemdepth\@ne \expandafter\let \csname @list\romannumeral\the\@itemdepth\endcsname=\@listk \list{\badmark}{\def\makelabel##1{\hss\llap{##1}}}% \fi}% % \end{macrocode} % % At the end of |choice| we dump all the items that may have been % collected inbetween and finish the |list|. % % \begin{macrocode} {\@dumpitems\endlist} % \end{macrocode} % \end{environment} % % \subsection{Code for Options to Choice} % % The option |\random| codes macros |\@loaditem| and % |\@dumpitems| so that the items are actually loaded, % then shuffled and dumped afterwards. % The |\ordered| option makes them noops and thus the % items will be typeset on the fly. % % \begin{macro}{\random} % \begin{macro}{\ordered} % \begin{macrocode} \newcommand\random{\@chktag\random \def\@loaditem{\loaditem}% \def\@dumpitems{\shuffle\dumpitems}% \fi} \newcommand\ordered{\@chktag\ordered \def\@loaditem{}% \def\@dumpitems{}% \fi} % \end{macrocode} % \end{macro} % \end{macro} % % \subsection{Formatting the Item Mark} % % We require two marks: one for the bad guys and one % for the good guy. We use two symbols from % the AMSa font, |\square| = |\symbol{3}| and % |\checksquare| = |\symbol{2}|. Declared for example by % \begin{macrocode} % \DeclareMathSymbol\square{\mathord}{AMSa}{'003} % \DeclareMathSymbol\checksquare{\mathord}{AMSa}{'002} % \end{macrocode} % % However, we make this code % as portable as possible and provide for % standard \LaTeX{} replacements % if these macros are not defined in the system. % % \begin{macro}{\square} % \begin{macro}{\checksquare} % \begin{macro}{\badmark} % \begin{macro}{\goodmark} % \begin{macrocode} \providecommand\square{\bigcirc} \providecommand\checksquare{\surd} \newcommand\badmark{$\square$} \newcommand\goodmark{\ifanswers$\checksquare$\else\badmark\fi} % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} % \end{macro} % % Each item can either be right or wrong. We take the precaution % to suppress the difference when typesetting the actual exam. % Enclose each item in your list in the argument to % |\gooditem| and |\baditem|. They % will load the item in memory prior to (possible) random shuffling. % % \begin{macro}{\baditem} % \begin{macro}{\gooditem} % \begin{macrocode} \newcommand\baditem[1]{\@loaditem{\item[\badmark]#1}} \newcommand\gooditem[1]{\@loaditem{\item[\goodmark]#1}} % \end{macrocode} % \end{macro} % \end{macro} % % \subsection{Loading and Dumping Items} % % This series of token registers % can hold five alternatives. The mechanism that loads the % items is sufficiently general to use it for other purposes too. % Use your imagination! % That there are five of them is remembered in a definition % because we will need this number to prevent overfilling the store. % % \begin{macro}{\@itemA} % \begin{macro}{\@itemB} % \begin{macro}{\@itemC} % \begin{macro}{\@itemD} % \begin{macro}{\@itemE} % \begin{macro}{\@itemstore} % \begin{macrocode} \newtoks\@itemA \newtoks\@itemB \newtoks\@itemC \newtoks\@itemD \newtoks\@itemE \newcommand\@itemstore{5} % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} % \end{macro} % \end{macro} % \end{macro} % % According to the value of |loadcounter| the token registers % |\@itemA|, etc.\ are filled. Argument to macro |\loaditem| % is the contents of the item. % % \begin{macro}{\loaditem} % \begin{macrocode} \newcommand\loaditem[1]{% \ifcase\loadcounter \@itemA={#1}% \or\@itemB={#1}% \or\@itemC={#1}% \or\@itemD={#1}% \or\@itemE={#1}% \fi \ifnum\loadcounter<\@itemstore \incloadcounter \else\typeout{ERROR! previous item dumped, too many\on@line}\fi} % \end{macrocode} % \end{macro} % % Produce the items that were loaded. % With |\dumpitem| the last one comes out, % with |\dumpitems| the whole lot is dumped. % % \begin{macro}{\dumpitem} % \begin{macro}{\dumpitems} % \begin{macrocode} \newcommand\dumpitem{% \ifcase\loadcounter \or\the\@itemA \or\the\@itemB \or\the\@itemC \or\the\@itemD \or\the\@itemE \fi\decloadcounter} \newcommand\dumpitems{\@whilenum\loadcounter>\z@\do{\dumpitem}} % \end{macrocode} % \end{macro} % \end{macro} % % \subsubsection{Shuffling Items} % % This macro permutes |loadcounter| items in the % token registers |\@itemA|, etc. Undoubtedly it % can be done better, but who's perfect? % % \begin{macro}{\shuffle} % \begin{macrocode} \newcommand\shuffle{% \ifcase\loadcounter \or \or\shuffle@ii \or\shuffle@\@itemA\@itemC \shuffle@ii \shuffle@\@itemB\@itemC \or\shuffle@iv \or\shuffle@\@itemD\@itemE \shuffle@iv \shuffle@\@itemD\@itemE \fi } % \end{macrocode} % \end{macro} % % Random interchange of two and four items. % % \begin{macro}{\@item@} % \begin{macro}{\shuffle@} % \begin{macro}{\shuffle@ii} % \begin{macro}{\shuffle@iv} % \begin{macrocode} \newtoks\@item@ \newcommand\shuffle@[2]{\SRtest{}{\@item@=#1 #1=#2 #2=\@item@}} \newcommand\shuffle@ii{\shuffle@\@itemA\@itemB} \newcommand\shuffle@iv{% \SRtest{\shuffle@\@itemA\@itemB}{\shuffle@\@itemC\@itemD}% \SRtest{\shuffle@\@itemA\@itemC}{\shuffle@\@itemB\@itemD}} % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} % \end{macro} % % \subsubsection{Random Generator Implementation} % % Not much commentary with these macros. They are % described in the first issue of Tugboat~1994. % % \begin{macro}{\@SR} % \begin{macro}{\@SRconst} % \begin{macro}{\SRset} % \begin{macro}{\@SRadvance} % \begin{macro}{\SRbit} % \begin{macro}{\SRtest} % \begin{macro}{\SRvalue} % \begin{macrocode} \ifx\@SR\undefined\newcount\@SR\fi \providecommand\@SRconst{2097152} \providecommand\SRset[1]{\global\@SR#1\relax} \providecommand\@SRadvance{% \begingroup \ifnum\@SR<\@SRconst\relax\count@\z@\else\count@\@ne\fi \ifodd\@SR\advance\count@\@ne\fi \global\divide\@SR\tw@ \ifodd\count@\global\advance\@SR\@SRconst\relax\fi \endgroup} \providecommand\SRbit{\@SRadvance\ifodd\@SR1\else0\fi} \providecommand\SRtest[2]{\@SRadvance\ifodd\@SR#2\else#1\fi} \providecommand\SRvalue{\number\@SR } \SRset{0} % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} % \end{macro} % \end{macro} % \end{macro} % \end{macro} % % \section{Styling} % % \subsection{The Page Style} % % As default style |headings| is chosen. % However the appearance is altered a bit. % % \begin{macro}{\thehead} % \begin{macro}{\ps@headings} % \begin{macrocode} \newcommand\thehead{% \slshape\@title\enspace\upshape:\enspace \ifseries\namesection\else\@date\fi} \renewcommand\ps@headings{% \let\@oddfoot\@empty \let\@evenfoot\@empty \renewcommand\@oddhead{% \vbox{% \hbox to\textwidth{\headerfont\thehead\hfil\upshape\thepage}% \vskip1.5\p@ \hrule\@height.5\p@\@width\textwidth }}% \let\@evenhead\@oddhead} % \end{macrocode} % \end{macro} % \end{macro} % % \subsection{The Titlepage} % % With target we denote the group of students for whom % the exam is meant. Define with |\target| and call up % with |\@target|. % % \begin{macro}{\target} % \begin{macrocode} \newcommand\target[1]{\gdef\@target{#1}}\def\@target{} % \end{macrocode} % \end{macro} % % The titlepage is set by a redefined |\maketitle|. Of course % this will be suppressed if the |notitlepage| option is given % on the |\documentclass| call. % Don't hesistate to adapt the blahblah to your own style. % % The |\Copyright| is a dummy; an example of a redefinition is: % \begin{macrocode} % \renewcommand\Copyright{% % \InputIfFileExists{\Commonfolder copyright}% % {}{\typeout{No file 'copyright' present}}} % \end{macrocode} % % \begin{macro}{\Copyright} % \begin{macrocode} \newcommand\Copyright{} % \end{macrocode} % \end{macro} % % \begin{macro}{\maketitle} % \begin{macrocode} \renewcommand\maketitle{% \if@titlepage\begin{titlepage} \begin{center}\titlefont \vspace*{1cm}% \mbox{}\rule{2cm}{0.4pt}\mbox{}\par \addvspace{1cm}% \begin{Large} \textbf{\ifseries\Collection\else\Exam\fi}\\[10mm] \end{Large} \begin{large} \@title\\[5mm] \ifseries\@author\else\@target\fi\\[5mm] \@date\\[10mm] \end{large} \mbox{}\rule{2cm}{0.4pt}\mbox{}\par \addvspace{2cm}% \ifseries \vfill\vfill \begin{flushleft}% \Copyright \end{flushleft}% \else\ifanswers \begin{huge}\Answers\end{huge}\par \else \begin{minipage}{.75\textwidth}% \raggedright\parindent\medskipamount Naam:\enspace\dotfill\null\par Adres:\enspace\dotfill\null\par Plaats:\enspace\dotfill\null\par Collegekaart:\enspace\dotfill\null\par \vspace{1cm}% \begin{itemize}% \item Zonder geldige collegekaart wordt geen tentamenbriefje uitgereikt. \item U wordt met nadruk verzocht om een \emph{leesbaar} schrift; wat niet leesbaar is, wordt fout gerekend. \item Denk erom losse vellen tentamenpapier van Uw naam en collegekaartnummer te voorzien; gebruik blokletters voor de leesbaarheid. \item Dit tentamen telt \theproblemnum\ opgaven \end{itemize}% \end{minipage}\\[10mm] \GoodLuck\par \fi \fi \end{center}% \end{titlepage}\fi} % \end{macrocode} % \end{macro} % % \section{Miscellaneous} % % \subsection{Language Adjustments} % % A small problem arose with the Babel system. % If a language is not defined with |\addlanguage| an % |\errmessage| interfers with the smooth processing. % We avoid this problem with the following macro. % % \begin{macro}{\onlanguage} % \begin{macrocode} \newcommand\onlanguage[4]{% {current}{existing}{not existing} \expandafter\ifx\csname l@#1\endcsname\relax #4\else \ifnum\csname l@#1\endcsname=\language #2% \else#3\fi \fi} % \end{macrocode} % \end{macro} % % \subsubsection{English} % % Put here all english equivalents. % \begin{macro}{\englishExamNames} % \begin{macrocode} \newcommand\englishExamNames{% \newcommand\Answers{ANSWERS}% \newcommand\Answer{Answer}% \newcommand\GoodLuck{Good luck!}% \newcommand\Exam{EXAM}% \newcommand\Collection{COLLECTION OF EXAMS}% \newcommand\Problem{Problem}% } % \end{macrocode} % \end{macro} % % If appropriate set one of these languages at the start of the document. % % \begin{macrocode} \AtBeginDocument{\onlanguage{english}{\englishExamNames}{}{}} \AtBeginDocument{\onlanguage{american}{\englishExamNames}{}{}} % \end{macrocode} % % \subsubsection{Dutch} % % Put here all dutch equivalents. % % \begin{macro}{\englishExamNames} % \begin{macrocode} \newcommand\dutchExamNames{% \newcommand\Answers{ANTWOORDEN}% \newcommand\Answer{Antwoord}% \newcommand\GoodLuck{Veel succes!}% \newcommand\Exam{TENTAMEN}% \newcommand\Collection{TENTAMENBUNDEL}% \newcommand\Problem{Opgave}% } % \end{macrocode} % \end{macro} % % If appropriate set this language at the start of the document. % % \begin{macrocode} \AtBeginDocument{\onlanguage{dutch}{\dutchExamNames}{}{}} % \end{macrocode} % % \subsubsection{Private Language Dependent Specialties} % % \begin{macro}{\fullanswer} % \begin{macrocode} \newcommand\fullanswer{Geef de volledige afleiding; % slechts het antwoord vermelden wordt \emph{niet} goed gerekend.} % \end{macrocode} % \end{macro} % % \subsection{Macros That May Be Missing} % % I like bold more than bold extended (small hack to mf-files), but % if you don't have bold, replace it by bold extended. % % \begin{macro}{\textbo} % \begin{macrocode} \providecommand\textbo{\textbf} % \end{macrocode} % \end{macro} % % Testing for the presence or absence of a parameter. % % \begin{macro}{\@ifemptyarg} % \begin{macrocode} \providecommand\@ifemptyarg[1]{% {absence}{presence} \ifx\@empty#1\@empty \expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi} % \end{macrocode} % \end{macro} % % \section{Initializations} % % \subsection{Pagestyle} % % Initialize the pagestyle. % % \begin{macrocode} \pagestyle{headings} % \end{macrocode} % % \subsection{Page Layout and Fonts} % % I like a somewhat more efficient use of the paper surface % % \begin{macrocode} \addtolength{\topmargin}{-15mm} \addtolength{\textheight}{35mm} % \end{macrocode} % % And allow more stretch in the lines, % encourage pagebreaking at paragraphs, % more strongly discourage widows % % \begin{macrocode} \tolerance=2000 \hbadness=2000 \emergencystretch=2mm \interlinepenalty=1000 \widowpenalty 1000 % \end{macrocode} % % Fonts for pageheader, body of the text and on the titlepage. % % \begin{macro}{\headerfont} % \begin{macro}{\bodyfont} % \begin{macro}{\titlefont} % \begin{macrocode} \newcommand\headerfont{\rmfamily\small} \newcommand\bodyfont{\sffamily} \newcommand\titlefont{\rmfamily\upshape} % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} % % And initialize % % \begin{macrocode} \bodyfont % \end{macrocode} % % \subsection{Directory Localization} % % Specify folders (directories) for the main source, % a common folder for related material and a folder % for e.g.\ EPSF figures etc. % % \begin{macro}{\Mainfolder} % \begin{macro}{\Commonfolder} % \begin{macro}{\Figuresfolder} % \begin{macrocode} \newcommand\Mainfolder[1]{\def\mainfolder{#1}} \newcommand\Commonfolder[1]{\def\commonfolder{#1}} \newcommand\Figuresfolder[1]{\def\figuresfolder{#1}} % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} % % Initialize them % % \begin{macrocode} \Mainfolder{\@currdir} \Commonfolder{\@currdir} \Figuresfolder{\@currdir} % \end{macrocode} % % \subsection{Configuration File} % % Last, but not least, see if there is a configuration % file \emph{exam.cfg} and read it for the final adjustments. % % \begin{macrocode} \InputIfFileExists{exam.cfg}{}{} % % \end{macrocode} % % % \section{The documentation driver file} % % \begin{macrocode} %<*driver> \documentclass{ltxdoc} % \begin{end} % % We use the document class provided by the \LaTeXe distribution % for producing the documentation. % % We don't want everything to appear in the index % \begin{macrocode} \DoNotIndex{\',\.,\@M,\@@input,\@addtoreset,\@arabic,\@badmath} \DoNotIndex{\@centercr,\@cite} \DoNotIndex{\@dotsep,\@empty,\@float,\@gobble,\@gobbletwo,\@ignoretrue} \DoNotIndex{\@input,\@ixpt,\@m} \DoNotIndex{\@minus,\@mkboth,\@ne,\@nil,\@nomath,\@plus,\@set@topoint} \DoNotIndex{\@tempboxa,\@tempcnta,\@tempdima,\@tempdimb} \DoNotIndex{\@tempswafalse,\@tempswatrue,\@viipt,\@viiipt,\@vipt} \DoNotIndex{\@vpt,\@warning,\@xiipt,\@xipt,\@xivpt,\@xpt,\@xviipt} \DoNotIndex{\@xxpt,\@xxvpt,\\,\ ,\addpenalty,\addtolength,\addvspace} \DoNotIndex{\advance,\Alph,\alph} \DoNotIndex{\arabic,\ast,\begin,\begingroup,\bfseries,\bgroup,\box} \DoNotIndex{\bullet} \DoNotIndex{\cdot,\cite,\CodelineIndex,\cr,\day,\DeclareOption} \DoNotIndex{\def,\DisableCrossrefs,\divide,\DocInput,\documentclass} \DoNotIndex{\DoNotIndex,\egroup,\else,\em,\endtrivlist} \DoNotIndex{\EnableCrossrefs,\end,\end@dblfloat,\end@float,\endgroup} \DoNotIndex{\endlist,\everycr,\everypar,\ExecuteOptions,\expandafter} \DoNotIndex{\fbox,\fi} \DoNotIndex{\filedate,\filename,\fileversion,\fontsize,\framebox,\gdef} \DoNotIndex{\global,\halign,\hangindent,\hbox,\hfil,\hfill,\hrule} \DoNotIndex{\hsize,\hskip\hspace,\hss,\if@tempswa,\ifcase,\ifdim} \DoNotIndex{\ifhmode,\ifvmode,\ifnum,\iftrue,\ifx,\input} \DoNotIndex{\jobname,\kern,\leavevmode,\let,\leftmark} \DoNotIndex{\list,\llap,\long,\m@ne,\m@th,\mark,\markboth,\markright} \DoNotIndex{\month,\newcommand,\newcounter,\newenvironment,\newif} \DoNotIndex{\NeedsTeXFormat,\newdimen} \DoNotIndex{\newlength,\newpage,\nobreak,\noindent,\null,\number} \DoNotIndex{\numberline,\OldMakeindex,\OnlyDescription,\or,\p@} \DoNotIndex{\pagestyle,\par,\paragraph,\paragraphmark,\parfillskip} \DoNotIndex{\penalty,\PrintChanges,\PrintIndex,\ProcessOptions} \DoNotIndex{\protect,\ProvidesClass,\raggedbottom,\raggedright} \DoNotIndex{\refstepcounter,\relax,\renewcommand,\reset@font} \DoNotIndex{\rightmargin,\rightmark,\rightskip,\rlap,\rmfamily,\roman} \DoNotIndex{\roman,\secdef,\selectfont,\setbox,\setcounter,\setlength} \DoNotIndex{\settowidth,\sfcode,\skip,\sloppy,\slshape,\space} \DoNotIndex{\symbol,\the,\trivlist,\typeout,\tw@,\undefined,\uppercase} \DoNotIndex{\usecounter,\usefont,\usepackage,\vfil,\vfill,\viiipt} \DoNotIndex{\viipt,\vipt,\vskip,\vspace} \DoNotIndex{\wd,\xiipt,\year,\z@} % \end{macrocode} % % We do want an index, using linenumbers % \begin{macrocode} \EnableCrossrefs % comment out if index is ready \DisableCrossrefs % \end{macrocode} % % We also want the full details. % % \begin{macrocode} \RecordChanges % Gather update information %\OnlyDescription % comment out for implementation details % % start up the body of the document % % \begin{macrocode} \tolerance=2000 \hbadness=2000 \emergencystretch=2mm \begin{document} \DocInput{exam.dtx} \PrintIndex \PrintChanges \end{document} % % \end{macrocode} % % \Finale % \endinput % %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z %% Digits \0\1\2\3\4\5\6\7\8\9 %% Exclamation \! Double quote \" Hash (number) \# %% Dollar \$ Percent \% Ampersand \& %% Acute accent \' Left paren \( Right paren \) %% Asterisk \* Plus \+ Comma \, %% Minus \- Point \. Solidus \/ %% Colon \: Semicolon \; Less than \< %% Equals \= Greater than \> Question mark \? %% Commercial at \@ Left bracket \[ Backslash \\ %% Right bracket \] Circumflex \^ Underscore \_ %% Grave accent \` Left brace \{ Vertical bar \| %% Right brace \} Tilde \~} \endinput