home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fonts 1
/
freshfonts1.bin
/
programs
/
amiga
/
pastex
/
macros
/
latex2e
/
contrib
/
supported
/
exams
/
exam.dtx
(
.txt
)
< prev
next >
Wrap
LaTeX Document
|
1994-02-25
|
45KB
|
1,194 lines
% \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
% argumen