summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/exam-n/exam-n.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-12-20 22:54:48 +0000
committerKarl Berry <karl@freefriends.org>2016-12-20 22:54:48 +0000
commitf84e6a7cb7a889c2a8c7297f9d5ca4894eab7687 (patch)
treec549ecf37486b8cadd59b3b82d3bac295c3e7596 /Master/texmf-dist/source/latex/exam-n/exam-n.dtx
parent5a634cef0f8bbb07d7982cb2bbcb38037a233686 (diff)
exam-n (20dec16)
git-svn-id: svn://tug.org/texlive/trunk@42755 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/exam-n/exam-n.dtx')
-rw-r--r--Master/texmf-dist/source/latex/exam-n/exam-n.dtx450
1 files changed, 316 insertions, 134 deletions
diff --git a/Master/texmf-dist/source/latex/exam-n/exam-n.dtx b/Master/texmf-dist/source/latex/exam-n/exam-n.dtx
index 4d870699207..043d2c9f7c9 100644
--- a/Master/texmf-dist/source/latex/exam-n/exam-n.dtx
+++ b/Master/texmf-dist/source/latex/exam-n/exam-n.dtx
@@ -3,10 +3,10 @@
%
% Generated file : DO NOT EDIT
%
-%% Release version 1.1, 2014 May 03.
+%% Release version 1.1.4, 2016 December 19.
%%
%%%% File: exam-n.dtx
-%%%% Copyright 2005--2014, Norman Gray
+%%%% Copyright 2005--2016, Norman Gray
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
@@ -17,27 +17,27 @@
%% version 2005/12/01 or later.
%%
%% This work has the LPPL maintenance status `maintained'.
-%%
+%%
%% The Current Maintainer of this work is Norman Gray <http://nxg.me.uk>
%%
%% This work consists of the files exam-n.dtx and exam-n.ins,
%% the derived file exam-n.cls,
%% and the associated *.clo files.
-%<+package|driver|example>%%%% Source: Mercurial revision 6f818b549982, 2014-05-03 13:42 +0100, tag 1.1 + 0
+%<+package|driver|example>%%%% Source: Mercurial revision e8a612cb25f4, 2016-12-19 16:49 +0000, tag exam-n-1.1.4 + 0
%%
%<*package|driver>
%</package|driver>
%<+package>\NeedsTeXFormat{LaTeX2e}
-%<+package>\ProvidesClass{exam-n}[2014/05/03 1.1]
-%<+package>\typeout{Class: `exam-n 1.1 <2014/05/03>}
+%<+package>\ProvidesClass{exam-n}[2016/12/19 1.1.4]
+%<+package>\typeout{Class: `exam-n 1.1.4 <2016/12/19>}
%
%<*driver>
\documentclass{ltxdoc}
\title{exam-n: exam papers}
\author{Norman Gray\\(\texttt{norman@astro.gla.ac.uk})}
-\date{Release 1.1}
+\date{Release 1.1.4}
\usepackage{url}
\newcommand\Lopt[1]{\textsf {#1}} % options
\newcommand\file[1]{\texttt {#1}}
@@ -203,7 +203,7 @@
% should use \Lopt{draft}; and you should use \Lopt{final} only for
% the final version.
% The \Lopt{draft} option switches on the \Lopt{showsolutions}
-% option (below), displays |\comment| remarks,
+% option (below), displays |\comment| remarks,
% and makes some mild layout changes.
% The \Lopt{compose} option implies the \Lopt{showsolutions} option,
% causes questions to be formatted one per page, and turns off
@@ -273,8 +273,8 @@
% superstition -- there seems remarkably little actual evidence
% either way).
%
-% \item[\Lopt{bigfont}]
-% Produce a version of the paper in a `huge' font (36pt size) for
+% \item[\Lopt{largefont}, or \Lopt{hugefont}]
+% Produce a version of the paper in a `big' font (18pt) or `huge' font (36pt) for
% the benefit of students with visual impairments. See notes below.
%
% \end{description}
@@ -284,7 +284,7 @@
% modifications. Most typically, these changes will affect the
% rubric, and the sheet of physical constants.
% The only generic style option is \Lopt{A1}
-% (which is included as an example of how such a file is written).
+% (which is included as an example of how such a file is written).
% See section~\ref{s:custom} below.
%
% In some circumstances -- for example when processing exam scripts
@@ -292,7 +292,7 @@
% control package options from outside the package. If there is a
% file called \texttt{exam-n.config} in the input path (most likely in
% the same directory as the exam paper), then this is read in when any
-% exam script is processed, and will supplement, any
+% exam script is processed, and will supplement any
% options in the |\documentclass| line. For example, if this file were present
% and contained the line |\ExecuteOptions{showsolutions}|, then the
% typeset exam would include the solutions. Note that this will
@@ -303,17 +303,20 @@
% make immediate use of amsmath features if you wish (see
% \texttt{\small http://www.ams.org/tex/amslatex.html} for discussion).
%
-% The change of font size with the \Lopt{bigfont} option requires a
-% couple of minor layout changes. You may need to make some other
-% changes by hand, in this case. You can do that by bracketing the
-% adjusted text in \cmd|\ifbigfont<big font
-% material>\else<normal font material>\fi|. The \Lpackage{amsmath}
+% The change of font size with the \Lopt{hugefont} option requires a
+% couple of minor layout changes. You may need to force some similar
+% changes in the exam paper, in this case. You can do that by bracketing the
+% adjusted text in \cmd|\ifbigfont<big font material>\else<normal font
+% material>\fi|; the |\ifbigfont| flag is true in the case of
+% \Lopt{hugefont}, but not \Lopt{largefont}. If you want the
+% |\ifbigfont| flag to apply to \Lopt{largefont}, too, then you may
+% set |\bigfonttrue| in a suitable place. The \Lpackage{amsmath}
% \texttt{multline} environment can be useful here. The exams
% convener should review the result carefully: a few judicious
% \cmd|\ifbigfont\newpage\fi| insertions can make the result look less
-% awful. The \Lopt{bigfont} option applies to the content of
-% solutions if the \Lopt{showsolutions} option is present; this may or
-% may not be the optimal choice.
+% awful. The \Lopt{largefont} and \Lopt{hugefont} options apply to
+% the content of solutions if the \Lopt{showsolutions} option is
+% present; this may or may not be the optimal choice.
%
% At the bottom of each page, you see a faint identification code, such
% as `QM/123-456'. This consists of an exam identifier, extracted from
@@ -328,7 +331,7 @@
% \label{s:question}
%
% Within the document, you include questions within a \Lenv{question}
-% environment, within which you may further have
+% environment, within which you may further have
% \Lenv{questiondata} and \Lenv{solution} environments.
%
% \DescribeEnv{question}
@@ -353,37 +356,47 @@
% \Lopt{perquestionmarks} option is present or not. If it is present
% (the default) then the \Lenv{question} environment takes a non-empty
% argument showing the total marks available for a question.
-% In addition, the class checks that the |\partmarks| within the
-% question add up to this declared goal mark.
+% In addition, the class checks that the |\partmarks| commands within the
+% question (see below) add up to this declared goal mark.
+% If the \Lopt{showmarktotals} option is present, then this (expected and
+% checked) total is displayed at the end of the question.
%
-% If the option is not present, then questions have no individual marks, the
+% If the \Lopt{perquestionmarks} option is \emph{not} present,
+% then questions have no individual marks, the
% environment takes no marks argument, and no marks are shown (this is usual
% in essay-question exams, which typically comprise a sequence of
-% short equal-valued questions with an explanatory rubric). The
-% |\partmarks| command cannot be used within the question. If the
-% \Lopt{showmarktotals} option is present, then this (expected and
-% checked) total is displayed at the end of the question.
+% short equal-valued questions with an explanatory rubric).
+% Also, in this case the |\partmarks| command cannot be used within the question.
%
% The \Lenv{question} environment takes an optional argument, giving
% the expected question number. In \Lopt{compose} mode, this is used
% as the question number (unsurprisingly). In the two other modes,
-% this is compared with the expected question number, based on the
-% number of preceding \Lenv{question} environments in the file, so
+% this is compared with the question number which would be generated based on the
+% position in the sequence of \Lenv{question} environments in the file, so
% that the first \Lenv{question} environment is for question one, the
% second for question two, and so on. If these do not match, the exam
% class displays a warning in \Lopt{draft} mode, and produces a fatal
-% error in \Lopt{final} mode. You should generally give this argument
-% -- it is intended to help catch embarrassing errors.
+% error in \Lopt{final} mode.
+% The intention is that this can act as a check that all expected
+% questions are present; see also the |\numquestions| command.
+% \iffalse XXX How useful is this in fact? Should I just discard this,
+% especially since includequestion has a similar features? \fi
%
+% \DescribeMacro{\QuestionNumberChecksOff}
% In some cases, the questions are not numbered in this
% straightforward fashion, so that you might have questions~`2A'
-% and~`2B'. In this case, the check is not meaningful, and you can
+% and~`2B'. In this case, the check is not meaningful, and you must
% suppress it by calling the macro |\QuestionNumberChecksOff| in the
-% preamble, and the question-number argument is required (though it
-% must still appear within square brackets). If these checks are off,
-% but a \Lenv{question} appears without a forced question number, then
-% the class warns about this, but still numbers the question as the
-% next one in sequence.
+% preamble. After that, you must provide a question-number argument
+% (in square brackets) for every question.
+%
+% In some odder circumstances, you might not want to have any question
+% numbers at all; for example, you might want to require examinees to
+% attempt \emph{all} of the questions, and so simply have a mark for
+% the whole exam. There isn't a mode for this as such, but if you use
+% the \cs{QuestionNumberChecksOff} macro, and give |[\space]| as the
+% optional `question number' at the beginning of the \Lenv{question}
+% environment, then this will have the desired effect.
%
% \DescribeEnv{solution}
% The \Lenv{solution} environment, contained within the \Lenv{question}
@@ -494,22 +507,36 @@
% controlled by the exam style, as customised in
% Sect.~\ref{s:custom}. This macro starts a new paragraph.
%
+% You can use the |\part| macro within solutions: this is useful if
+% you have the entire \Lenv{solution} environment at the end of the
+% question, but distracting if you intersperse the \Lenv{solution}
+% environments between question parts. The |\part| macro within
+% solutions increments separately from the increments within the question,
+% so if you use this in the solutions, you must have as many
+% |\part|s in the solution as there are parts in the question.
+%
% \DescribeMacro{\partmarks}
+% \DescribeMacro{\partmarks*}
% Macros \cmd|\partmarks{<num>}| and \cmd|\partmarks*{<num>}| announce
% the number of marks associated with the current part of a question.
% The class checks that the number of marks here does add up to the
% number declared at the beginning of the {question} environment.
% You will typically have just one |\partmarks| per |\part|, but
% you can have more if you want.
-% The starred version should be used when a part ends with an unnumbered
-% equation, as it adjusts the spacing appropriately; it might also
-% be useful at the end of a part which finishes with an
+% The starred version differs by adjusting the position of the mark
+% indicator, and should be used either (i) after (for example) an
% itemized list, or some other structure which leaves an expanse of
-% white space on the right-hand side of the page.
+% white space on the right-hand side of the page; or (ii) within
+% an \emph{unnumbered} equation. If, in case (ii), the style of
+% the part-marks indicators is such that the indicator may be
+% mistaken for an equation number, then it would be wise to use
+% either |\partmarks*| or plain |\partmarks| after the equation,
+% instead.
+%
% The unstarred version should only be used at the end of a
% paragraph, and in fact forces a paragraph end; the starred
-% version should generally be used only at the end of a paragraph,
-% but it doesn't force one.
+% version should on stylistic grounds generally be used only at the
+% end of a paragraph, but it doesn't force one.
%
% \DescribeMacro{\comment}
% \cmd|\comment{<text>}| associates a comment with a part of the text.
@@ -527,11 +554,11 @@
% \DescribeMacro{\shout}
% If there is part of a question which is, for example, incomplete,
% and which needs a more prominent callout than `comment', then you
-% should |\shout{...}| it. Shouts appear in all modes (including
+% should |\shout{...}| it. Shouts appear in all modes (\emph{including}
% \Lopt{final}) and appear whether or not the class is showing solutions.
% This makes a prominent remark in the text, and also in a list of
-% shouts at the end of the text. Your co-authors really have no
-% excuse for missing it after that.
+% shouts at the end of the text. Your co-authors, or the exam
+% proof-checker, really have no excuse for missing it after that.
%
% \DescribeMacro{\leftnudge}
% For various reasons, most often because of printing problems, it can
@@ -571,8 +598,8 @@
% \begin{description}
% \item[University course code]
% This is the code for the course (and thus for the paper) as it
-% appears in university information systems (for example,
-% MyCampus), and is a university-unique code such as `PHYS3031'.
+% appears in university information systems, and is a
+% university-unique code such as `PHYS3031'.
% \item[School course code]
% This is a more informal, but more recognisable, code for the
% course/paper, as it is generally recognised within the school;
@@ -584,7 +611,7 @@
% This is a textual description of the qualifications that the
% students doing this exam are heading for. This text has little
% formal weight, but might help a lost student realise they're in
-% completely the wrong exam room\dots. This is something like
+% completely the wrong exam room\dots. This is something like
% |{Physics 3\\Chemical Physics 3}| (separate each description
% using |\\|).
% \end{description}
@@ -599,7 +626,7 @@
% \DescribeMacro{\paperident}
% It can be convenient to add some identification to each page, if for
% no other reason than to double-check that you haven't inserted a
-% field theory question into an ExCos exam. The command |\paperident|
+% field theory question into an `astronomy for poets' exam. The command |\paperident|
% allows you to declare some text which appears at the bottom of each
% page of the exam. It will typically repeat some of the text in the
% |\schoolcoursecode| or |\degreedescriptions| arguments.
@@ -724,7 +751,7 @@
% The most typical changes here will be to adjust the exam rubric for
% a particular class, with the command |\baserubric|, and to change the
% sheet of physical constants, with the command |\constantssheet|.
-% See the file |A1.clo| for examples.
+% See the sample file |A1.clo| for examples.
%
% Examine this sample \file{SpecialExam.clo} file:
% \begin{verbatim}
@@ -734,7 +761,8 @@
% \OverrideFormatting{
% \renewcommand\FormatPartMarks[1]{\{#1\}}
% \renewcommand\FormatPartNumber
-% {\hbox to 0pt{\hss (\alph{partnumber})\hskip1em}}
+% {\hbox to 0pt{\hss (\StylePartNumber{partnumber})\hskip1em}}
+% \let\StylePartNumber\roman % as opposed to \alph
% \renewcommand\FormatQuestionNumber
% {\hbox to 0pt{\hss \textbf{\@currentquestion}\hskip2.5em}}
% }
@@ -776,6 +804,11 @@
% markers will jut into the left-hand margin, rather than being
% run-in.
%
+% \item[StylePartNumber]
+% This overrides how to style the |\part| markers. The default is
+% |\alph|, but you might prefer, for example, |\Roman| or |\arabic|.
+% Override this with |\let\StylePartNumber\Roman|.
+%
% \item[FormatQuestionNumber]
% If you adjust the part marks, you should probably adjust the
% formatting of the question number also.
@@ -1100,12 +1133,30 @@ have a clue.
\DeclareOption{colour}{}
% \end{macrocode}
%
-% Option \Lopt{bigfont} prints a version of the exam in a `huge'
-% font, to help students with visual impairments.
+% Options \Lopt{largefont} and \Lopt{hugefont} print versions of the
+% exam in `big' or `huge' font sizes, to help students with visual impairments.
+% The available font variants are represented as numbers.
+% Note: the |\examn@fontvariant| mechanism is in principle more
+% general than simply size variants, but some of the code below
+% assumes that |\examn@fontvariant| greater than zero means large
+% text, and so would need to be adjusted if this becomes untrue.
+%
+% The flag |\ifbigfont| is true if the font is `significantly large';
+% option \Lopt{hugefont} sets it true, option \Lopt{largefont} does
+% not; it's intended to be a user-visible and -settable flag.
+% \emph{Note:} the \Lopt{hugefont} option used to be \Lopt{bigfont};
+% the latter is deprecated and may be removed in v1.2.
% \begin{macrocode}
+\newcount\examn@fontvariant
+ \examn@fontvariant=0 % the default
\newif\ifbigfont
-\bigfontfalse
-\DeclareOption{bigfont}{\bigfonttrue}
+ \bigfontfalse
+\DeclareOption{largefont}{\examn@fontvariant=1 \bigfontfalse}
+% Deprecate [bigfont]; consider removing in v1.2
+\DeclareOption{bigfont}{%
+ \ClassWarning{exam-n}{OPTION [bigfont] HAS BEEN DEPRECATED; use [hugefont] instead}
+ \examn@fontvariant=2 \bigfonttrue}
+\DeclareOption{hugefont}{\examn@fontvariant=2 \bigfonttrue}
% \end{macrocode}
%
% This class is based on the article class. Load it, and pass the \texttt{a4paper}
@@ -1253,7 +1304,7 @@ have a clue.
% \begin{macrocode}
\def\examn@setdocident{%
\begingroup
- % yes, a big \ifcase would be more straightforward;
+ % yes, a big \ifcase would be more straightforward;
% no, that wouldn't be any fun at all
% (also it ends up looking messy and even tricksier).
\def\@step##1##2\@nil{\advance\@tempcnta##1 \def\@tempa{##2}}
@@ -1328,15 +1379,15 @@ have a clue.
\fi
\ClassWarningNoLine{exam-n}{Using Mathtime fonts}
\or % use mtpro2 fonts
- \RequirePackage[T1]{fontenc}
- \RequirePackage{textcomp}
+ \RequirePackage[T1]{fontenc}
+ \RequirePackage{textcomp}
\ifexamn@serif
\renewcommand\rmdefault{ptm} % the default
\else
- \RequirePackage[scaled=0.9]{helvet}
+ \RequirePackage[scaled=0.9]{helvet}
\renewcommand\rmdefault{phv}
\fi
- \RequirePackage[mtpbb]{mtpro2}
+ \RequirePackage[mtpbb]{mtpro2}
\ClassWarningNoLine{exam-n}{Using MTPro2 fonts}
\else
\ClassError{exam-n}{Impossible value of mtselect: \examn@mtselect}
@@ -1362,7 +1413,25 @@ have a clue.
% implement both of them by redefining |\examn@bodyfontchange|, so
% they're not in practice (a future fix, perhaps).
% \begin{macrocode}
-\ifbigfont
+\ifcase\examn@fontvariant
+ % default: do nothing
+\or
+ % font variant 1: 18pt
+ \def\examn@bodyfontchange{
+ \renewcommand\normalsize{%
+ \@setfontsize\normalsize{18}{24}%
+ \abovedisplayskip 18\p@ \@plus3.5\p@ \@minus9\p@
+ \abovedisplayshortskip \z@ \@plus5\p@
+ \belowdisplayshortskip 10\p@ \@plus5\p@ \@minus5\p@
+ \belowdisplayskip \abovedisplayskip
+ \let\@listi\@listI}
+ \parindent=24pt
+ \parskip=18pt
+ % Redefine \FormatPartMarks so that it doesn't push the text off the paper
+ \let\FormatPartMarks\examn@variantFormatPartMarks
+ }
+\or
+ % font variant 2: 36pt
\def\examn@bodyfontchange{
\renewcommand\normalsize{%
\@setfontsize\normalsize{36}{42}%
@@ -1374,18 +1443,28 @@ have a clue.
\parindent=48pt
\parskip=36pt
% Redefine \FormatPartMarks so that it doesn't push the text off the paper
- \def\FormatPartMarks##1{
- \setbox0=\hbox{\hskip 1em \textbf{[##1]}}
- \@tempdima=0.8\marginsize
- \ifdim\wd0>\@tempdima
- \advance\@tempdima -\wd0
- \hbox to 0pt{\hskip\@tempdima \box0\hss}%
- \else
- \hbox to 0pt{\box0\hss}
- \fi}}
+ \let\FormatPartMarks\examn@variantFormatPartMarks
+ }
+\else
+ % Bad font variant
+ \ClassError{exam-n}
+ {Bad font variant \examn@fontvariant}
+ {I didn't expect to see that number (broken style file re largefont/hugefont?)}
\fi
% \end{macrocode}
-%
+% The above font variants require a |\FormatPartMarks| variant which
+% avoids being pushed off the edge of the page.
+% \begin{macrocode}
+\def\examn@variantFormatPartMarks#1{%
+ \setbox0=\hbox{\hskip 1em \textbf{[#1]}}%
+ \@tempdima=0.8\marginsize
+ \ifdim\wd0>\@tempdima
+ \advance\@tempdima -\wd0
+ \hbox to 0pt{\hskip\@tempdima \box0\hss}%
+ \else
+ \hbox to 0pt{\box0\hss}%
+ \fi}
+% \end{macrocode}
%
% \subsubsection{Exam metadata}
%
@@ -1420,7 +1499,7 @@ have a clue.
\let\@tempb\leavevmode
\def\dd##1\\{%
\def\@tempa{##1}%
- \ifx\@tempa\@empty
+ \ifx\@tempa\@empty
\let\next\relax
\else
\@tempb\hbox{##1}\let\next\dd
@@ -1459,12 +1538,12 @@ images may not be used in examinations without prior arrangement.
\def\CheckTotalQuestions{%
\ifnum\@draftstatus < 2
\ifx\@numquestions\@empty \else
- \ifnum\questionnumber=\@numquestions \else
+ \ifnum\c@questionnumber=\@numquestions \else
\ClassWarning{exam-n}
- {Expected \@numquestions\space questions, got \the\questionnumber!}
+ {Expected \@numquestions\space questions, got \thequestionnumber!}
\ifnum\@draftstatus > 0 % draft mode
\begin{center}
- \textbf{\highlighted{Expected \@numquestions\space questions, got \the\questionnumber}}
+ \textbf{\highlighted{Expected \@numquestions\space questions, got \thequestionnumber}}
\end{center}
\fi
\fi
@@ -1581,7 +1660,7 @@ images may not be used in examinations without prior arrangement.
% |begingroup |ttfamily
% \catcode`\{=12 \catcode`\}=12 \catcode`\\=12
% |noindent \newcommand\FormatPartNumber{|linebreak
-% |noindent|quad\hbox to 2em{(\alph{partnumber})\hss}}
+% |noindent|quad\hbox to 2em{(\StylePartNumber{partnumber})\hss}}
% |endgroup
% \end{quotation}
% works adequately as a part number,
@@ -1592,19 +1671,38 @@ images may not be used in examinations without prior arrangement.
\setlength{\parskip}{\bigskipamount}
% \end{macrocode}
%
+% We must clear out any floats at the end of the paper, without
+% forcing a new page (figures and tables don't float, but there are
+% other packages which can generate floats, such as the
+% \Lenv{sidewaystable} from the \Lpackage{rotating} package).
+% This technique is simplified form Donald Arsenau's \Lpackage{placeins} package.
+% \begin{macrocode}
+\def\examn@flushfloats{\par
+ \begingroup
+ \edef\@tempa{\@deferlist\@dbldeferlist}
+ \ifx\@tempa\@empty \else
+ \clearpage
+ \fi
+ \endgroup
+}
+% \end{macrocode}
% Text at the end of the paper. Command |\ClosingText| is added to
% |\AtEndDocument|, below.
% \begin{macrocode}
\ifcase\@draftstatus % Final version
\def\ClosingText{
+ \examn@flushfloats
\begin{center}\textbf{End of Paper}\\\end{center}
\mark{END}}
\or % Draft version
\def\ClosingText{
+ \examn@flushfloats
\begin{center}\textbf{End of Draft Paper}\\\end{center}
\mark{END}}
\else % Compose version (nothing, because this would be on a page by itself)
- \def\ClosingText{\mark{END}}
+ \def\ClosingText{
+ \examn@flushfloats
+ \mark{END}}
\fi
% \end{macrocode}
%
@@ -1649,7 +1747,7 @@ images may not be used in examinations without prior arrangement.
\def\@tempa{END}
\xdef\examn@topmark{\botmark}
\ifx\examn@topmark\@empty
- \formatcontinuations{Paper continued over}%
+ \formatcontinuations{Paper continued over\dots}%
\else\ifx\examn@topmark\@tempa
\formatcontinuations{END}
\else
@@ -1817,7 +1915,7 @@ images may not be used in examinations without prior arrangement.
\leftskip=0pt plus1fil \rightskip=0pt \parfillskip=0pt
\baselineskip=2.5ex
\parskip=0.25ex
- \let\\\par
+ \let\\\par
\ifx\@examdate\@empty
\shout{missing exam date}
\else
@@ -1883,15 +1981,16 @@ images may not be used in examinations without prior arrangement.
\vskip 2\baselineskip plus 0.3fil
\parindent=0pt
\parskip=0.5\baselineskip
- \ifbigfont
+ \ifnum\examn@fontvariant > 0
% Don't put the rubric here (see below)
+ {\LARGE Rubric: see overleaf}
\else
\ifx\@rubric\@empty\else
\ifx\@rubric\@nnil\else
- % if there's a rubric, separate from the base rubric, then
+ % If there's a rubric, separate from the base rubric, then
% separate the two with an hrule (the per-exam rubric
% presumably represents special instructions for this exam,
- % so should be highlighted
+ % so should be highlighted)
\vbox{\let\emph\textbf
\@rubric
\par}
@@ -1903,10 +2002,10 @@ images may not be used in examinations without prior arrangement.
% \end{macrocode}
% Let the base rubric be a justified block of text near the bottom.
% \begin{macrocode}
- \ifx\@baserubric\@empty \else
- \@baserubric \par
- \fi
- \fi % end \ifbigfont\else
+ \ifx\@baserubric\@empty \else
+ \@baserubric \par
+ \fi
+ \fi % end \ifbigfont \else ...
\end{center}
% \end{macrocode}
% These various fractions of fil glue don't add up as I'd expect
@@ -1955,7 +2054,7 @@ images may not be used in examinations without prior arrangement.
%
\examn@bodyfontchange
\normalfont\normalsize
- \ifbigfont
+ \ifnum\examn@fontvariant>0
% Put the rubric on a second page, in the 'huge' size.
\begin{center}
\parskip=18pt
@@ -2016,7 +2115,7 @@ images may not be used in examinations without prior arrangement.
% their arguments. If we don't, then \LaTeX\ gets \emph{terribly}
% confused about what the mark is. I don't quite follow what happens
% in this case, but symptoms include Babel blowing up, and
-% \TeX\ running out of stack space.
+% \TeX\ running out of stack space. So: bad.
% \begin{macrocode}
\let\sectionmark\@gobble
\let\subsectionmark\@gobble
@@ -2032,13 +2131,24 @@ images may not be used in examinations without prior arrangement.
\def\subparagraph{\@badsection{subparagraph}}
% \end{macrocode}
%
+% The above redefinitions break the |\tableofcontents| macro.
+% It's unlikely but \emph{possibly} useful, in some cases, to have a
+% table of contents in an exam paper. Whether or not it is, we should
+% avoid breaking it, on a principle of least surprise. The following
+% makes the macro work again, even though it's not particularly
+% pretty.
+% \begin{macrocode}
+\renewcommand\tableofcontents{\bigskip
+ \hbox to \textwidth{\hfil\textbf{\Large Contents}\hfil}%
+ \@starttoc{toc}}
+% \end{macrocode}
+%
% Counters:
% \begin{macrocode}
\newcount\marktotal % number of marks accumulated so far
\newcount\markgoal % number of marks we should have in the end
-
-\newcount\questionnumber
-\questionnumber=0
+\newcounter{questionnumber}
+\setcounter{questionnumber}0
% \end{macrocode}
%
% Counter partnumber holds the number (i,ii,iii, etc) of the parts
@@ -2063,7 +2173,14 @@ images may not be used in examinations without prior arrangement.
% The default |\FormatPartNumber| creates a box the same size as a
% parindent. This therefore assumes that it's following a |\noindent|.
% \begin{macrocode}
-\newcommand\FormatPartNumber{\hbox to \parindent{(\alph{partnumber})\hss}}
+\newcommand\FormatPartNumber{\hbox to \parindent{(\StylePartNumber{partnumber})\hss}}
+% \end{macrocode}
+% And by default we use alphanumeric counters for parts (we abstract
+% this, rather than simply including |\alph| in the definition of
+% |\FormatPartNumber|, so that we use the same style for the
+% `answerpartnumber' counter.
+% \begin{macrocode}
+\let\StylePartNumber\alph
% \end{macrocode}
%
% A flag indicating whether we should start a new page before the next
@@ -2139,7 +2256,7 @@ images may not be used in examinations without prior arrangement.
% visual display only -- doesn't count towards mark total
\setbox0=\vbox to 0pt{\vss
\hbox to \textwidth{\hfil\hbox to 0pt{\quad\small[\dots #1]\hss}}
- \vskip0.25ex }
+ \vskip0.25ex }%
% the next line is probably unnecessary, but guarantees that box0
% has zero depth, so no extra vertical space appears because of
% this new box
@@ -2153,25 +2270,48 @@ images may not be used in examinations without prior arrangement.
\global\advance\marktotal #1
\if@tempswa
% \end{macrocode}
-% Just after maths (or some other display which doesn't fill the line)
-% -- move the part mark up a bit. We don't automatically end the
+% This is the starred form of |\partmarks|. That is, this is being invoked
+% (i) just after maths (or some other display which doesn't fill the line),
+% \emph{or} (ii) at the end of an unnumbered equation. In case (i),
+% we move the part mark up a bit; in case (ii), we format the
+% partmarks as a type of equation number
+%
+% We handle case (ii) first, by detecting whether we're in a maths
+% display. If so, we format the partmarks as an equation number, using
+% |\eqno|. Note that \Lpackage{amsmath} maths (which is what we're
+% using here) formats this differently if the material following
+% |\eqno| is of zero size, so we make this slightly larger than that.
+% \begin{macrocode}
+ \ifdim\displaywidth>0pt
+ \if@eqnsw
+ \ClassError{exam-n}{\string\partmarks* may not be used
+ within numbered equations}{Replace \string\partmarks*
+ with a \string\partmarks\ after the equation}
+ \global\advance\marktotal -#1 % to cause the mark total to be wrong
+ \else
+ \eqno \hbox to 1sp{\FormatPartMarks{#1}\hfil}%
+ \fi
+% \end{macrocode}
+% Case (i), not in maths: We don't automatically end the
% paragraph here, because a display will often not be the end of a paragraph.
% I am not at all convinced that this is the correct approach
% to nudging the partmarks text up the right amount. The
% following appears to do roughly the right thing, but there's a
% strong element of trial and error in it.
% \begin{macrocode}
- \setbox0=\vbox to 0pt{\vss
- \hbox to \textwidth{\strut\hfill\FormatPartMarks{#1}}%
- \vskip 1\baselineskip} % vskip means box has zero depth
- \ifvmode
- \box0
\else
- \vadjust{\box0}%
+ \setbox0=\vbox to 0pt{\vss
+ \hbox to \textwidth{\strut\hfill\FormatPartMarks{#1}}%
+ \vskip 1\baselineskip}% vskip means box has zero depth
+ \ifvmode
+ \box0
+ \else
+ \vadjust{\box0}%
+ \fi
\fi
% \end{macrocode}
-% Not after maths. We also end the paragraph here.
-% This is filched from the TeXBook, p106.
+% We've called the unstarred version of |\partmarks|. We also end the paragraph here
+% (this technique is filched from the TeXBook, p106).
% \begin{macrocode}
\else
\ifdim\@partmarksspace > 0pt
@@ -2235,8 +2375,8 @@ images may not be used in examinations without prior arrangement.
{Missing mark goal for question (using 0 instead)}
{Missing mark goal for question (using 0 instead)}
\def\@tempa{0}
- \fi
- \ifx\@includequestionoverridenumber\@empty
+ \fi
+ \ifx\@includequestionoverridenumber\@empty
\do@question{#1}{\@tempa}%
\else
\ClassWarning{exam-n}{Forcing question number
@@ -2304,16 +2444,16 @@ images may not be used in examinations without prior arrangement.
% \begin{macrocode}
{\par
\ifnum\ex@mcqi<\ex@nmcq
- \ClassWarning{exam-n}{Too few potential answers in MCQ \the\questionnumber}
- \@shout{Too few potential answers in MCQ \the\questionnumber}
+ \ClassWarning{exam-n}{Too few potential answers in MCQ \thequestionnumber}
+ \@shout{Too few potential answers in MCQ \thequestionnumber}
\ifnum\@draftstatus > 0
\highlighted{TOO FEW ANSWERS}\par
\fi
\fi
\ifcase\ex@mcqnanswer
\ClassWarning{exam-n}
- {No correct MCQ answer provided in question \the\questionnumber}
- \@shout{No correct MCQ answer provided in question \the\questionnumber}
+ {No correct MCQ answer provided in question \thequestionnumber}
+ \@shout{No correct MCQ answer provided in question \thequestionnumber}
\ifnum\@draftstatus > 0
\highlighted{NO CORRECT ANSWER PROVIDED}\par
\fi
@@ -2321,8 +2461,8 @@ images may not be used in examinations without prior arrangement.
% ex@mcqanswer=1: correct -- do nothing
\else
\ClassWarning{exam-n}
- {Too many correct MCQ answers provided in question \the\questionnumber}
- \@shout{Too many correct MCQ answers provided in question \the\questionnumber}
+ {Too many correct MCQ answers provided in question \thequestionnumber}
+ \@shout{Too many correct MCQ answers provided in question \thequestionnumber}
\ifnum\@draftstatus > 0
\highlighted{TOO MANY CORRECT ANSWERS}\par
\fi
@@ -2380,7 +2520,18 @@ images may not be used in examinations without prior arrangement.
\questionpreamble{}
\fi
\setcounter{partnumber}{0}
- \global\advance\questionnumber 1
+ \setcounter{answerpartnumber}{0}
+% \end{macrocode}
+% If the argument |#1| is non-empty, then it is a number, forcing the
+% question number. This is local, however -- don't use it to change
+% the sequence of questions, so don't set the `questionnumber'
+% counter, but only the current label.
+% \begin{macrocode}
+ \refstepcounter{questionnumber}
+ \def\@tempa{#1}
+ \ifx\@tempa\@empty \else
+ \edef\@currentlabel{#1}
+ \fi
% \end{macrocode}
%
% If |pageperquestion| is true, then start a new page here (unless
@@ -2410,9 +2561,9 @@ images may not be used in examinations without prior arrangement.
% \begin{macrocode}
\ifx\@tempa\@empty
% no optional argument -- easy
- \def\@currentquestion{\the\questionnumber}
+ \def\@currentquestion{\thequestionnumber}
% \end{macrocode}
-%
+%
% We have a non-null optional argument in |#1|.
% Check the question number in the argument. If there's a
% mismatch, warn in draft mode, and fail in final mode. First,
@@ -2433,27 +2584,26 @@ images may not be used in examinations without prior arrangement.
(the formatting below may be messed up).\par
\fi
% \end{macrocode}
-% Switch on the draft status: in the final version, this mismatch is
-% an error
+% Switch on the draft status: in the final version, this mismatch is an error
% \begin{macrocode}
\ifcase\@draftstatus
% Final version
\@tempcnta=#1
- \ifnum\questionnumber=\@tempcnta
+ \ifnum\c@questionnumber=\@tempcnta
\def\@currentquestion{#1}
\else
\ifx\@includequestionoverridenumber\@empty
\ClassError{exam-n}
- {\string\question[#1] is actually question \the\questionnumber!}
+ {\string\question[#1] is actually question \thequestionnumber!}
{The question in {question} environment number
- \the\questionnumber\space is specified as
+ \thequestionnumber\space is specified as
\string\question[#1].\MessageBreak
This is an error in 'final' mode.\MessageBreak
Perhaps you need \string\QuestionNumberChecksOff?}
\def\@currentquestion{???}
\else
\ClassWarning{exam-n}{Forcing question number \@includequestionoverridenumber,
- in {question} environment number \the\questionnumber}
+ in {question} environment number \thequestionnumber}
\edef\@currentquestion{\@includequestionoverridenumber}% this doesn't seem to expand in fact!
\message{current question=\@currentquestion, override \@includequestionoverridenumber}
\fi
@@ -2465,9 +2615,9 @@ images may not be used in examinations without prior arrangement.
% Draft version -- let the given number override
% \the\questionnumber, but warn if there's a difference.
\@tempcnta=#1
- \ifnum\questionnumber=\@tempcnta \else
+ \ifnum\c@questionnumber=\@tempcnta \else
\ClassWarning{exam-n}
- {\string\question[#1] is actually question \the\questionnumber!}
+ {\string\question[#1] is actually question \thequestionnumber!}
\fi
\def\@currentquestion{#1}
\else
@@ -2482,9 +2632,9 @@ images may not be used in examinations without prior arrangement.
% no optional argument -- this is possibly an error, so warn
\ClassWarning{exam-n}{\string\QuestionNumberChecksOff\ is in
force, but this question has no [number]}
- \def\@currentquestion{\the\questionnumber}
+ \def\@currentquestion{\thequestionnumber}
\else
- \typeout{Forcing question \the\questionnumber\space to be #1}
+ \typeout{Forcing question \thequestionnumber\space to be #1}
\def\@currentquestion{#1}
\fi
\fi
@@ -2498,11 +2648,18 @@ images may not be used in examinations without prior arrangement.
% question number: if it happens before, and there is a page-break
% immediately before the new question, we can get a spurious
% `Q?? continued' on the previous page.
+%
+% If a paragraph starts inside a level of grouping -- for example
+% |{\bf 1} text...| or even just |{T}ext| -- then the |\everypar|
+% tokens are expanded inside that group, which means that the
+% resetting of |\everypar| is local, with the result that the tokens
+% are reused for the next paragraph. Make the emptying of |\everypar|
+% global for that reason.
% \begin{macrocode}
\everypar{\setbox0=\lastbox % discard \box0
\FormatQuestionNumber
\mark{\@currentquestion}%
- \everypar{}}
+ \global\everypar{}}
}
% \end{macrocode}
% Format the question number. This command is documented as existing,
@@ -2512,8 +2669,7 @@ images may not be used in examinations without prior arrangement.
{\hbox to 0pt{\hss \textbf{\@currentquestion}\hskip1em}}
% \end{macrocode}
%
-% Finish off the question.
-%
+% Finish off the question:
% Format the indication of the total number
% of marks, and do a few consistency checks.
% \begin{macrocode}
@@ -2532,6 +2688,9 @@ images may not be used in examinations without prior arrangement.
\break
\fi
\fi
+% \end{macrocode}
+% In the case where the mark total doesn't match, make a noise about it.
+% \begin{macrocode}
\else
\ClassWarning{exam-n}
{Question \@currentquestion\space has a total of \the\marktotal\space marks,
@@ -2544,6 +2703,9 @@ images may not be used in examinations without prior arrangement.
\expandafter\shout\expandafter{\@tempa}
\end{center}
\fi
+% \end{macrocode}
+% Make a few tidyups in the end-question wrapper.
+% \begin{macrocode}
\examn@endquestion{%
\if@showmarktotals
\par % into vertical mode
@@ -2567,8 +2729,10 @@ images may not be used in examinations without prior arrangement.
%
% The \Lenv{questiondata} environment allows the author to provide
% some additional data or equations for the question.
+% This environment ends a preceding paragraph.
% \begin{macrocode}
\newenvironment{questiondata}{%
+ \par
\penalty50 % poor break
\vbox\bgroup
\slshape
@@ -2584,7 +2748,7 @@ images may not be used in examinations without prior arrangement.
\medskip
\hrule width \textwidth
\par
- \egroup
+ \egroup % end of \vbox
}
% \end{macrocode}
%
@@ -2672,7 +2836,7 @@ images may not be used in examinations without prior arrangement.
% remark to a list of exclamations which are highlighted at the end of
% the document.
% The argument to |\@shout| can have expandable things (such as
-% |\the\questionnumber|) in it.
+% |\thequestionnumber|) in it.
% Shouts appear in all modes and cannot be suppressed.
% \begin{macrocode}
\newtoks\@allshouts \@allshouts={}
@@ -2744,6 +2908,22 @@ images may not be used in examinations without prior arrangement.
\@insolutionfalse
% \end{macrocode}
%
+% We want to use |\part| within solutions. If we were to do so naively
+% however, we would end up incrementing the |partnumber| counter
+% which that macro uses, which either disturbs the numbering of the
+% parts in the question (if the solutions are interspersed in the
+% question) or starts out of sequence (if the solutions are at the
+% end). So we maintain a separate counter. Additionally, we want to
+% force the formatting of the solution parts, to be independent of the
+% formatting in the main question
+% \begin{macrocode}
+\newcounter{answerpartnumber}
+\newcommand{\examn@solutionpart}{%
+ \par
+ \stepcounter{answerpartnumber}
+ \noindent\hbox to \parindent{(\StylePartNumber{answerpartnumber})\hss}}
+% \end{macrocode}
+%
% Specify how solutions should be shown. The following makes them
% ragged right, slightly smaller and slanted, with rules fore and aft.
% This doesn't leap out, but the difference should be detectable.
@@ -2759,6 +2939,7 @@ images may not be used in examinations without prior arrangement.
\fi
\examn@dummycaptions % dummy captions within solutions
\typeout{SHOWING SOLUTIONS}
+ \let\part\examn@solutionpart
% \end{macrocode}
% Checks done; now get on with the layout
% \begin{macrocode}
@@ -2767,7 +2948,7 @@ images may not be used in examinations without prior arrangement.
\parskip 0.5\baselineskip
\raggedright
\color{solutiontext}%\slshape
- \ifbigfont\else
+ \ifbigfont \else
\small
\fi
\hrule
@@ -2776,6 +2957,7 @@ images may not be used in examinations without prior arrangement.
\vskip -\parskip % cancel out the following parskip
\textbf{\highlighted{Solution:}}\hskip2em
\ignorespaces
+ \parindent=2em
}
% \end{macrocode}
% The end of the solution environment is simple, and simply matches
@@ -2789,7 +2971,7 @@ images may not be used in examinations without prior arrangement.
\hrule
}
% \end{macrocode}
-%
+%
% The content of the \Lenv{solution} environment is balanced \LaTeX\
% text, and so does not have to be complicated; in particular, it does
% not have to have the generality, and the consequent restrictions, of
@@ -2897,7 +3079,7 @@ images may not be used in examinations without prior arrangement.
}
}
% \end{macrocode}
-%
+%
% \subsubsection{Solutions and pdfpages}
%
% It appears that the \Lpackage{pdfpages} package is incompatible with