% \iffalse
% makeindex -s gglo.ist -o eqexam.gls eqexam.glo
%<*copyright>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% eqexam.sty package, 2011-08-17 %%
%% Copyright (C) 2005--2011 D. P. Story %%
%% dpstory@uakron.edu %%
%% %%
%% This program can redistributed and/or modified under %%
%% the terms of the LaTeX Project Public License %%
%% Distributed from CTAN archives in directory %%
%% macros/latex/base/lppl.txt; either version 1 of the %%
%% License, or (at your option) any later version. %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%\NeedsTeXFormat{LaTeX2e}
%\ProvidesPackage{eqexam}
% [2011/09/17 v3.0m An Exam Construction Package (dps)]
%<*driver>
\documentclass{ltxdoc}
\usepackage[colorlinks,hyperindex]{hyperref}
%\pdfstringdefDisableCommands{\let\\\textbackslash}%
%\EnableCrossrefs
%\CodelineIndex
\RecordChanges
\begin{document}
\GetFileInfo{eqexam.sty}
\title{eqexam: An Exam Construction Package}
\author{D. P. Story\\
Email: \texttt{dpstory@uakron.edu}}
\date{Processed \today}
\maketitle
\tableofcontents
\let\Email\texttt
\renewenvironment{theglossary}{%
\let\efill\relax
\begin{itemize}}{\end{itemize}}
\value{GlossaryColumns}=1
\DocInput{eqexam.dtx}
\PrintIndex
\end{document}
%
% \fi
%
% \MakeShortVerb{|}
% \StopEventually{}
%
% \DoNotIndex{\def,\edef,\gdef,\xdef,\global,\long,\let}
% \DoNotIndex{\expandafter,\string,\the,\ifx,\else,\fi}
% \DoNotIndex{\csname,\endcsname,\relax,\begingroup,\endgroup}
% \DoNotIndex{\DeclareTextCommand,\DeclareTextCompositeCommand}
% \DoNotIndex{\space,\@empty,\special}
%
% \IfFileExists{\jobname.gls}{\section{Change History}\PrintChanges}{}
%
% \section{Introduction}
%
% This package is my attempt at writing a set of macros for creating exams.
% The package can be used with or without \textsf{web} or
% \textsf{exerquiz}. When used without, what is produced is a document
% suitable for printing. When \textsf{exerquiz} is used, the same document
% is produced, but with hypertext links to solutions. This may be useful
% for publishing solutions on the web, or publishing pretests with/without
% solutions.
%
% The package must be as flexible as possible vis-\`a-vis PDF. (1)
% \textsf{web} only does not add much, it does input hyperrref and test
% info such as \cs{title}, \cs{subject}, etc are placed in the Document
% Info fields of the PDF. (2) If \textsf{exerquiz} is also input (prior to
% \textsf{eqexam}), then hyperlinks will be created to the solutions to the
% test, if solutions are included at the end of the document. (3) If
% \textsf{web} and \textsf{exerquiz} are input, and the \texttt{online}
% option is taken, then the checkboxes will be come interactive, the space
% left to work the problems will be multi-line text boxes, fill-ins limited
% to True/False and simple text fill-in the blank will also become text
% boxes.
%
% When in \texttt{online} mode, the student can take the test in a computer
% lab, the completed exam can be printed and handed in, or perhaps
% submitted server-side script.
%
% \medskip\noindent
% (2011/05/13) The version of \textsf{eqexam} is a departure from previous
% versions. Previously, the list of problems were not in list, they were
% left-justified, with the problem number extending out into a little area
% determined by \cs{oddsidemargin}. This makes it hard to reformat a list
% of problems to fit into a custom book format. This new version defines a
% new environment, \texttt{eqequestions}, that makes each problem into a
% list. The list environment allows for an easy redesign of the formatting
% of the problems. The purpose of this new scheme, is to open up
% \textsf{eqexam} as a format package that can be used by author for
% writing a textbook.
%
% \newpage
% \section{Package options and Process Options}
% Let us catalog the options of this package.
%
% \subsection{Options New to eqexam}
%
% Here are some options unique to this package.
% \begin{macrocode}
%<*package>
% \end{macrocode}
% \begin{macrocode}
\usepackage{xkeyval}
% \end{macrocode}
%
% \begin{macro}{usecustomdesign}
% Use this option to avoid \textsf{eqexam} from setting up the ``standard'' page layout.
% \begin{macrocode}
\DeclareOptionX{usecustomdesign}{\eqcustomdesigntrue}
\newif\ifeqcustomdesign \eqcustomdesignfalse
% \end{macrocode}
% \end{macro}
% \begin{macro}{fortextbook}
% An option to extend the application of \textsf{eqexam} to provide support
% (exercises, providing solutions, short solutions, answers, and hints) for authors writing
% textbooks.
% \begin{macrocode}
\DeclareOptionX{fortextbook}{\eqfortextbooktrue}
\newif\ifeqfortextbook \eqfortextbookfalse
% \end{macrocode}
% The switch \cs{ifeqwritetomargins} is use by the \texttt{fortextbook} option. It is normally true,
% but if set to false, the \cs{AddToShipoutPicture} is not generated
% at the beginning of the document. Here is the code taken from below:
%\begin{verbatim}
% \ifeqfortextbook\ifeqwritetomargins
% \AtBeginDocument{\chkmarginboxwidth
% \AddToShipoutPicture{\eqe@tb@shipout}}
% \fi\fi
%\end{verbatim}
% \begin{macrocode}
\DeclareOptionX{nomarginwrite}{\eqwritetomarginsfalse}
\newif\ifeqwritetomargins\eqwritetomarginstrue
% \end{macrocode}
% \end{macro}
%
% \paragraph*{Configuration Files.}
%
% \begin{macro}{myconfig}
% \begin{macro}{myconfigi}
% \begin{macro}{myconfigii}
% We offer three sets of configuration files.
% \begin{macrocode}
\DeclareOptionX{myconfig}{\AtEndOfPackage{\eqemyconfig}}
\DeclareOptionX{myconfigi}{\AtEndOfPackage{\eqemyconfigi}}
\DeclareOptionX{myconfigii}{\AtEndOfPackage{\eqemyconfigii}}
% \end{macrocode}
%
% \paragraph*{Point options.}
%
% \begin{macro}{pointsonleft}
% \begin{macro}{pointsonright}
% \begin{macro}{pointsonboth}
% \begin{macro}{nopoints}
% \begin{macro}{totalsonleft}
% \begin{macro}{totalsonright}
% Options relating to points
% \begin{macrocode}
\DeclareOptionX{pointsonleft}{\AtEndOfPackage{\PointsOnLeft}}
\DeclareOptionX{pointsonright}{\AtEndOfPackage{\PointsOnRight}}
\DeclareOptionX{pointsonboth}{\AtEndOfPackage{\PointsOnBothSides}}
\DeclareOptionX{nopoints}{\AtEndOfPackage{\NoPoints}}
\DeclareOptionX{totalsonleft}{\AtEndOfPackage{\TotalsOnLeft}}
\DeclareOptionX{totalsonright}{\AtEndOfPackage{\TotalsOnRight}}
% \end{macrocode}
%
% \paragraph*{Totals options.}
%
% \begin{macro}{nototals}
% \begin{macro}{noparttotals}
% \begin{macro}{parttotalsonright}
% \begin{macro}{parttotalsonleft}
% \begin{macro}{noseparationrule}
% \begin{macro}{nosummarytotals}
% Options relating to totals
% \begin{macrocode}
\DeclareOptionX{nototals}{\AtEndOfPackage{\NoTotals}}
\DeclareOptionX{noparttotals}{\AtEndOfPackage{\let\eq@parttotals=n}}
\DeclareOptionX{parttotalsonright}{%
\def\eqeomarginbox{\eqeomarginboxright}}
\DeclareOptionX{parttotalsonleft}{%
\def\eqeomarginbox{\eqeomarginboxleft}}
\def\eqeomarginbox{\eqeomarginboxright}
\DeclareOptionX{noseparationrule}{%
\AtEndOfPackage{\let\separationrule\relax}}
\DeclareOptionX{nosummarytotals}{\let\eq@nosummarytotals=y}
% \end{macrocode}
% \begin{macro}{coverpage}
% Coverpage option
% \begin{macrocode}
\DeclareOptionX{coverpage}{\def\eqex@coverpage{\eqexcoverpage}%
\setcounter{page}{0}}
\define@choicekey+{eqexam.sty}{coverpagesumry}[\val\nr]%
{byparts,bypages,none}{%
\ifcase\nr\relax
\def\sumryAnnots{\cpSumrybyparts}\or
\def\sumryAnnots{\cpSumrybypages}\or
\let\sumryAnnots\relax
\fi
}{\PackageWarning{aeb}{Bad choice for coverpagesumry, permissible values
are byparts, bypages, and none. Try again}}
\let\sumryAnnots\relax
% \end{macrocode}
% Options related to how the document is built.
% \begin{macro}{nospacetowork}
% The vertical space defined by the solution environment is removed.
% \begin{macrocode}
\DeclareOptionX{nospacetowork}{%
\AtEndOfPackage{\let\eq@insertverticalspace=n}}
% \end{macrocode}
% \begin{macro}{answerkey}
% Equivalent to solutionsafter and proofing.
% \begin{macrocode}
\newif\ifanswerkey \answerkeyfalse
\DeclareOptionX{answerkey}{\answerkeytrue\eq@proofingtrue
\eq@solutionsaftertrue}
% \end{macrocode}
% \begin{macro}{vspacewithsolns}
% When \texttt{vspacewithsolns} is used, vertical space is created by
% the solutions environment, and the solutions are written to the
% end of the file.
%\changes{v2.0d}{2011/03/04}{%
% Added the \texttt{vspacewithsolns} option
%}
% \begin{macro}{ftbsolns}
% Added \texttt{ftbsolns} as an alias for \texttt{vspacewithsolns}
%\changes{v3.0h}{2011/08/17}{% 2011/08/17 v3.0h
% Added the \texttt{vspacewithsolns} option
%}
% \begin{macrocode}
\newif\ifvspacewithsolns\vspacewithsolnsfalse
\DeclareOptionX{vspacewithsolns}{%
\vspacewithsolnstrue\displayworkareatrue}
\DeclareOptionX{ftbsolns}{%
\vspacewithsolnstrue\displayworkareatrue}
% \end{macrocode}
% \begin{macro}{useforms}
% Use forms (if online option is taken); otherwise draw rectangles for multiple
% choice/multiple selection questions.
% \paragraph*{PDF Options} The various options to go beyond paper!
% \begin{macrocode}
\DeclareOptionX{useforms}{\AtEndOfPackage{\def\sqstar{*}}}
% \end{macrocode}
% \begin{macro}{online}
% \begin{macro}{pdf}
% \begin{macro}{links}
% \begin{macro}{email}
% Options related to the interactive capability of \textsf{eqexam}.
% \begin{macrocode}
\DeclareOptionX{online}{\let\eq@online=y\ExecuteOptionsX{links}}
\DeclareOptionX{pdf}{\let\load@web=y}
\DeclareOptionX{links}{\let\load@web=y\let\load@exerquiz=y}
\DeclareOptionX{email}{\let\use@email=y\ExecuteOptionsX{online}}
% \end{macrocode}
% \begin{macro}{obeylocalversions}
% This option is used for multiple versions of a document.
% \begin{macrocode}
\newif\ifeqobeylocalversion \eqobeylocalversionfalse
\DeclareOptionX{obeylocalversions}{\eqobeylocalversiontrue}
% \end{macrocode}
% \begin{macro}{usexkv}
% Causes the \textsf{xkeyval} package to be input, this option extends the option list of
% \cs{fillIn}.
% \begin{macrocode}
\DeclareOptionX{usexkv}{\let\eq@usexkeys=y}
\let\eq@usexkeys=n
% \end{macrocode}
%\paragraph*{Renditions} Options relating to renditions.
% \begin{macro}{max}
% \begin{macro}{rendition}
% The \texttt{max} and \texttt{rendition} option can be used instead of the
% \verb!\numVersions{2}! and \verb!\forVersion{a}!, respectively.
%\changes{v2.0}{2010/03/05}
%{
% Switched over to xkeyval, added max and rendition to be consistent with the
% renditions package, though we don't use the rendition package itself. eqexam
% has a more extensive renditions system already. Introduced this mostly for
% use AeB Exam Builder.
%}
% \begin{macrocode}
\let\eq@renditionOptions\@empty
\let\eq@max@selected\@empty \let\eq@ren@selected\@empty
\DeclareOptionX{max}{\def\eq@max@selected{#1}%
\g@addto@macro\eq@renditionOptions{\numVersions{#1}}}
\DeclareOptionX{rendition}{\def\eq@ren@selected{#1}%
\g@addto@macro\eq@renditionOptions{\forVersion{#1}}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%\paragraph*{Randomization} Options relating to randomization.
% \begin{macro}{allowrandomize}
% Use this option to randomize the choices of a multiple choice question.
% \begin{macrocode}
\DeclareOptionX{allowrandomize}{\AtEndOfPackage{\inputRandomizeChoices}}
\def\inputRandomizeChoices{\InputIfFileExists{aebrandom.def}
{\typeout{inputting aebrandom.def}}{cannot find aebrandom.def}}
% \end{macrocode}
% \end{macro}
% We set some defaults, and define macros for use by the document author.
% \begin{macrocode}
\let\eq@online=n
\let\use@email=n
\let\load@web=n
\let\load@exerquiz=n
\def\sqLinks{\def\sqstar{}}\sqLinks
\def\sqForms{\def\sqstar{*}}
\def\NoSpaceToWork{\let\eq@insertverticalspace=n}
\def\SpaceToWork{\let\eq@insertverticalspace=y}
\let\eq@nototals=n
\let\eq@nosummarytotals=n
\let\eq@parttotals=y
\let\eqx@separationrule=y
\let\eq@insertverticalspace=y
\let\eqex@coverpage\relax
\def\@reportpoints{0}
\let\marginpoints=\@empty
\let\totalsbox=\hfil
% \end{macrocode}
%
% \subsection{Options from Exerquiz}
%
% Options from \textsf{exerquiz} that are useful for this package.
% \begin{macro}{forpaper}
% \begin{macro}{forcolorpaper}
% Here is the list of options of \textsf{exerquiz} we plan to recognize.
% \begin{macrocode}
\DeclareOptionX{forpaper}{\eqforpapertrue
\PassOptionsToPackage{monochrome}{\eq@ColorPackage}}
\DeclareOptionX{forcolorpaper}{\eqforpapertrue} % for print
% \end{macrocode}
% \begin{macro}{preview}
% Preview shows outlines for form fields.
% \begin{macrocode}
\DeclareOptionX{preview}{\previewtrue}
% \end{macrocode}
% \begin{macro}{nosolutions}
% \begin{macro}{nohiddensolutions}
% \begin{macro}{noHiddensolutions}
% \begin{macro}{solutionsafter}
%\changes{v1.7b}{2007/21/07}{Added a \texttt{solutionsonly} option}
% \begin{macro}{solutionsonly}
% Solutions related options
% \begin{macrocode}
% dps 03/04/11
\DeclareOptionX{nosolutions}{\eq@nolinktrue\eq@nosolutionstrue
\displayworkareatrue}
\DeclareOptionX{nohiddensolutions}{\eq@globalshowsolutionstrue}
\DeclareOptionX{noHiddensolutions}%
{\eq@globalshowsolutionstrue\AtBeginDocument{\def\Hidesymbol{h}}}
\DeclareOptionX{solutionsafter}{\eq@solutionsaftertrue
\displayworkareafalse}
\DeclareOptionX{solutionsonly}{%
\solutionsonlytrue\answerkeytrue\displayworkareafalse
\AtEndOfPackage{\therearesolutionstrue\let\exerSolnsHeadnToc\relax}}
\DeclareOptionX{proofing}{\eq@proofingtrue}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{showgrayletters}
%\changes{v1.7c}{2008/08/21}
%{
% Added the \texttt{showgrayletters} option to eqexam (ported from exerquiz)
%}
% When this option is in effect, capital letters in gray appear under
% the multiple choice question boxes.
% \begin{macrocode}
\newif\ifaebshowgrayletters\aebshowgraylettersfalse
\DeclareOptionX{showgrayletters}%
{\AtEndOfPackage{\aebshowgrayletterstrue}}
% \end{macrocode}
% \end{macro}
%
%\changes{v2.0i}{2011/04/17 }
%{
% Added the switch \cs{ifdisplayworkarea} to better control when the
% work area is to be displayed.
%}
% \begin{macrocode}
\newif\ifdisplayworkarea \displayworkareafalse
% \end{macrocode}
%
% \paragraph*{Color packages}
%
% \begin{macrocode}
\IfFileExists{xcolor.sty}%
{\def\eq@ColorPackage{xcolor}\PassOptionsToPackage{xcolor}{table}}
{\def\eq@ColorPackage{color}}
\DeclareOptionX{noxcolor}{\def\eq@ColorPackage{color}}
\def\eq@drivernum{5}
\let\eqDriverName\@empty
% \end{macrocode}
%
% \subsection{Drivers Recognized}
%
% \begin{macro}{dvipsone}
% \begin{macro}{dvips}
% \begin{macro}{pdftex}
% \begin{macro}{dvipdfm}
% \begin{macro}{textures}
% A list of recognized drivers.
% \begin{macrocode}
\DeclareOptionX{dvipsone}{%
\def\eq@drivernum{0}\def\eqDriverName{dvipsone}
\PassOptionsToPackage{\eq@ColorPackage}{dvipsone}}
\DeclareOptionX{dvips}{\def\eq@drivernum{0}\def\eqDriverName{dvips}
\PassOptionsToPackage{\eq@ColorPackage}{dvips}}
\DeclareOptionX{pdftex}{\def\eq@drivernum{1}\def\eqDriverName{pdftex}
\PassOptionsToPackage{\eq@ColorPackage}{pdftex}}
\DeclareOptionX{dvipdfm}{\def\eq@drivernum{2}\def\eqDriverName{dvipdfm}
\PassOptionsToPackage{\eq@ColorPackage}{dvipdfm}}
\DeclareOptionX{textures}{%
\def\eq@drivernum{3}\def\eqDriverName{textures}
\PassOptionsToPackage{\eq@ColorPackage}{textures}}
\DeclareOptionX*{%
\PassOptionsToPackage{\CurrentOption}{\eq@ColorPackage}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macrocode}
\@ifpackageloaded{xcolor}%
{%
\@ifpackagelater{xcolor}{2004/07/04}{}
{%
\PackageError{eqexan}{%
*************************************************\MessageBreak
* Your Version of `xcolor.sty' is too old!\MessageBreak
* You need the version from 2004/07/04 or newer\MessageBreak
* or use: \string\usepackage[noxcolor]{eqexam}\MessageBreak
* or \string\documentclass[noxcolor]{article}\MessageBreak
*************************************************}{}%
}%
}{}
% \end{macrocode}
% If \textsf{exerquiz} is not loaded, when we need to define some of the switches that
% were defined in \textsf{exerquiz}.
%
% The following switches are used in the options above, and are also defined
% in web, exerquiz, or eforms.
% \begin{macrocode}
\newif\ifeq@solutionsafter \eq@solutionsafterfalse
\newif\ifsolutionsonly\solutionsonlyfalse
\newif\ifeq@hidesolution \eq@hidesolutionfalse
\newif\ifeq@globalshowsolutions \eq@globalshowsolutionsfalse
\newif\ifeq@nosolutions \eq@nosolutionsfalse
\newif\ifeq@proofing \eq@proofingfalse
\newif\ifeq@nolink \eq@nolinkfalse
\newif\ifpreview \previewfalse
\newif\ifeqforpaper \eqforpaperfalse
\def\eqemyconfig{\InputIfFileExists{eqexam.cfg}{}{}}
\def\eqemyconfigi{\InputIfFileExists{eqexami.cfg}{}{}}
\def\eqemyconfigii{\InputIfFileExists{eqexamii.cfg}{}{}}
% \end{macrocode}
%
% \subsection{Bring in Config Files}
%
% First read \texttt{web.cfg}, to possibly get the driver, then input \texttt{eqecus.opt},
% which is used to create convenient custom options.
% \changes{v1.6e}{2006/05/07}
%{
% Added a custom option feature. Just before the options are processed,
% the tex compiler looks for the file \texttt{eqecus.opt}. This file should
% contain one or more custom options.
%}
%
% Here is an example of usage for defining your own custom options, must be based on
% current options, this code would be in the file \texttt{eqecus.opt}.
%\begin{verbatim}
%\DeclareOptionX{atbdbopts}
%{%
% \ExecuteOptionsX{online}
% \ExecuteOptionsX{forcolorpaper}
% \ExecuteOptionsX{nosolutions}
% \ExecuteOptionsX{nopoints}
% \ExecuteOptionsX{nototals}
% \ExecuteOptionsX{nospacetowork}
% \ExecuteOptionsX{obeylocalversions}
% \ExecuteOptionsX{myconfig}
%}
%\end{verbatim}
% \begin{macrocode}
\InputIfFileExists{web.cfg}{}{}
\InputIfFileExists{eqecus.opt}{}{}
% \end{macrocode}
%\changes{v2.0}{2010/03/05}
%{
% Added exambuilder.cfg for use by AeB Exam Builder, to pass the values of the options
% max and rendition to eqexam.
%}
% \begin{macrocode}
\InputIfFileExists{rendition.cfg}{}{}
\InputIfFileExists{exambuilder.cfg}{}{}
% \end{macrocode}
%
% \subsection{Process Options}
%
% Now process the options.
% \begin{macrocode}
\ProcessOptionsX
% \end{macrocode}
% \begin{macro}{\showAllAnsAtEnd}
% If the user has chosen the \texttt{spacewithsolns} option, we must turn of all other solution
% options, namely \texttt{answerkey}. This command is used internally.
% \begin{macrocode}
\newcommand{\showAllAnsAtEnd}{%
\answerkeytrue\eq@proofingtrue
\eq@solutionsaftertrue\vspacewithsolnstrue
\displayworkareafalse\withsoldoctrue
}
% \end{macrocode}
% \cs{writeAllAnsAtEnd} writes the \cs{showAllAnsAtEnd} command to the solutions file.
% \begin{macrocode}
\def\writeAllAnsAtEnd{%
\let\quiz@solns\ex@solns
\immediate\write\quiz@solns{\string\showAllAnsAtEnd}%
}
% \end{macrocode}
% \end{macro}
% (2011/05/08) In the new version of \textsf{eqexam}, the one that makes the problems within an \texttt{exam}
% environment, into a list, the solutions file that appears at the end of the document
% also needs to be put into a list. Here, we define the command that writes
% the beginning of the \texttt{eqequestions} environment to the beginning of the \cs{jobname.sol} file.
% \begin{macrocode}
\newcommand{\setSolnMargins}[1]{\setlength\eqemargin{#1}}
\def\writeBeginEqeQuestions{%
\let\quiz@solns\ex@solns
\immediate\write\quiz@solns{\string\setSolnMargins{\the\eqemargin}}%
\immediate\write\quiz@solns{\string\begin{eqequestions}}%
}
% \end{macrocode}
% (2011/05/08) We define the command that writes the end of the \texttt{eqequestions}
% environment to the beginning of the \cs{jobname.sol} file.
% \begin{macrocode}
\def\writeEndEqeQuestions{%
\let\quiz@solns\ex@solns
\immediate\write\quiz@solns{\string\end{eqequestions}}%
}
% \end{macrocode}
% If \cs{ifvspacewithsolns} we set the switches need to simulate
% \texttt{nosolutions}.
% \begin{macrocode}
\ifvspacewithsolns
\answerkeyfalse\eq@proofingfalse\eq@solutionsafterfalse
\eq@nolinkfalse\eq@nosolutionsfalse\displayworkareatrue
\fi
% \end{macrocode}
%
% \subsection{Save Switch Values}
%
% Now, save the current state of the switches defined above. When, and if,
% the packages web, \textsf{exerquiz} and \textsf{eforms} are loaded, they will overwrite the
% choices set by the author, so we save them.
% \begin{macrocode}
\let\savedeq@online\eq@online
\let\savedifeq@solutionsafter\ifeq@solutionsafter
\let\savedifeq@hidesolution\ifeq@hidesolution
\let\savedifeq@globalshowsolutions\ifeq@globalshowsolutions
\let\savedifeq@nosolutions\ifeq@nosolutions
\let\savedifeq@proofing\ifeq@proofing
\let\savedifeq@nolink\ifeq@nolink
\let\savedifpreview\ifpreview
\let\savedifeqforpaper\ifeqforpaper
\let\ifnosolutions\ifeq@nosolutions
% \end{macrocode}
% \section{Required Packages}
% The following are the required packages for \textsf{eqexam}.
% \begin{macrocode}
\RequirePackage{amstext,amssymb}
% \end{macrocode}
% Bring the \texttt{comment} package in early, before \texttt{verbatim}, these two
% clash a bit.
% \begin{macrocode}
\RequirePackage{comment}
% \end{macrocode}
% (2011/05/08) Just before the file is closed and input, we write the end
% of the \texttt{eqequestions} environment, \verb!\end{eqequestions}!.
% \begin{macrocode}
%\AtEndDocument{\writeEndEqeQuestions}
% \end{macrocode}
% The macro \cs{includeexersolutions} is defined in \textsf{eqexam.def}. We execute
% the command \cs{include@solutions} before the web package is loaded. The \textsf{web} package
% has a \cs{AtEndDocument} as well, and inserts a new page that we don't want.
% \begin{macrocode}
\AtEndDocument{\includeexersolutions}
%\AtEndDocument{\include@solutions}
% \end{macrocode}
% If user has specified one of the pdf options (pdf, links, online, email), we bring in
% the web package.
% \begin{macrocode}
\@ifpackageloaded{web}{\let\load@web=y}{%
\ifx\load@web y \ifnum\eq@drivernum=5
\PackageInfo{eqexam}{You have not selected a driver %
for eqexam. Perhaps the \MessageBreak
driver is introduced through web.cfg%
}\fi\RequirePackage[\eqDriverName]{web}%
\edef\@pdfcreator{\@pdfcreator, The eqexam Package}\fi
}
% \end{macrocode}
% If user has specified links, online or email, we bring in the exerquiz package.
% \begin{macrocode}
\@ifpackageloaded{exerquiz}{\let\load@exerquiz=y}{%
\ifx\load@exerquiz y
\RequirePackage[nodljs]{exerquiz}[2011/08/30]
% \end{macrocode}
% We input \textsf{exerquiz} with the \texttt{nodljs}, we don't need all the JavaScript
% to process interactive shortquizzes or quizzes, but we do want the option of
% adding in document JavaScript, so after we input \textsf{exerquiz}, we set the
% switches to allow these features.
% \begin{macrocode}
\let\importdljs=y
\let\execjs=y
\fi
}
% \end{macrocode}
% Here is a fix to a problem I've been having previewing in dviwindo. I've traced
% the problem down to \cs{@pdfviewparams}, and changing the the following. Hope it
% causes no more problems.
% \begin{macrocode}
\def\eqDvipsone{dvipsone}
\ifx\eqDriverName\eqDvipsone
\@ifpackageloaded{hyperref}
{\renewcommand\@pdfviewparams{ null null null}}{}
\fi
% \end{macrocode}
% Now that we have possibly input web or exerquiz, we need to restore the authors options.
% \begin{macrocode}
\let\eq@online\savedeq@online
\let\ifeq@solutionsafter\savedifeq@solutionsafter
\def\ifsolutionsafter{\ifeq@solutionsafter} % user interface
\let\ifeq@hidesolution\savedifeq@hidesolution
\let\ifeq@globalshowsolutions\savedifeq@globalshowsolutions
\let\ifeq@nosolutions\savedifeq@nosolutions
\let\ifeq@proofing\savedifeq@proofing
\let\ifeq@nolink\savedifeq@nolink
\let\ifpreview\savedifpreview
\let\ifeqforpaper\savedifeqforpaper
% \end{macrocode}
% Other packages of interest.
% \begin{macrocode}
\RequirePackage{\eq@ColorPackage}
\RequirePackage{calc}
\RequirePackage{pifont}
% \end{macrocode}
% Here, I input the \texttt{verbatim} package after the comment package.
% \begin{macrocode}
\RequirePackage{verbatim}
% \end{macrocode}
% When constructing paper tests, I often use a multi-column format for some of
% the questions, so let's require this package
% \begin{macrocode}
\RequirePackage{multicol}
\setlength\columnseprule{.4pt}
\raggedcolumns\multicolsep=3pt
% \end{macrocode}
% \begin{macrocode}
\ifeqfortextbook
\RequirePackage{eso-pic}
\fi
% \end{macrocode}
% \section{Page Layout}
% (2011/05/08) The revised version of \texttt{eqexam} allows the document author
% to more easily design the size of the page; the new version makes all content
% inside the \texttt{exam} environment into a list, this gives us better control over the
% margins and spacing.
% \begin{macro}{\eqexammargin}
% (2011/05/08) Use this command to set the margin for the \texttt{exam} environment.
% \begin{macrocode}
\newlength{\eqemargin}
\def\eqe@decPointPrb{.}\def\eqe@dpsepPrb{\ }
\def\eqe@prtsepPrb{\ }\def\eqe@hspannerPrb{\ }
\newcommand{\eqexammargin}[2][\normalsize\normalfont\bfseries]{%
\settowidth{\eqemargin}{#1#2\eqe@decPointPrb\eqe@hspannerPrb}}
% \end{macrocode}
% (2011/05/08) The default margin for the \textsf{eqexam} environment, two digits and a space.
% \begin{macrocode}
\eqexammargin{00}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
\newcommand{\widthtpboxes}{35pt}
% \end{macrocode}
% \begin{macro}{\eqeSetExamPageParams}
% (2011/05/08) The default spacing maximizes the amount of space on the page.
% \begin{macrocode}
\newcommand{\eqeSetExamPageParams}{%
\setlength{\headheight}{12pt}
\setlength{\topmargin}{-.5in}
\setlength{\headsep}{20pt}
\setlength{\oddsidemargin}{0pt}
\setlength{\evensidemargin}{0pt}
\setlength{\marginparsep}{11pt}
\setlength{\marginparwidth}{35pt}
\setlength{\footskip}{11pt}
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\eqExamPageLayout}
% Set the basic parameters of this exam page package
% \begin{macrocode}
\newcommand{\eqExamPageLayout}{%
\setlength\textwidth\paperwidth
\addtolength{\textwidth}{-2in}
\addtolength{\textwidth}{-\oddsidemargin}
\setlength\textheight{\paperheight}
\addtolength\textheight{-2in}
\addtolength\textheight{-\headheight}
\addtolength\textheight{-\headsep}
\addtolength\textheight{-\topmargin}
\addtolength\textheight{-\footskip}
}
% \end{macrocode}
% (2011/05/08) If \texttt{usecustomdesign} is used it is expected that
% \cs{eqe\-Set\-Exam\-Page\-Params} and \cs{eqeSetExamPageParams} are redefined in he preamble,
% otherwise, we set up the standard parameters; otherwise
% \begin{macrocode}
\ifeqcustomdesign\else
\eqeSetExamPageParams
\eqExamPageLayout
\fi
% \end{macrocode}
% \end{macro}
% A simple page layout scheme for this exam.
% \begin{macrocode}
\newcommand{\ps@eqExamheadings}
{%
\renewcommand{\@oddhead}{%
{%
\normalfont\normalsize
\ifnum\value{page}<2 \hfil
\else\eqExamRunHead\fi
}%
}
\renewcommand{\@evenhead}{\@oddhead}
\renewcommand{\@oddfoot}{\settotalsbox}
\renewcommand{\@evenfoot}{\@oddfoot}}
\raggedbottom
% \end{macrocode}
% \section{Counters, Lengths and Tokens}
% Some counters to keep track of things. \DescribeEnv{eqpointsofar}
% \DescribeEnv{eqpointsthispage} The first two counters keep track, respectively,
% of the total points so far up the current page, and the number of points
% on the current page. \DescribeEnv{eq@numparts} The counter \texttt{eq@numparts}
% holds the number of parts of the multi-part question.
% \begin{macrocode}
\newcounter{eqpointsofar}
\newcounter{eqpointsthispage}
\newcounter{eq@numparts}
\newcounter{eq@count}
\newtoks\partNames \partNames={}
\newlength{\eq@tmplengthA}
\newbox{\eq@pointbox}
\newlength{\eq@pointboxtotalheight}
% \end{macrocode}
% Some scratch registers to do calc calculations.
% \begin{macrocode}
\newlength{\eqetmplengtha}
\newlength{\eqetmplengthb}
% \end{macrocode}
% \section{Some Macros to Support the Options}
% We make a few definitions to support various options.
% \begin{macrocode}
\def\eqbothmargins#1#2{\eqleftmargin{#1}{#2}\eqrightmarginbox{#1}{#2}}
\def\PointsOnLeft{\def\@reportpoints{1}\let\marginpoints\eqleftmargin}
\def\PointsOnRight{\def\@reportpoints{2}\relax
\let\marginpoints\eqrightmarginbox}
\def\PointsOnBothSides{\def\@reportpoints{3}\relax
\let\marginpoints\eqbothmargins}
\def\NoPoints{\def\@reporttotals{0}\let\totalsbox=\hfil
\let\marginpoints\@empty\let\eq@nosummarytotals=y}
\def\TotalsOnLeft{\def\@reporttotals{1}\def\totalsbox{\totalsboxleft}}
\def\TotalsOnRight{\def\@reporttotals{2}\def\totalsbox{\totalsboxright}}
\def\NoTotals{\def\@reporttotals{0}\let\totalsbox=\hfil}
\def\eoeTotalOff{\let\eq@parttotals=n}
\def\eoeTotalOn{\let\eq@parttotals=y}
\def\separationruleOn{\let\eqx@separationrule=y}
\def\separationruleOff{\let\eqx@separationrule=n}
\def\AllowFitItIn{\global\let\eq@fititin\eqfititin}
\def\DoNotFitItIn{\global\let\eq@fititin\@gobble}
% \end{macrocode}
% \begin{macro}{\vspacewithkeyOn}
% \begin{macro}{\vspacewithkeyOff}
%\changes{v2.0k}{2011/04/29}{Added user interface to the switch
%\cs{ifkeepdeclaredvspacing}, which is defined in \texttt{eqexam.def}/\textsf{exerquiz}.}
% User interface to keeping the declare vspace, even when
% the \texttt{answerkey} (or \texttt{solutionsafter}) option is taken. The switch
% \cs{ifkeepdeclaredvspacing} is defined in \texttt{eqexam.def}/\textsf{exerquiz}.
% \begin{macrocode}
\def\vspacewithkeyOn{\keepdeclaredvspacingtrue}
\def\vspacewithkeyOff{\keepdeclaredvspacingfalse}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\encloseProblemsWith}
%\changes{v1.7b}{2007/21/07}
%{%
% Added \cs{encloseProblemsWith} to support the \texttt{solutionsonly} option
%}
% \cs{encloseProblemsWith} to support the \texttt{solutionsonly} option
% \begin{macrocode}
\def\encloseProblemsWith#1{%
\ifsolutionsonly\excludecomment{#1}\else
\includecomment{#1}\fi
}
% \end{macrocode}
% \end{macro}
% \section{Colors}
% \begin{macro}{\proofingsymbolColor}
% \begin{macro}{\instructionsColor}
% \begin{macro}{\eqCommentsColor}
% \begin{macro}{\universityColor}
% \begin{macro}{\titleColor}
% \begin{macro}{\authorColor}
% \begin{macro}{\subjectColor}
% \begin{macro}{\linkcolor}
% \begin{macro}{\nolinkcolor}
% \begin{macro}{\fillinColor}
% \begin{macro}{\forceNoColor}
% Here we list commands for controlling colors. There are some other colors defined
% in the stand alone code.
% \changes{v1.6e}{2006/05/07}
% {
% Added easy user access to various colors, \cs{proofing\-symbol\-Color},
% \cs{instructionsColor}, \cs{eqCommentsColor}, \cs{authorColor},
% \cs{title\-Color}, \cs{universityColor} and \cs{subjectColor}
% }
% \begin{macrocode}
\providecommand{\proofingsymbolColor}[1]{\def\@proofingsymbolColor{#1}}
\proofingsymbolColor{red}
\providecommand{\instructionsColor}[1]{\def\@instructionsColor{#1}}
\instructionsColor{blue}
\providecommand{\eqCommentsColor}[1]{\def\@eqCommentsColor{#1}}
\eqCommentsColor{blue}
\providecommand{\eqCommentsColorBody}[1]{\def\@eqCommentsColorBody{#1}}
\eqCommentsColorBody{black}
\providecommand{\universityColor}[1]{\def\webuniversity@color{#1}}
\universityColor{blue}
\providecommand{\titleColor}[1]{\def\webtitle@color{#1}}
\titleColor{black}
\providecommand{\authorColor}[1]{\def\webauthor@color{#1}}
\authorColor{black}
\providecommand{\subjectColor}[1]{\def\websubject@color{#1}}
\subjectColor{blue}
\providecommand{\linkcolor}[1]{\def\@linkcolor{#1}}
\linkcolor{blue}
\providecommand{\nolinkcolor}[1]{\def\@nolinkcolor{#1}}
\nolinkcolor{black}
\def\fillinColor#1{\def\eq@fillinColor{#1}}\fillinColor{red}
\newcommand{\forceNoColor}{%
\proofingsymbolColor{black}\instructionsColor{black}
\eqCommentsColor{black}\universityColor{black}
\titleColor{black}\authorColor{black}
\subjectColor{black}\linkcolor{black}
\nolinkcolor{black}\fillinColor{black}
\if\load@web y\sectionColor{black}\fi
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \section{Version Control}
% Here are some simple macros use to create two versions,
% version A and version B, of the same test.
% \begin{macro}{\examNum}
% Convenience macro for holding the exam number. It sets the
% value of \cs{nExam}.
% \begin{macrocode}
\def\examNum#1{\def\nExam{#1}}
\examNum{1}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\Exam}
% \begin{macro}{\sExam}
% Convenience macros for titling the exam. Usage:
%\begin{verbatim}
%\VersionAtext{Test~\nExam--Version A}
%\VersionBtext{Test~\nExam--Version B}
%\shortVersionAtext{T\nExam A}
%\shortVersionBtext{T\nExam B}
%
%\examNum{1}
%\forVersion{c}
%\subject[C3]{Calculus III}
%\title[\sExam]{\Exam}
%\author{Dr.\ D. P. Story}
%\end{verbatim}
% These next two definitions are overwritten by the two
% commands \cs{longTitleText} and \cs{shortTitleText}.
% \begin{macrocode}
\def\Exam{\ifAB{\eq@VersionAtext}{\eq@VersionBtext}}
\def\sExam{\ifAB{\eq@shortVersionAtext}{\eq@shortVersionBtext}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\VersionAtext}
% \begin{macro}{\VersionBtext}
% \begin{macro}{\shortVersionAtext}
% \begin{macro}{\shortVersionBtext}
% Convenience macros for entering the text for the title, long and short
% for versions A and B.
% \begin{macrocode}
\def\VersionAtext#1{\def\eq@VersionAtext{#1}}
\def\VersionBtext#1{\def\eq@VersionBtext{#1}}
\def\shortVersionAtext#1{\def\eq@shortVersionAtext{#1}}
\def\shortVersionBtext#1{\def\eq@shortVersionBtext{#1}}
\VersionAtext{Exam~\nExam--Version A}
\VersionBtext{Exam~\nExam--Version B}
\shortVersionAtext{Exam~\nExam A}
\shortVersionBtext{Exam~\nExam B}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% In this section we introduce a new set of commands that supersedes
% the commands defined above. Those commands were limited to only
% two versions. The ones below can handle up to $26$ versions.
% \begin{macrocode}
\newtoks\eqtemptokena
\newtoks\eqtemptokenb
% \end{macrocode}
% \begin{macro}{\numVersions}
% In the preamble, declare the number of versions for this document
% using \cs{numVersions}, e.g., |\numVersions{3}|. This sets the value
% of \cs{eq@nVersions}
% \begin{macrocode}
\def\numVersions#1{\ifnum#1>26\def\eq@nVersions{26}%
\PackageWarning{eqexam}{The value of \string\numVersions is too
large. \MessageBreak Choose a natural number less than 27.}
\else\def\eq@nVersions{#1}\fi}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\longTitleText}
% \begin{macro}{\endlongTitleText}
% \begin{macro}{\shortTitleText}
% \begin{macro}{\endshortTitleText}
% Next we state the long and short titles for our document,
% one for each of our declare number of versions given earlier.
% For example, we can use the value \cs{nExam} in out titles. Usage:
%\begin{verbatim}
% \longTitleText
% {Test~\nExam--Version A}
% {Test~\nExam--Version B}
% {Test~\nExam--Make Up}
% \endlongTitleText
% \shortTitleText
% {T\nExam A}
% {T\nExam B}
% {T\nExam MU}
% \endshortTitleText
%\end{verbatim}
% I've added markers that delimit the end of the arguments. In this
% way, the end of the list of titles can be detected, even though
% the number of titles is not the same as what is declared by the
% \cs{numVersions}.
%
% If there are more titles than what is declared, the rest are absorbed (gobbled).
% If there are fewer titles than declared, a {\LaTeX} package error is generated,
% and substitute titles are generated.
% \changes{v1.9f}{2009/10/06}
% {
% Modified \cs{longTitleText}, \cs{shortTitleText} to have an optional
% argument (A--Z;a--z). You can select a particular title from a list
% of titles. If no optional argument is passed, then the title determined
% by \cs{forVersion} is used.
% }
% Modified \cs{longTitleText} and \cs{shortTitleText} to have an optional
% argument (A--Z;a--z). You can select a particular title from a list
% of titles. If no optional argument is passed, then the title determined
% by \cs{forVersion} is used.
% \begin{macrocode}
\newcommand{\longTitleText}[1][]{%
\ifeqglobalversion\let\eq@selectedVersion@save\eq@selectedVersion
\else\let\eq@selectedVersion@save\relax\fi
\uppercase{\def\eqe@localTextTitle{#1}}%
\ifx\eqe@localTextTitle\@empty\else
\expandafter\forVersion\expandafter{\eqe@localTextTitle}\fi
\eqe@contTitleText{\Exam}{\endlongTitleText}%
}
\def\endlongTitleText{l}
\newcommand{\shortTitleText}[1][]{%
\ifeqglobalversion\let\eq@selectedVersion@save\eq@selectedVersion
\else\let\eq@selectedVersion@save\relax\fi
\uppercase{\def\eqe@localTextTitle{#1}}%
\ifx\eqe@localTextTitle\@empty\else
\expandafter\forVersion\expandafter{\eqe@localTextTitle}\fi
\eqe@contTitleText{\sExam}{\endshortTitleText}%
}
\def\endshortTitleText{s}
% \end{macrocode}
% Both title commands, above, call this macro which sets the environment
% for \cs{@gatherTitleText}, which gathers the list of titles.
% \begin{macrocode}
\def\eqe@contTitleText#1#2{%
\setcounter{eq@count}{0}%
\eqtemptokena={}\let\endtitleMarker#2
\@gatherTitleText{#1}%
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% This command gathers each title and places it as the argument of a
% \cs{v} command. These are accumulated in token registers
% then saved in \cs{Exam} and \cs{sExam}.
% \begin{macrocode}
\def\@gatherTitleText#1#2{%
\def\eqe@argii{#2}
\if\endtitleMarker\eqe@argii
% \end{macrocode}
% Encountered the end marker. See if we have collected the
% correct number of titles declared. If we have collected too
% few, we note an warning in the log, and create titles.
% \begin{macrocode}
\ifnum\value{eq@count}>\eq@nVersions\let\eqe@next\relax
\else\def\eqe@next{\eq@shortTitlesFix{#1}}\fi
\else
\stepcounter{eq@count}
\eqtemptokenb=\expandafter{#2}
\xdef#1{\the\eqtemptokena\expandafter\noexpand
\csname v\Alph{eq@count}\endcsname{\the\eqtemptokenb}}
\xdef\sExam{\the\eqtemptokena\expandafter\noexpand
\csname v\Alph{eq@count}\endcsname{\the\eqtemptokenb}}
\eqtemptokena=\expandafter{#1}
\ifnum\value{eq@count}<\eq@nVersions
\def\eqe@next{\@gatherTitleText{#1}}%
\else
\def\eqe@next{%
\if\endtitleMarker\endlongTitleText
\expandafter\eqe@absorbTokensLong
\else
\expandafter\eqe@absorbTokensShort
\fi
}%
\fi
\fi
\eqe@next
}
\long\def\eqe@absorbTokensLong#1\endlongTitleText{%
\protected@xdef\Exam{\Exam}\ifx\eq@selectedVersion@save\relax
\eqe@offVersion\else\expandafter\forVersion\expandafter
{\eq@selectedVersion@save}\fi}
\long\def\eqe@absorbTokensShort#1\endshortTitleText{%
\protected@xdef\sExam{\sExam}\ifx\eq@selectedVersion@save\relax
\eqe@offVersion\else\expandafter\forVersion\expandafter
{\eq@selectedVersion@save}\fi}
% \end{macrocode}
% We have reached \cs{endtitleMarker}, but the count is still less than \cs{eq@nVersions},
% so we'll warn the user, and create titles for user.
% \begin{macrocode}
\def\eq@shortTitlesFix#1{%
\PackageWarning{eqexam}{You have defined an insufficient number
of titles for the number of versions declared in
\string\numVersions. Please fix the problem}%
\stepcounter{eq@count}%
\if\endtitleMarker\endlongTitleText
\edef\eqe@tmp{\noexpand\@gatherTitleText{\noexpand#1}
{??---Title \# \the\value{eq@count}---??}%
\noexpand\endlongTitleText}
\else
\edef\eqe@tmp{\noexpand\@gatherTitleText{\noexpand#1}
{T\#\the\value{eq@count}??}\noexpand\endshortTitleText}
\fi
\addtocounter{eq@count}{-1}%
\eqe@tmp
}
% \end{macrocode}
% Here, we define \cs{ifAB} so that document under the old system
% still work properly, I hope. Usage of \cs{ifAB} at this point
% is discouraged.
% \begin{macrocode}
\def\ifAB#1#2{\if\eq@selectedVersion A#1%
\else\if\eq@selectedVersion B#2%
\fi\fi}
\def\eq@replaceToken#1{#1}
% \end{macrocode}
% \begin{macro}{\forVersion}
% Here is the command that does all the work. It creates alternate
% text macros for each of the versions declared using \cs{numVersions}.
%
% For example, assuming |\numVersions{3}| appeared earlier, the
% command |\forVersion{a}| (or |\forVersion{A}|) defines $3$ text commands \cs{vA}, \cs{vB} and
% \cs{vC}, each taking one argument, the text you want to display:
%\begin{verbatim}
% Name the \vA{place}\vB{date}\vC{year} of the signing of the Declaration
% of independence.
%\end{verbatim}
% Since we said |forVersion{a}| only the \cs{vA} text
% is displayed, the others are gobbled up, etc. But wait, the \cs{forVersion}
% does more than that! It also creates a series of comment environments
% |\begin{verA}/\end{verA}|, |\begin{verB}/\end{verB}|, |\begin{verC}/\end{verC}|, etc.,
% where only the version for which this compile applies will be typeset,
% the others are commented out.
%\begin{verbatim}
%\numVersions{3}
%\forVersion{b}
%...
%\begin{document}
%...
% Solve the equation for $\vA{x}\vB{y}\vC{z}$:
%\[
%\begin{verA}
% 2x + 4 = 7
%\end{verA}
%\begin{verB}
% 5y + 2 = 4
%\end{verB}
%\begin{verC}
% 3z - 2 = 2
%\end{verC}
%\]
%\end{verbatim}
% \changes{1.6b}{2006/04/03}
% {
% Changed the alphabet environments \texttt{A}, \texttt{B}, etc.\ due to a
% conflict with \cs{S}, the control sequence for the \textsf{amsmath} package
% for a section: \cs{S} expands to \S. Names changed to \texttt{verA}, \texttt{verB}, etc.
% }
% \changes{v1.6f}{2006/10/24}
% {
% Fixed a bug in the \cs{eqe@initializeMultiVersions} command, made sure that any
% already defined comment environments are set to relax.
% }
% \begin{macrocode}
\newif\ifeqglobalversion \eqglobalversionfalse
\newif\ifeqlocalversion \eqlocalversionfalse
\newif\if@templocalversion \@templocalversionfalse
\def\eqe@initializeMultiVersions{%
\let\save@message\message\let\message\@gobble
\@tfor\eqe@tmp:=ABCDEFGHIJKLMNOPQRSTUVWXYZ\do{%
\expandafter\let\csname v\eqe@tmp\endcsname\@gobble
\expandafter\excludecomment\expandafter{ver\eqe@tmp}%
\expandafter\let\csname Afterver\eqe@tmp Comment\endcsname\relax
}\let\message\save@message
}
\AtBeginDocument{\let\eqe@initializeMultiVersions\relax}
% \end{macrocode}
% (09/10/04) Trying to fix a bug in the case when the version selected is greater
% then the number of versions available for a given problem; that is, when modular
% arithmetic occurs (in \cs{selectVersion}).
% \begin{macrocode}
\let\eqe@@onVersion\@empty
\def\eqe@onVersion{\g@addto@macro\eqe@@onVersion}
\let\eqe@@offVersion\empty
\def\eqe@offVersion{\g@addto@macro\eqe@@offVersion}
\let\eqe@@holdTemp\@empty
\def\eqe@holdTemp{\g@addto@macro\eqe@@holdTemp}
% \end{macrocode}
% Two commands to turn on and off versions (the \cs{v} and the \texttt{ver}
% environment).
%
% Throughout the definitions below, we use \cs{csarg}, a command that is defined in the
% \textsf{comment} package.
% \begin{macrocode}
\def\eqe@showArg#1{#1}
\def\eqe@turnOnComment#1{%
% \csarg\let{v#1}\@empty
\csarg\let{v#1}\eqe@showArg
\edef\exp@temp{\noexpand\includecomment{ver#1}}\exp@temp
}
\def\eqe@turnOffComment#1{%
\csarg\let{v#1}\@gobble
\edef\exp@temp{\noexpand\excludecomment{ver#1}}\exp@temp
\csarg\let{Afterver#1Comment}\relax
}
% \end{macrocode}
% Finally, the \cs{forVersion} command.
% \begin{macrocode}
\def\forVersion#1%
{%
\eqe@initializeMultiVersions
\let\eqe@@onVersion\@empty
\let\eqe@@offVersion\@empty
\global\eqglobalversiontrue
\setcounter{eq@count}{0}%
\uppercase{\edef\eq@selectedVersion{#1}}%
\@ifundefined{eq@nVersions}{\PackageInfo{eqexam}{%
\string\numVersions\space has not been declared, \MessageBreak
taking the number of versions to be 2.}\def\eq@nVersions{2}}{}%
\loop
\stepcounter{eq@count}%
\expandafter\if\Alph{eq@count}\eq@selectedVersion
\xdef\eq@nSelectedVersion{\the\value{eq@count}}%
\setcounter{eq@count}{27}\fi
\ifnum\value{eq@count}<26\repeat
\ifnum\eq@nSelectedVersion >\eq@nVersions
\PackageError{eqexam}
{The value of \string\forVersion
\space(\eq@selectedVersion)\MessageBreak
exceeds the value of \string\numVersions\space
(\eq@nVersions)}%
{Decrease the value of \string\forVersion.}%
\fi
\setcounter{eq@count}{0}%
\let\save@message\message\let\message\@gobble
\loop
\stepcounter{eq@count}%
\csarg\let{After\Alph{eq@count}Comment}\relax
\lowercase
{%
\if#1\alph{eq@count}%
\eqe@turnOnComment{\Alph{eq@count}}%
% \end{macrocode}
% (09/10/04) Save the commands for turning on the version with
% \cs{eqe@onVersion}, and for turning it off with
% \cs{eqe@offVeresion}.
% \begin{macrocode}
\edef\temp@exp{\noexpand
\eqe@turnOnComment{\Alph{eq@count}}}%
\expandafter\eqe@onVersion\expandafter{\temp@exp}%
\edef\temp@exp{\noexpand
\eqe@turnOffComment{\Alph{eq@count}}}%
\expandafter\eqe@offVersion\expandafter{\temp@exp}%
\else
\eqe@turnOffComment{\Alph{eq@count}}%
\fi
}%
\ifnum\value{eq@count}<\eq@nVersions\repeat
\let\message\save@message
}
% \end{macrocode}
% Let us assume version A initially, user with reset this in document.
%\changes{1.6c}{2006/05/02}
%{%
% At the end of the package, set the initial value of \cs{select\-Version} to
% \string\verb!*+\string\selectVersion{26}+ and set the initial value
% of \cs{forVersion} to \string\verb!*+\string\forVersion{A}+.
%}
% \begin{macrocode}
\AtEndOfPackage{\numVersions{26}\forVersion{A}%
\eq@renditionOptions}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\selectVersion}
% When an exam has questions in which the number of variations are not all the same,
% then you can locally change the version between problems.
% If the first argument is empty, the first variation is chosen.
% The syntax is
%\begin{verbatim}
%\selectVersion{2}{3}
%\end{verbatim}
%This command says that the next problem has 3 variations, and here we select the second one.
%\changes{1.6a}{2006/01/22}
% {%
% added \cs{selectVersion} command, also the command was fixed \cs{forVersion} so that it can be changed
% within the document, added switches to control new selection.
% Added option \texttt{ignorelocalversions}
% }
% \begin{macrocode}
\def\selectVersion#1#2{% #1 \le #2
\xdef\nLocalSelection{#1}%
\xdef\nLocalVersions{#2}%
% \end{macrocode}
% When the solutions appear at the end of the document, the version may not match
% the version for the question. We need to use a private hook defined in
% \textsf{exerquiz} (and eqexam.def) to reproduce the same settings going going into
% each solution at the end. So, we write the \cs{selectVersion} to the solution
% file.
% \begin{macrocode}
\edef\exer@solnheadhook{%
\string\selectVersion{#1}{#2}}%
% \end{macrocode}
% Turn off messaging.
% \begin{macrocode}
\let\save@message\message\let\message\@gobble
% \end{macrocode}
% Reset the selected version, the one selected in the preamble. A previous problem
% may have changed the version due to modular arithmetic.
% \begin{macrocode}
\eqe@@onVersion
\ifx\eqe@@holdTemp\@empty\else
% \end{macrocode}
% If \cs{eqe@holdTemp} is non-empty, this means that modular
% arithmetic was performed on the previous problem. We need to turn
% on the original choice, and turn off the temporary choice, then
% clear the command \cs{eqe@@holdTemp}.
% \begin{macrocode}
\eqe@@onVersion\eqe@@holdTemp
\let\eqe@@holdTemp\@empty
\fi
% \end{macrocode}
% If \cs{eqglobalversion} is \texttt{true}, then a \cs{forVersion}
% has been executed. If the number of versions declared by
% \cs{numVersions} is greater than the number of local versions for
% this problem, then we perform modular arithmetic to get an
% appropriate alternative. It may be necessarily to temporarily put
% \cs{eqobeylocalversion} to true to accomplish, but we use change it
% back at the end.
% \begin{macrocode}
\ifeqglobalversion\ifnum\eq@nSelectedVersion>\nLocalVersions
% \end{macrocode}
% If we perform modular arithmetic, turn off original choice.
% \begin{macrocode}
\eqe@@offVersion
% \end{macrocode}
% Now perform mod arithmetic
% \begin{macrocode}
{\count0=\eq@nSelectedVersion \count2=\count0
\advance\count0by-1 \divide\count0by\nLocalVersions
\multiply\count0by\nLocalVersions \count2=\eq@nSelectedVersion
\advance\count2by-\count0
\xdef\nLocalSelection{\the\count2 }%
\ifeqobeylocalversion\else
\global\@templocalversiontrue
\global\eqobeylocalversiontrue\fi}%
\fi\fi
\ifeqglobalversion\ifnum\eq@nSelectedVersion>\nLocalVersions
\global\let\eqe@@holdTemp\@empty
{\count0=\eq@nSelectedVersion \count2=\count0
\advance\count0by-1 \divide\count0by\nLocalVersions
\multiply\count0by\nLocalVersions \count2=\eq@nSelectedVersion
\advance\count2by-\count0
\xdef\nLocalSelection{\the\count2 }%
\ifeqobeylocalversion\else
\global\@templocalversiontrue
\global\eqobeylocalversiontrue\fi}%
\fi\fi
\ifeqobeylocalversion
\global\eqlocalversiontrue
\setcounter{eq@count}{0}%
\ifx\nLocalSelection\@empty\def\nLocalSelection{1}\fi
\ifnum\nLocalSelection>\nLocalVersions\PackageWarning{eqexam}
{Selected local version greater than the number\MessageBreak
of local versions. I'm selecting version 1\MessageBreak
for you}\def\nLocalSelection{1}\fi
\let\save@message\message\let\message\@gobble
\loop
\stepcounter{eq@count}%
\csarg\let{Afterver\Alph{eq@count}Comment}\relax
\lowercase
{%
\ifnum\value{eq@count}=\nLocalSelection
\eqe@turnOnComment{\Alph{eq@count}}%
\edef\temp@exp{\noexpand
\eqe@turnOffComment{\Alph{eq@count}}}%
\expandafter\eqe@holdTemp\expandafter{\temp@exp}%
\else
\eqe@turnOffComment{\Alph{eq@count}}%
\fi
}%
\ifnum\value{eq@count}<\nLocalVersions\repeat
\let\message\save@message
\fi
\if@templocalversion\global\eqobeylocalversionfalse\fi
% \end{macrocode}
% added 09/10/03 reset back to default
% \begin{macrocode}
\@templocalversionfalse
\let\message\save@message
}
% \end{macrocode}
% \end{macro}
% \section{Title Definitions from Web}
% \begin{macro}{\title}
% \begin{macro}{\subject}
% \begin{macro}{\author}
% \begin{macro}{\email}
% \begin{macro}{\keywords}
% \begin{macro}{\university}
% Make Title Definitions taken from the \texttt{Web} package. This is
% to maintain compatibility with \texttt{Web}.
% \begin{macrocode}
\@ifpackageloaded{web}{}
{
\let\web@save@title\title
\def\title{\@ifnextchar[{\@web@title}{\@web@title[]}}
\def\@web@title[#1]#2{\gdef\webtitle{#2}%
\@ifundefined{hypersetup}{}{\hypersetup{pdftitle={#2}}}%
\def\webArg{#1}\ifx\webArg\@empty\gdef\shortwebtitle{#2}\else
\gdef\shortwebtitle{#1}\fi\web@save@title{#2}}
\let\web@saved@author\author
\def\author#1{\gdef\webauthor{#1}%
\@ifundefined{hypersetup}{}{\hypersetup{pdfauthor={#1}}}%
\web@saved@author{#1}}
\def\subject{\@ifnextchar[{\@subject}{\@subject[]}}
\def\@subject[#1]#2{\gdef\websubject{#2}
\@ifundefined{hypersetup}{}{\hypersetup{pdfsubject={#2}}}%
\def\webArg{#1}\ifx\webArg\@empty\gdef\shortwebsubject{#2}\else
\gdef\shortwebsubject{#1}\fi}
\def\email#1{\gdef\webemail{#1}}
\def\keywords#1{\gdef\webkeywords{#1}%
\@ifundefined{hypersetup}{}{\hypersetup{pdfkeywords={#1}}}}
\def\university#1{\gdef\webuniversity{#1}}
\def\web@versionlabel{Version}
\def\web@toc{Table of Contents}
\def\web@continued{cont.}
% set some defaults
\title{}\author{}\email{}\subject{}\keywords{}\university{}
\def\optionalpagematter{}
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\date}
% {\LaTeX} (\TeX) defines a \cs{date} command that is also used by \textsf{eqexam}.
% \begin{macrocode}
\def\duedate#1{\def\theduedate{#1}}
\duedate{}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\duedate}
% In addition to these, we also define a \cs{duedate} macro, may be useful for
% writing assignments with a due date.
% \begin{macrocode}
\def\duedate#1{\def\theduedate{#1}}
\duedate{}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\thisterm}
% The command \cs{thisterm} can be used in the \cs{date} field to indicate the term
% of this test, for example, \verb!\date{\thisterm, \the\year}! This command may
% be redefined to conform to your own academic terms.
% \begin{macrocode}
\newcommand\thisterm
{%
\ifnum\the\month<6
Spring%
\else
\ifnum\the\month<8
Summer%
\else
% August or later
\ifnum\the\month>8
% September or later
Fall%
\else
% month of August
\ifnum\the\day>25
Fall%
\else
Summer%
\fi
\fi
\fi
\fi
}
% \end{macrocode}
% \end{macro}
% \section{Identification Information}
% We define a series of commands in support of building an exam: Lines to identify
% the student and his/her student id (SID), the instructors email address, the name of the
% test and the course.
%\par\medskip
%\noindent\DescribeMacro{\eqExamName}\DescribeMacro{\examNameLabel} provides a line for the student to enter his/her name into the
% exam. The command \cs{examNameLabel} can be used to define the name label, the default
% is \texttt{Name:}
%
% Will insert a text box as well if the \texttt{option} is taken in addition
% to \texttt{nosolutions} and with \texttt{solutionsafter} not taken.
% This macro defines \cs{eq@ExamName}, which actually contains the code.
% The first (optional) parameter is passed to \cs{insTxtFieldIdInfo}, and can be
% used to change the appearance of the text field created; the second required parameter
% is the width of the field.
% \begin{macrocode}
\newcommand{\examAnsKeyLabel}[1]{%
\def\@examAnsKeyLabel{\ifanswerkey\space #1\fi}}
\examAnsKeyLabel{Answer Key}
\newcommand\examNameLabel[1]{\gdef\@examNameLabel{#1\@examAnsKeyLabel}}
\examNameLabel{Name:}
\newcommand\eqExamName[2][]{\gdef\eq@ExamName{%
\bgroup\settowidth\eq@tmplengthA{\@examNameLabel\ }%
\@tempdima=#2 \advance\@tempdima by-\eq@tmplengthA
\underbar{\makebox[#2][l]{\@examNameLabel}}%
\insTxtFieldIdInfo[#1]{\@tempdima}{IdInfo.Name}%
\egroup}%
}
% \end{macrocode}
% Here we set the field to be a required field with width of $2.25$ inches
% \begin{macrocode}
\eqExamName[\Ff\FfRequired]{2.25in}
% \end{macrocode}
% \DescribeMacro{\eqSID} provides a line for the student to enter his/her ID number (SID).
%
% Will insert a text box as well if the \texttt{option} is taken in addition
% to \texttt{nosolutions} and with \texttt{solutionsafter} not taken.
% The first (optional) parameter is passed to \cs{insTxtFieldIdInfo}, and can be
% used to change the appearance of the text field created; the second required parameter
% is the width of the field.
% \begin{macrocode}
\newcommand\examSIDLabel[1]{\gdef\@examSIDLabel{#1}}
\examSIDLabel{SID:}
\newcommand\eqSID[2][]{\gdef\eq@SID{%
\bgroup\settowidth\eq@tmplengthA{\@examSIDLabel\ }%
\@tempdima=#2 \advance\@tempdima by-\eq@tmplengthA
\underbar{\makebox[#2][l]{\@examSIDLabel}}%
\insTxtFieldIdInfo[#1]{\@tempdima}{IdInfo.SID}%
\egroup}%
}
% \end{macrocode}
% Here we set the field to be a required field with width of $2.25$ inches
% \begin{macrocode}
\eqSID[\Ff\FfRequired]{2.25in}
% \end{macrocode}
% \DescribeMacro{\eqEmail} provides a line for the student
% to enter his/her email address. Useful for documents submitted by email, the
% instructor can reply.
%
% Will insert a text box as well if the \texttt{option} is taken in addition
% to \texttt{nosolutions} and with \texttt{solutionsafter} not taken.
% The first (optional) parameter is passed to \cs{insTxtFieldIdInfo}, and can be
% used to change the appearance of the text field created; the second required parameter
% is the width of the field.
% \begin{macrocode}
\newcommand\examEmailLabel[1]{\gdef\@examEmailLabel{#1}}
\examEmailLabel{Email:}
\newcommand\eqEmail[2][]{\gdef\eq@Email{%
\bgroup\settowidth\eq@tmplengthA{\@examEmailLabel\ }%
\@tempdima=#2 \advance\@tempdima by-\eq@tmplengthA
\underbar{\makebox[#2][l]{\@examEmailLabel}}%
\insTxtFieldIdInfo[#1]{\@tempdima}{IdInfo.email}%
\egroup}%
}
% \end{macrocode}
% Here we set the field to be a field with width of $2.25$ inches. (Not set to be a required field.)
% \begin{macrocode}
\eqEmail{2.25in}
% \end{macrocode}
% \DescribeMacro{\insTxtFieldIdInfo} The above macros (\cs{eqExamName}, \cs{eqSID} and \cs{eqEmail})
% all call this macro, which inserts a Acroforms text field if the \texttt{option} is taken in addition
% to \texttt{nosolutions} and with \texttt{solutionsafter} not taken.
%
% The first (optional) parameter is used to change the appearance of the text field.
% The second parameter is the width of the field, and the third is the field name.
% \begin{macrocode}
\def\insTxtFieldIdInfo[#1]#2#3{%
\@ifundefined{@quiz}{}{\ifx\eq@online y\relax
\ifeq@nosolutions\ifeq@solutionsafter\else
\makebox[0pt][r]{\textField[\BC{}#1]{#3}{#2}{11bp}}%
\fi\fi\fi
}%
}
% \end{macrocode}
% \DescribeMacro{\SubmitInfo} is required when the \texttt{email} option is taken,
% and should appear in the preamble. The first argument is the URL to the \textsf{eqAttach.asp}
% code on the server, and the second is the email of the instructor is to receive the results.
% (Multiple recipients can be specified by separating each with a comma.)
% \begin{macrocode}
\def\SubmitInfo#1#2{%
\def\EqExam@SubmitURL{#1}\def\@EmailInstr{#2}%
}
% \end{macrocode}
% \DescribeMacro{\EmailCourseName} is used to specify the course name of the course. The default
% value for this is \cs{websubject}, obtained from the \cs{subject} macro used in the preamble; however,
% if you want a different name in the email, perhaps with more information included, you can redefine
% the value using this macro.
% \begin{macrocode}
\def\EmailCourseName#1{\def\@EmailCourseName{#1}}
% \end{macrocode}
% Here's the default value.
% \begin{macrocode}
\EmailCourseName{\websubject}
% \end{macrocode}
% \DescribeMacro{\EmailExamName} is used to specify the exam name of the course. The default
% value for this is \cs{webtitle}, obtained from the \cs{title} macro used in the preamble; however,
% if you want a different name in the email, perhaps with more information included, you can redefine
% the value using this macro.
% (Multiple recipients can be specified by separating each with a comma.)
% \begin{macrocode}
\def\EmailExamName#1{\def\@EmailExamName{#1}}
% \end{macrocode}
% Here's the default value.
% \begin{macrocode}
\EmailExamName{\webtitle}
% \end{macrocode}
% \DescribeMacro{\EmailSubject} The document author mail want a custom subject in the email, instead
% of the standard one. By using this macro, he can design his own email subject.
% \begin{macrocode}
\def\EmailSubject#1{\def\@EmailSubject{#1}}
% \end{macrocode}
% Here's the default value, which generates no custom subject line.
% \begin{macrocode}
\EmailSubject{}
% \end{macrocode}
% In this case \textsf{eqAttach.asp} inserts the standard one.
%\begin{verbatim}
%Exam Results: \webtitle of \websubject
%\end{verbatim}
% The email would read like ``\texttt{Exam Results:~Test 1 of Calculus I}'', for example.
%
% \DescribeMacro{\ServerRetnMsg} Unless submitted in \texttt{silent} mode, the \textsf{eqAttach.asp}
% returns a message acknowledging the receipt of the data. \cs{ServerRetnMsg} is used to customize
% this message.
% \begin{macrocode}
\def\ServerRetnMsg#1{\def\@ServerRetnMsg{#1}}
% \end{macrocode}
% Here's the default value, which generates no custom return message
% \begin{macrocode}
\ServerRetnMsg{}
% \end{macrocode}
% \noindent\DescribeMacro{\SubmitButtonLabel} is the label that appears on the submit button.
% \begin{macrocode}
\def\SubmitButtonLabel#1{\def\@SubmitButtonLabel{#1}}
% \end{macrocode}
% Here's the default value.
% \begin{macrocode}
\SubmitButtonLabel{Submit}
% \end{macrocode}
% \DescribeMacro{\SubmitButton} is the macro that provides the submit button
% when the \texttt{email} option is taken. It appears automatically at the top of
% the first page of the exam, and appears only if \texttt{nosolutions} has has been
% taken, and \texttt{solutionsafter} has not been taken.
% \begin{macrocode}
\let\priorSubmitJS\@gobble
\let\postSubmitJS\@empty
\def\SubmitButton
{%
\ifx\use@email y\ifeq@nosolutions\ifeq@solutionsafter\else
\makebox[0pt][l]{\pushButton
[\CA{\@SubmitButtonLabel}\A{\JS{%
var _eqEok2Submit = true;\r
var aSubmitFields = new Array("eqexam", "IdInfo");\r
\priorSubmitJS\r
if(_eqEok2Submit) this.submitForm("\EqExam@SubmitURL",
true, false, aSubmitFields);\r
\postSubmitJS
}}]{Submit}{1.5in}{16bp}}%
\makebox[0pt][l]{\textField[\F\FHidden\DV{\@EmailInstr}
\V{\@EmailInstr}]{IdInfo.mailTo}{11bp}{11bp}}%
\makebox[0pt][l]{\textField[\F\FHidden\DV{\@EmailCourseName}
\V{\@EmailCourseName}]{IdInfo.courseName}{11bp}{11bp}}%
\makebox[0pt][l]{\textField[\F\FHidden\DV{\@EmailExamName}
\V{\@EmailExamName}]{IdInfo.examName}{11bp}{11bp}}%
\makebox[0pt][l]{\textField[\F\FHidden\DV{\@EmailSubject}
\V{\@EmailSubject}]{IdInfo.subject}{11bp}{11bp}}%
\makebox[0pt][l]{\textField[\F\FHidden\DV{\@ServerRetnMsg}
\V{\@ServerRetnMsg}]{IdInfo.retnmsg}{11bp}{11bp}}%
\fi\fi\fi
}
% \end{macrocode}
% \begin{macrocode}
\def\thequizno{\if\probstar*\Alph{quizno}\else\alph{quizno}\fi}%
\def\linkContentFormat{%
\if\probstar*\Alph{quizno}\else\alph{quizno}\fi}
\def\linkContentWrapper{(\hfil\linkContentFormat\hfil)}%
\def\Ans@r@l@Defaults
{%
\BC{}\S{S}\W{1}\Ff{\FfNoToggleToOff}
\textSize{12}\textColor{0 g}
}
\def\eqExam@Ans@sq@l{%
\leavevmode\stepcounter{quizno}\PBS\raggedright
\settowidth{\eq@tmplength}{\eq@lw@l}\sbox{\eq@tmpbox}{\eq@l@l}%
\eq@tmpdima=\wd\eq@tmpbox
\def\link@@Content{\linkContentWrapper}%
\hangindent=\eq@tmplength\hangafter=1\relax
\edef\fieldName{%
\if\probstar*eqexam.\curr@quiz.\theeqquestionnoi.part\thepartno
\else
eqexam.\curr@quiz.\theeqquestionnoi
\fi
}%
\ifx\eq@online y\relax
\makebox[0pt][l]{\radio@@Button{}{\fieldName}%
{\eq@tmpdima}{\RadioFieldSize}{\Ans@choice\alph{quizno}}%
{\eq@protect\A}{\eq@setWidgetProps\eq@l@check@driver}%
{\Ans@r@l@Defaults\every@RadioButton\every@qRadioButton}}%
\else
\edef\@linkcolor{\@nolinkcolor}%
\fi
\ifeq@nosolutions\edef\@linkcolor{\@nolinkcolor}\fi
\textcolor{\@linkcolor}{\makebox[\eq@tmpdima]{\link@@Content}}%
\Ans@proofing{\eq@tmpdima}%
}
\def\eqExam@Ans@sq@f{%
\stepcounter{quizno}\PBS\raggedright
\settowidth{\eq@tmplength}{\eq@lw@f}%
\eq@tmpdima=\wd\eq@tmpbox%
\hangindent=\eq@tmplength\hangafter=1\relax
\ifx\eq@online n\previewtrue
\Ans@sq@f@driver
\else
\edef\fieldName{%
\if\probstar*eqexam.\curr@quiz.\theeqquestionnoi.%
part\thepartno
\else
eqexam.\curr@quiz.\theeqquestionnoi
\fi
}\insertGrayLetters
\radio@@Button{}{\fieldName}{\RadioFieldSize}%
{\RadioFieldSize}{\Ans@choice\alph{quizno}}{\eq@protect\A}%
{\eq@setWidgetProps\eq@RadioCheck@driver}%
{\@@Ans@sq@f@Defaults\Ans@sq@f@Actions\every@RadioButton
\every@sqRadioButton}%
\fi
\Ans@proofing{\RadioFieldSize}%
}
\def\eqExam@Ans@ck@sq@l{%
\leavevmode\stepcounter{quizno}\PBS\raggedright
\settowidth{\eq@tmplength}{\eq@lw@l}\sbox{\eq@tmpbox}{\eq@l@l}%
\eq@tmpdima=\wd\eq@tmpbox
\def\link@@Content{\linkContentWrapper}%
\hangindent=\eq@tmplength\hangafter=1\relax
\edef\fieldName{%
\if\probstar*eqexam.\curr@quiz.\theeqquestionnoi.%
part\thepartno.\alph{quizno}
\else
eqexam.\curr@quiz.\theeqquestionnoi.\alph{quizno}
\fi
}%
\ifx\eq@online y\relax
\makebox[0pt][l]{\check@@Box{}{\fieldName}%
{\eq@tmpdima}{\RadioFieldSize}{\Ans@choice\alph{quizno}}%
{\eq@protect\A}{\eq@setWidgetProps\eq@l@check@driver}%
{\Ans@r@l@Defaults\every@RadioButton\every@qRadioButton}}%
\else
\edef\@linkcolor{\@nolinkcolor}%
\fi
\ifeq@nosolutions\def\@linkcolor{\@nolinkcolor}\fi
\textcolor{\@linkcolor}{\makebox[\eq@tmpdima]{\link@@Content}}%
\Ans@proofing{\eq@tmpdima}%
}
\def\eqExam@Ans@ck@sq@f{%
\stepcounter{quizno}\PBS\raggedright
\settowidth{\eq@tmplength}{\eq@lw@f}%
\eq@tmpdima=\wd\eq@tmpbox%
\hangindent=\eq@tmplength\hangafter=1\relax
\ifx\eq@online n\previewtrue
\Ans@sq@f@driver
\else
\edef\fieldName{%
\if\probstar*eqexam.\curr@quiz.\theeqquestionnoi.%
part\thepartno.\alph{quizno}
\else
eqexam.\curr@quiz.\theeqquestionnoi.\alph{quizno}
\fi
}%
\check@@Box{}{\fieldName}{\RadioFieldSize}%
{\RadioFieldSize}{\Ans@choice\alph{quizno}}{\eq@protect\A}%
{\eq@setWidgetProps\eq@RadioCheck@driver}%
{\@@Ans@sq@f@Defaults\Ans@sq@f@Actions\every@RadioButton
\every@sqRadioButton}%
\fi
\Ans@proofing{\RadioFieldSize}%
}
\def\eqExamPriorVspace#1{%
\edef\fieldName{%
\if\probstar*eqexam.\curr@quiz.%
\theeqquestionnoi.part\thepartno.solution
\else
eqexam.\curr@quiz.\theeqquestionnoi.solution
\fi
}%
\nobreak\textField[\Ff\FfMultiline\BC{}]
{\fieldName}{\linewidth}{#1}%
\@gobble
}
% \end{macrocode}
%
% Test to see if \texttt{exerquiz} is loaded. If not, we input
% the `stand alone', \texttt{eqalone.def}, followed by \texttt{eqexam.def}. The latter
% definition file is maintained in \texttt{exerquiz.dtx} under the \texttt{eqexam} option.
%
% \begin{macrocode}
\@ifpackageloaded{exerquiz}{%
\let\Ans@sq@l\eqExam@Ans@sq@l
\let\Ans@sq@f\eqExam@Ans@sq@f
\let\Ans@ck@sq@l\eqExam@Ans@ck@sq@l
\let\Ans@ck@sq@f\eqExam@Ans@ck@sq@f
\def\eqexheader@wrapper{\makebox[0pt][r]{%
\hypertarget{qex.\the@exno}{\eqexheader}}}
\ifx\eq@online y\relax
\newcounter{@cntfillin}
\let\eqPriorVspace\eqExamPriorVspace
\fi
}%
{%
\input{eqalone.def}
\input{eqexam.def}
\def\eqexheader@wrapper{\makebox[0pt][r]{\eqexheader}}
}
% \end{macrocode}
% We wrote \verb!\begin{eqequestions}! to the top of the solutions file (\cs{jobname.sol}.
% \begin{macrocode}
%\writeBeginEqeQuestions
% \end{macrocode}
% If the \texttt{vspacewithsolns} is in effect, we write solutions to the end of the document.
% \begin{macrocode}
\ifvspacewithsolns\writeAllAnsAtEnd\else
\ifeqfortextbook\writeAllAnsAtEnd\fi\fi
% \end{macrocode}
% We execute \cs{vspacewithkeyOff}, which sets \cs{ifkeepdeclaredvspacing} to false,
% the default behavior of \textsf{eqexam} before the new feature.
% \begin{macrocode}
\vspacewithkeyOff
% \end{macrocode}
% \begin{macrocode}
%
% \end{macrocode}
% \section{Stand alone Code}
%
% \begin{macrocode}
%<*standalone>
% \end{macrocode}
% Now we begin the listing of the stand alone code. This code is necessary if
% \texttt{exerquiz} has not been loaded.
%
% Many of the following definitions are given in \texttt{eqforms}, which was recently separated
% from \texttt{exerquiz} and is now maintained as a separate package.
% \begin{macrocode}
\@ifundefined{eq@tmpbox}{\newsavebox{\eq@tmpbox}}{}% defined in eforms
\@ifundefined{eq@tmpdima}{\newdimen\eq@tmpdima}{} % defined in eforms
\def\RadioFieldSize{11bp}
% \end{macrocode}
% \begin{macrocode}
\newdimen\eqcenterWidget
% \end{macrocode}
% This macro is used to vertically center the response box on the line. Seems to
% work well.
% \begin{macrocode}
\def\centerWidget
#1{%
\eqcenterWidget=#1
\eqcenterWidget=.5\eqcenterWidget
\advance\eqcenterWidget by -4bp
}
% \end{macrocode}
% When the \texttt{preview} option has been used, draw a frame box
% around the bounding rectangle.
% \begin{macrocode}
\def\Bbox#1#2{\vbox{\hrule width #1
\hbox to#1{\vrule height#2\hfill\vrule height#2}\vfill\hrule}}
% \end{macrocode}
% \begin{macrocode}
\def\Rect#1{\textcolor{\@linkcolor}{#1}}
\def\ReturnTo#1#2{\eq@fititin{#2}}
%\def\AllowFitItIn{\global\let\eq@fititin\eqfititin}
%\def\DoNotFitItIn{\global\let\eq@fititin\@gobble}
\newcommand{\proofingsymbol}[1]{%
\def\@proofingsymbol{\textcolor{\@proofingsymbolColor}{#1}}}
\proofingsymbol{$\bullet$}
% \end{macrocode}
% This is the answers macro for the link-style and is called from the \texttt{eqexam.def} file.
% \begin{macrocode}
%
% \end{macrocode}
% \begin{macrocode}
%<*package>
% \end{macrocode}
% \section{The Main Code}
% We now continue with the main package. Mostly, we define macros specific to the
% \texttt{eqexam} package: define the \texttt{problem} and \texttt{problem*} environments,
% macros for calculating totals per page, etc.
%
% \begin{macrocode}
\def\Ans@sq@l@driver{%
\Rect{\makebox[\eq@tmpdima]{\linkContentWrapper}}%
\Ans@proofing{\eq@tmpdima}%
}
% \end{macrocode}
% This is the answers macro for the form-style and is called from the \texttt{eqexam.def} file.
% \begin{macrocode}
\def\Ans@sq@f@driver{%
\centerWidget\RadioFieldSize
\leavevmode\lower\eqcenterWidget\Bbox
{\RadioFieldSize}{\RadioFieldSize}%
\Ans@proofing{\RadioFieldSize}%
}
% \end{macrocode}
% Write quiz solutions to the exercise solutions file
% \begin{macrocode}
\def\eq@sqsllabel{\string\textbf{Solution to Quiz:}}
\def\sqsllabel{\eq@sqsllabel}
% \end{macrocode}
% \begin{macro}{\writeToSolnFile}
% General purpose command for writing to the solution file.
% \begin{macro}{\preExamSolnHead}
% Executed just before a user friendly name
% \begin{macro}{\examSolnHeadFmt}
% Format for the user friendly name
% \begin{macro}{\postExamSolnHead}
% Executed just after a user friendly name
% \begin{macrocode}
\let\quiz@solns\ex@solns
\newcommand{\preExamSolnHead}{\goodbreak\noindent}
\newcommand{\examSolnHeadFmt}[1]{\textbf{#1}}
\newcommand{\postExamSolnHead}{\par\medskip}
\newcommand{\writeToSolnFile}[1]{%
\set@display@protect
\immediate\write\quiz@solns{#1}%
\set@typeset@protect
}
% \end{macrocode}
% We will write all solutions to the \texttt{.sol} auxiliary file.
% \begin{macrocode}
\def\eqe@writetoSolns#1{%
\set@display@protect
\immediate\write\quiz@solns{\string\preExamSolnHead
\string\examSolnHeadFmt{#1}\string\postExamSolnHead}%
\set@typeset@protect
}
\def\eqe@writetoAux#1{%
\set@display@protect
\immediate\write\@auxout{#1}%
\set@typeset@protect
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% Turn off interactivity of short quiz.
\def\Ans@sq@l@Actions{}
\def\Ans@sq@f@Actions{}
% \begin{macrocode}
% \end{macrocode}
% This macro is defined in \texttt{exerquiz}, but has a little different definition for \texttt{eqexam}.
% \begin{macrocode}
\def\Ans@proofing
#1{%
\ifeq@proofing\if\Ans@choice1\relax
\llap{\rlap{\,\@proofingsymbol}\hskip#1\relax}%
\fi\fi
}
% \end{macrocode}
% This macro gets the page number of the last page of the exam. It is read in through
% a macro definition made and written to the \texttt{.aux} file.
% \begin{macrocode}
\def\eq@ExamLastPage{\csname eqExamLastPage\endcsname}
\newcommand{\nPagesOnExam}{\csname eqExamLastPage\endcsname}
% \end{macrocode}
% \begin{macro}{\lastPageOfExam}
%\changes{v2.0l}{2011/05/05}{%
% Returns the page number of the end of the exam with a given name.
%}
% Returns the page number of the end of the exam with a name of \texttt{\#1}.
% \begin{macro}{\firstPageOfExam}
%\changes{v2.0l}{2011/05/05}{%
% Returns the page number of the beginning of the exam with a given name.
%}
% Returns the page number of the beginning of the exam with a name of \texttt{\#1}.
% \begin{macrocode}
\newcommand{\lastPageOfExam}[1]{\pageref{#1PageEnd}}
\newcommand{\firstPageOfExam}[1]{\pageref{#1PageBegin}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \subsection{Running Heads, \texorpdfstring{\protect\cs{maketitle}}{\textbackslash{maketitle}} and Cover Pages}
% We develop a series of macros for creating a running header for the exam, and a cover page, if
% desired.
%
% \begin{macro}{\lheadeqe}
% \begin{macro}{\cheadeqe}
% \begin{macro}{\cheadeqe}
%\changes{2.0a}{2010/05/06}{
% Changed the definitions of \cs{lhead}, \cs{chead}, and \cs{rhead} so they don't clash
% with the \textsf{fancyhdr} package. If \textsf{fancyhdr} is not loaded at the time \textsf{eqexam} is loaded, we
% \cs{let} the old names to the new names. Therefore, when \textsf{fancyhdr} is loaded first use
% the new definitions.
%}
% Set the left, center, and right running headers.
% \begin{macrocode}
\newcommand{\lheadeqe}[1]{\def\eq@lhead{#1}}
\lheadeqe{\shortwebsubject/\shortwebtitle}
\newcommand{\cheadeqe}[1]{\def\eq@chead{#1}}
\cheadeqe{-- Page \arabic{page}\space of \eq@ExamLastPage\space--}
\newcommand{\rheadeqe}[1]{\def\eq@rhead{#1}}
\rheadeqe{\eq@ExamName}
% \end{macrocode}
% \begin{macro}{\lhead}
% \begin{macro}{\chead}
% \begin{macro}{\rhead}
% These are the original names for the headers, we'll keep them if
% \textsf{fancyhdr} is not already loaded to maintain compatibility
% with previous versions of \textsf{eqexam}.
% \begin{macrocode}
\@ifpackageloaded{fancyhdr}{}{%
\let\lhead\lheadeqe
\let\chead\cheadeqe
\let\rhead\rheadeqe
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\eqExamRunHead}
% \begin{macro}{\eqExamRunHead}
% The running header of the exam, may be redefined.
% \begin{macrocode}
\newcommand{\runExamHeader}{\eq@lhead\hfill\eq@chead\hfill\eq@rhead}
\newcommand\eqExamRunHead{%
\addtolength\textwidth{\oddsidemargin}%
\noindent\hspace*{-\oddsidemargin}\makebox[\textwidth]
{\runExamHeader}%
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\lheadSol}
% \begin{macro}{\cheadSol}
% \begin{macro}{\rheadSol}
% \begin{macro}{\eqsolutionshook}
% The running header of the exam, when solutions are included at the end of the document, perhaps
% for posting the solutions to the exam, or publication of a ``pretest''. Note that \cs{eqsolutionshook}
% is defined in \texttt{exerquiz/eqexam.def}. May be redefined.
% \begin{macrocode}
\newcommand{\lheadSol}[1]{\def\eq@lheadSol{#1}}
\lheadSol{\shortwebsubject/\shortwebtitle}
\newcommand{\cheadSol}[1]{\def\eq@cheadSol{#1}}
\cheadSol{-- Page \arabic{page}\space of \eq@ExamLastPage\space--}
\newcommand{\rheadSol}[1]{\def\eq@rheadSol{#1}}
\rheadSol{SOLUTIONS}
\newcommand{\runExamHeaderSol}
{\eq@lheadSol\hfill\eq@cheadSol\hfill\eq@rheadSol}
\def\eqsolutionshook
{%
\gdef\eqExamRunHead{\addtolength\textwidth{\oddsidemargin}%
\noindent\hspace*{-\oddsidemargin}\makebox[\textwidth]
{\runExamHeaderSol}}%
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\maketitle}
% \begin{macro}{\maketitledesign}
% \begin{macro}{\altTitle}
% Standard {\LaTeX} macro, but this time it is used to create the header at the top of the first
% page of the exam. Typically, consisting of two rows of info. (1) first row has course name, exam name, and
% a place for the student to put his/her name. (2) second row has date and instructor. May be redefined.
%
% Modify the title by redefining \cs{maketitledesign}, the \cs{maketitle} command
% itself has {\LaTeX} commands in it that should not be changed.
% \changes{v1.6i}{2007/09/18}
%{
% Added the command \cs{altTitle} as an alternate title for the exam
% document. This alternate title appear centered under the title
% of the document.
%}
% \begin{macrocode}
\newcommand\maketitledesign
{%
\makebox[\textwidth]{\normalsize
\shortstack[l]{\strut\websubject\\\@date}\hfill
\shortstack[c]{\webtitle\\\strut\@altTitle}\hfill
\shortstack[l]{\strut\eq@ExamName\\\webauthor}}%
}
\def\altTitle#1{\def\@altTitle{#1}}
\let\@altTitle\@empty
\def\eqemaketitle
{%
\begingroup
\addtolength\textwidth{\oddsidemargin}%
\noindent\hspace*{-\oddsidemargin}%
\raisebox{.7in}[0pt][0pt]{\SubmitButton}%
\maketitledesign
\endgroup
% \end{macrocode}
% \cs{EQEcalculateAllTotals}: We don't actually calculate all totals, just some of them. We do calculate the grade total
% of all the \texttt{exam} environments in the document, we also calculate the percentage
% that each exam contributes to to the total. If \cs{maketitle} is not used, for whatever reason,
% this command should be calculated explicitly just after |\begin{document}|.
% \begin{macrocode}
\EQEcalculateAllTotals
}
% \end{macrocode}
% If the fortextbook option is not taken, we set up the usual \cs{maketitle} definition.
% \begin{macrocode}
\ifeqfortextbook\else\let\maketitle\eqemaketitle\fi
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\eqexcoverpage}
% The \texttt{eqexam} package allows for the possibility of a cover page, if the \texttt{coverpage}
% option is taken.
% \begin{macro}{\placeCoverPageLogo}
% A simple command to insert a logo on the cover page. The logo can be used to cover the
% score in the next page, if the instructor places the score under the logo. Example of usage
%\begin{verbatim}
% \placeCoverPageLogo{5in}{-1.5in}{\includegraphics{nwfsc_logo}}
%\end{verbatim}
% Working from the upper left corner, the first parameter is the amount to move to logo
% to the right, the second parameter is the amount to move the logo vertically. The
% Third parameter is the content; perhaps an \cs{includegraphics} command.
%\changes{v1.9b}{2009/09/29}{Added \cs{placeCoverPageLogo} to insert a logo on the cover page.}
% \begin{macrocode}
\newcommand\placeCoverPageLogo[3]{%
\def\eqe@insertLogo{\hbox to0pt{%
\hspace*{#1}\smash{\raisebox{#2}{#3}}\hss}}}
\let\eqe@insertLogo\relax
% \end{macrocode}
% Define \cs{eqexcoverpage}, this command places \cs{eqe@insertLogo} and
% \cs{eqex\-cover\-page\-design} in a group. It is this command that gets executed when
% the user calls for the \texttt{coverpage} option.
% \begin{macrocode}
\def\eqexcoverpage{%
\begingroup
\pagenumbering{roman}
\eqe@insertLogo
\eqexcoverpagedesign
\endgroup\newpage
\pagenumbering{arabic}
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\eqexcoverpagedesign}
% The \texttt{eqexam} package allows for the possibility of a cover page, if the \texttt{coverpage}
% option is taken. This macro can and should be redefined to fit your needs. The definition below
% is just a representative example.
% \begin{macro}{\coverpagesubject}
% \begin{macro}{\coverpageUniversityFmt}
% \begin{macro}{\coverpageSubjectFmt}
% \begin{macro}{\coverpageTitleFmt}
% The following four commands are used with the cover page.
% The \cs{cover\-page\-sub\-ject} is used to provide a special subject
% for the cover page, different from \cs{websubject}. The others
% are used for formatting.
%\changes{v1.9a}{2009/28/09}{Added these various Fmt commands for coverpage.}
% \begin{macrocode}
\newcommand{\coverpagesubject}[1]{\def\coverpage@subject{#1}}
\let\coverpage@subject\@empty
\def\eqexamsubject{\ifx\coverpage@subject\@empty\websubject
\else\coverpage@subject\fi}
\newcommand{\coverpageUniversityFmt}[1]{%
\def\eqex@coverpageUniversityFmt{#1}}
\coverpageUniversityFmt{\bfseries\large}
\newcommand{\coverpageSubjectFmt}[1]{%
\def\eqex@coverpageSubjectFmt{#1}}
\coverpageSubjectFmt{\bfseries\large}
\newcommand{\coverpageTitleFmt}[1]{%
\def\eqex@coverpageTitleFmt{#1}}
\coverpageTitleFmt{\bfseries\large}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% Now we present the definition of \cs{eqexcoverpagedesign}.
% \begin{macrocode}
\def\eqeSumryVert{\def\eqe@SumryVert{\par\vfill}\let\eqe@SumryHoriz\relax
\def\eqe@@SumryVert{\vspace{\stretch{-1}}\bigskip}}
\def\eqeSumryHoriz{\def\eqe@SumryHoriz{\hfill}\let\eqe@SumryVert\relax
\let\eqe@@SumryVert\relax}
\eqeSumryHoriz
\newcommand{\useUIPartNames}{\let\useUIP@rtN@mes1}
\let\useUIP@rtN@mes0
\newcommand{\eqexcoverpagedesign}
{%
\thispagestyle{empty}
\addtolength\textwidth{\oddsidemargin}
\vspace*{.1\textheight}
\noindent\hspace*{-\oddsidemargin}%
\makebox[\linewidth]{\parbox{\linewidth}%
{\eqex@coverpageUniversityFmt
\color{\webuniversity@color}%
\centering\webuniversity}}
\par\vspace{.1\textheight}
\noindent\hspace*{-\oddsidemargin}%
\makebox[\linewidth]{\parbox{\linewidth}%
{\eqex@coverpageSubjectFmt
\color{\websubject@color}%
\centering\eqexamsubject}}
\par\vspace{\bigskipamount}
\noindent\hspace*{-\oddsidemargin}%
\makebox[\linewidth]{\parbox{\linewidth}%
{\eqex@coverpageTitleFmt
\color{\webtitle@color}%
\centering\webtitle}}
\par\vspace{\stretch{1}}
\optionalpagematter
\par\vspace{\stretch{1}}\parbox[b]{.45\linewidth}{\parindent0pt
\eq@ExamName\\[2ex]\eq@SID\\[2ex]
\ifx\use@email y\eq@Email\\[2ex]\fi
\textcolor{\webauthor@color}{\webauthor}, \@date}%
\eqe@SumryHoriz\eqe@SumryVert
\sumryAnnots
}
\newcommand{\cpSumryHeader}{\textbf{Exam Record}}
\newcommand{\cpSumryPts}{\,\text{pts}}
\newcommand{\cpSumryPage}{Page}
\newcommand{\cpSumryTotal}{Total:}
\newcommand{\cpSumryGrade}{Grade:}
\newcommand{\cpSetSumryWidth}[1]{\def\cp@SetSumryWidth{#1}}
\cpSetSumryWidth{.5\linewidth}
\newcommand{\cpUsefbox}{\let\cp@Usefbox\fbox}
\cpUsefbox
\newcommand{\cpNofbox}{\let\cp@Usefbox\mbox}
\newcommand{\cpSumrybyparts}{%
\eqe@@SumryVert\cp@Usefbox{%
\begin{minipage}[b]{\cp@SetSumryWidth}\kern0pt
\begin{flushleft}
\expandafter\ifx\csname NumberOfParts\endcsname\relax
\else
\count2 = 0
\medskip
\cpSumryHeader\par\parskip\bigskipamount
\def\\##1{\advance\count2by\csname ##1total\endcsname
\underbar{\makebox[0pt][l]{\if\useUIP@rtN@mes0##1\else
\@nameuse{userFriendly##1}\fi}\hspace*{1.5in}}%
/ $\csname ##1total\endcsname\cpSumryPts$\par}
\thePartNames
\fi
\underbar{\makebox[0pt][l]{\cpSumryTotal}\hspace{1.5in}}/
$\the\count2\relax\cpSumryPts$ \par
\underbar{\makebox[0pt][l]{\cpSumryGrade}\hspace{1.5in}}%
\ifx\cp@Usefbox\fbox\medskip\fi
\end{flushleft}\kern0pt
\end{minipage}}\par
}
\newcommand{\cpSumrybypages}{%
\eqe@@SumryVert\cp@Usefbox{%
\begin{minipage}[b]{\cp@SetSumryWidth}
\begin{flushleft}
\expandafter\ifx\csname NumberOfParts\endcsname\relax
\else
\medskip
\count0= 0\relax\count2=0\relax
\textbf{Exam Record}\par\parskip\bigskipamount
\@whilenum\count0<\csname eqExamLastPage\endcsname\do{%
\advance\count0by1\relax
\count4=\@nameuse{Page\the\count0total}\relax
\expandafter\ifx\csname Page\the\count0spilltotal\endcsname\relax
\else\advance\count4by\csname Page\the\count0spilltotal\endcsname\relax\fi
\advance\count2by\count4\relax
\underbar{\makebox[0pt][l]{\cpSumryPage~\the\count0}\hspace*{1.5in}}%
/ $\the\count4\relax\cpSumryPts$%
\expandafter\ifx\csname Page\the\count0spilltotal\endcsname\relax
\else\ $(\@nameuse{Page\the\count0spilltotal}\cpSumryPts
+\@nameuse{Page\the\count0total}\cpSumryPts)$\fi\par
}
\fi
\underbar{\makebox[0pt][l]{\cpSumryTotal}\hspace{1.5in}}/
$\the\count2\relax\cpSumryPts$\par
\underbar{\makebox[0pt][l]{\cpSumryGrade}\hspace{1.5in}}%
\ifx\cp@Usefbox\fbox\medskip\fi
\end{flushleft}
\end{minipage}}\par
}
% \end{macrocode}
% \end{macro}
% If the author takes the \texttt{coverpage} option, \cs{eqex@coverpage} is set equal
% to \cs{eqexcoverpagedesign}, otherwise, it is set equal to \cs{relax}.
% \begin{macrocode}
\AtBeginDocument{\eqex@coverpage}
% \end{macrocode}
% \subsection{Insert Points in Margins and Compute Page Totals}
% Here we attempt to place point values of a problem in the margins and
% to compute the page totals.
%
%\begin{macro}{\probvalue}
% This is a fundamental macro for keeping track of the points of the problem.
% It increments the counter \texttt{eqpointvalue}, which keeps a running total
% of the points of the current part of the exam, puts the value in the margins,
% and sets a \texttt{mark}, so that at the end of the page, we can compute the
% number of points on the current page. This macro is used in several situations,
% for example, in the \texttt{problem} environment, \cs{manualcalcparts} and in
% \cs{autocaleparts}. \textbf{Should not be redefined}.
%\begin{flushleft}
%Parameters
%\begin{verbatim}
%#1 = total points for this problem
%#2 = 0 if total points, otherwise, #2 is the number of points each
% problem.
%\end{verbatim}
%\end{flushleft}
% \begin{macrocode}
\def\@marktotalvalue{%
\mark{\theeqpointvalue\csname eqExam\endcsname\theeq@numparts}%
% \typeout{\string\mark{%
% \theeqpointvalue\string\eqExam\theeq@numparts}}%
}
\def\probvalue#1#2{%
\addtocounter{eqpointvalue}{#1}%
\marginpoints{#1}{#2}\@marktotalvalue
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\eqleftmarginbox}
% This macro places the problem value in the left margin, can be redefined, if you dare.
%\begin{flushleft}
% Parameters
%\begin{verbatim}
%#1 = total points for this problem
%#2 = 0 if total points, otherwise, #2 is the number of points each
% problem.
%\end{verbatim}
%\end{flushleft}
% Currently, this macro is not used.
% \begin{macrocode}
\def\eqleftmarginbox#1#2{\makebox[0pt][r]{%
\setlength\tabcolsep{0pt}%
\raisebox{-.5\height}[0pt][0pt]{\parbox{\widthtpboxes}{%
\tabcolsep=0pt\relax
\begin{tabular}{|c|}\hline
\vrule height15pt width0pt\\\hline
\makebox[\widthtpboxes]{%
\marginpointsboxtext{#1}{#2}}\\\hline
\end{tabular}%
}}\hspace*{\marginparsep}\hspace*{\eqemargin}}%
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\ptsLabel}
% \begin{macro}{\eachLabel}
% \begin{macro}{\pointsLabel}
% The following three convenience commands can be used to localize some of
% the strings to other languages.
% \begin{macrocode}
\providecommand{\ptsLabel}[1]{\def\eqptsLabel{#1}}\ptsLabel{pts}
\providecommand{\ptLabel}[1]{\def\eqptLabel{#1}}\ptLabel{pt}
\newcommand{\eachLabel}[1]{\def\eq@eachLabel{#1}}\eachLabel{ea.}
\newcommand{\pointsLabel}[1]{%
\def\eq@pointsLabel{#1}}\pointsLabel{points}
\newcommand{\pointLabel}[1]{%
\def\eq@pointLabel{#1}}\pointLabel{point}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\marginpointtext}
% Creates the text for \cs{eqleftmargin} to use. Use can see from the macro,
% if \texttt{\#2} is 0, then we write the points for the problem, else, we write
% the points each for the problem.
% \begin{macrocode}
\newcommand\leftmarginPtsTxt[1]{(\small$#1^{\text{%
\ifnum#1=1\relax\eqptLabel\else\eqptsLabel\fi}}$)}
\newcommand\leftmarginPtsEaTxt[1]{(\small$#1_{\text{%
\eq@eachLabel}}^{\text{\ifnum#1=1\relax\eqptLabel\else
\eqptsLabel\fi}}$)}
\def\marginpointtext#1#2{\ifnum#2=0\leftmarginPtsTxt{#1}\else
\leftmarginPtsEaTxt{#2}\fi
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\eqleftmargin}
% Places the number of points (or points each) in the left margin. Can be redefined as
% desired. This macro is used when author chooses the \texttt{pointsonleft}
% or \texttt{pointsonbothsides} option.
% \begin{macrocode}
\def\eqleftmargin#1#2{\makebox[0pt][r]{\marginpointtext{#1}{#2}%
% \hspace*{\oddsidemargin}\hspace*{\marginparsep}}%
\setlength{\@tempdima}{\marginparsep+\eqemargin}%
\hspace*{\@tempdima}}%
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\marginpointsboxtext}
% When the author selects \texttt{pointsonright} or \texttt{pointsonbothsides}, a box
% appears in the right margin containing problem totals, this is the text for the box.
% \begin{macrocode}
\newcommand{\marginpointsboxtext}[2]{\small$#1\,\text{%
\ifnum#1=1\relax\eqptLabel\else\eqptsLabel\fi}$}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\eqrightmarginbox}
% When the author selects \texttt{pointsonright} or \texttt{pointsonbothsides}, a box
% appears in the right margin containing problem totals, this is the box that appears.
% \begin{macrocode}
\def\@insertPointsBoxPDF
{
\def\fieldName{pointsgiven.\curr@quiz.page\thepage.%
\theeqquestionnoi}%
\calcTextField[\F\FHidden\BC{}\Q1\textColor{1 0 0 rg}]
{\fieldName}{\widthtpboxes}{15pt}%
}
\def\@insertTotalsBoxPDF
{
\def\fieldName{pagetotals.\curr@quiz.page\thepage}%
\calcTextField[\F\FHidden\BC{}\Q1\textColor{1 0 0 rg}
\AA{\AACalculate{AFSimple_Calculate("SUM",
new Array("pointsgiven.\curr@quiz.page\thepage"));}}]
{\fieldName}{\widthtpboxes}{15pt}%
}
\ifx\use@email y
\let\insertPointsBoxPDF=\@insertPointsBoxPDF
\let\insertTotalsBoxPDF=\@insertTotalsBoxPDF
\else
\let\insertPointsBoxPDF=\@empty
\let\insertTotalsBoxPDF=\@empty
\fi
\def\eqrightmarginbox#1#2{%
\makebox[0pt][l]{%
\setlength\tabcolsep{0pt}%
% \end{macrocode}
% (2011/05/08) new calculation for the right point box.
% \begin{macrocode}
\setlength{\@tempdima}{\textwidth-\eqemargin+\marginparsep}%
\hspace*{\@tempdima}%
\raisebox{-.5\height}[0pt][0pt]{%
\parbox{\widthtpboxes}{%
\tabcolsep=0pt\relax
\begin{tabular}{|c|}\hline
\vrule height15pt width0pt\insertPointsBoxPDF\\\hline
\makebox[\widthtpboxes]{%
\marginpointsboxtext{#1}{#2}}\\\hline
\end{tabular}%
}%
}\hfil
}%
}
\def\eqeomarginboxright#1#2{%
\makebox[0pt][l]{%
% \setlength\tabcolsep{0pt}%
\setlength{\@tempdima}{\textwidth+\marginparsep-\parindent}%
\hspace*{\@tempdima}%
\raisebox{-.5\height}[0pt][0pt]{%
\parbox{\widthtpboxes}{%
\tabcolsep=0pt\relax
\begin{tabular}{|c|}\hline
\vrule height15pt width0pt\insertTotalsBoxPDF\\\hline
\makebox[\widthtpboxes]{%
\marginpointsboxtext{#1}{#2}}\\\hline
\end{tabular}%
}%
}\hfil
}%
}
\def\eqeomarginboxleft#1#2{\makebox[0pt][r]{%
\raisebox{-.5\height}[0pt][0pt]{\parbox{\widthtpboxes}{%
\tabcolsep=0pt\relax
\begin{tabular}{|c|}\hline
\vrule height15pt width0pt\insertTotalsBoxPDF\\\hline
\makebox[\widthtpboxes]{%
\marginpointsboxtext{#1}{#2}}\\\hline
\end{tabular}%
}}{\settowidth{\@tempdimb}{\eqe@hspannerPrb}%
\setlength{\@tempdima}{\marginparsep+\eqemargin-\@tempdimb}%
\hspace*{\@tempdima}}}\hfil
}
\setbox\eq@pointbox=\hbox{%
\parbox{\widthtpboxes}{%
\tabcolsep=0pt\relax
\begin{tabular}{|c|}\hline
\vrule height15pt width0pt\\\hline
\makebox[\widthtpboxes]{%
\marginpointsboxtext{00}{0}}\\\hline
\end{tabular}%
}%
}
\setlength\eq@pointboxtotalheight{\dp\eq@pointbox+\ht\eq@pointbox}
% \end{macrocode}
% \end{macro}
% The macro \cs{probvalue}, defined above, says
%\begin{verbatim}
%\mark{\theeqpointvalue\csname eqExam\endcsname\theeq@numparts}
%\end{verbatim}
% so the \cs{botmark} contains the point value of this page and the part number for
% this page.
% \begin{macrocode}
\def\lastparttotaled{0}
% \end{macrocode}
% The \texttt{botmark} looks like \texttt{18\string\eqExam0}, where $18$ will be the total number of
% points accumulated for this text part. We need to retrieve these number, I don't remember why
% I save them this way.
%
% \DescribeMacro{\parsetotals}
% The \cs{parsetotals} macro is called in \cs{settotalsbox} to retrieve the ongoing point values
% from \cs{botmark}, and returns to two parameters, contained in \cs{argi} and \cs{argiii}.
% \DescribeMacro{\stripeqExam}
% Whereas, \cs{stripeqExam} just retrieves the first parameter only.
% \begin{macrocode}
\def\parsetotals#1\eqExam#2\end{\def\argi{#1}\def\argii{#2}}
\def\stripeqExam#1\eqExam{\def\argii{#1}}
% \end{macrocode}
% \begin{macro}{\settotalsbox}
% This is the box containing the page total, it may appear on the left or right side bottom
% corner.
% \begin{macrocode}
\def\settotalsbox{%
%\typeout{\string\botmark=\botmark}%
\expandafter\parsetotals\botmark\eqExam\end
\ifx\argi\@empty\hfil
\else\ifx\argii\@empty\hfil
\else
\expandafter\stripeqExam\argii
% \end{macrocode}
% Set \texttt{eqpointsthispage} equal to \cs{argi}, which should be the accumulated total
% for this part of the test so far.
% \begin{macrocode}
\setcounter{eqpointsthispage}{\argi}%
% \end{macrocode}
% This subtract \texttt{eqpointsofar}, which should be the total for this test part through the
% previous page. The difference is the number of points for this page.
% \begin{macrocode}
\addtocounter{eqpointsthispage}{-\value{eqpointsofar}}%
% \end{macrocode}
% Now we set \texttt{eqpointsofar} to the new accumulated total \cs{argi}.
% \begin{macrocode}
\setcounter{eqpointsofar}{\argi}%
% \end{macrocode}
% And save to the auxiliary file for later usage.
% \begin{macrocode}
\xdef\lastparttotaled{\argii}%
\immediate\write\@auxout{\string\expandafter\string\gdef
\string\csname\space Page\thepage total\string\endcsname
{\theeqpointsthispage}}%
% \end{macrocode}
% Finally, place the totals box.
% \begin{macrocode}
\totalsbox
\fi
\fi
}
% \end{macrocode}
% \end{macro}
% \DescribeMacro{\totalsboxtext} This is the text that appears in the totals boxes
% \begin{macrocode}
\newcommand\totalsboxtext{\small$\theeqpointsthispage\,\text{%
\ifnum\theeqpointsthispage=1\relax\eqptLabel\else
\eqptsLabel\fi}$}
% \end{macrocode}
% \DescribeMacro{\totalsboxleft}\DescribeMacro{\totalsboxright} There are two totals boxes, one for the left and one
% for the right side. These can be redefined as desired.
% \begin{macrocode}
\def\totalsboxleft{%
\makebox[0pt][r]{\setlength\tabcolsep{0pt}%
\raisebox{-\height-\marginparsep}[0pt][0pt]{%
\parbox{\widthtpboxes}{%
\begin{tabular}{|c|}\hline
\vrule height15pt width0pt\insertTotalsBoxPDF\\\hline
\parbox{\widthtpboxes}{%
\strut\centering\totalsboxtext\strut}\\\hline
\end{tabular}%
}}\hspace*{\marginparsep}%
}\hfil
}
\def\totalsboxright
{%
\makebox[0pt][l]{\setlength\tabcolsep{0pt}%
\hspace*{\textwidth}\hspace*{\marginparsep}%
\raisebox{-\height-\marginparsep}[0pt][0pt]{%
\parbox{\widthtpboxes}{%
\begin{tabular}{|c|}\hline
\vrule height15pt width0pt\insertTotalsBoxPDF\\\hline
\parbox{\widthtpboxes}{%
\strut\centering\totalsboxtext\strut}\\\hline
\end{tabular}%
}%
}%
}\hfil
}
% \end{macrocode}
% We begin the document by declaring the current part is part 0 with 0 points. This is the default,
% in case the author writes a document with no parts or points!
% \begin{macrocode}
\AtBeginDocument{\mark{0\csname eqExam\endcsname0}}
% \end{macrocode}
% At the end of the document, we write out the number of parts for this test, and
% the names of the parts the author has given each part.
% \begin{macrocode}
\AtEndDocument{%
\immediate\write\@auxout{\string\expandafter\string\gdef
\string\csname\space NumberOfParts\string\endcsname
{\arabic{eq@numparts}}}%
\immediate\write\@auxout{\string\expandafter\string\gdef
\string\csname\space thePartNames\string\endcsname
{\the\partNames}}%
\clearpage\addtocounter{page}{-1}\writelastpage\relax
\addtocounter{page}{1}%
}
% \end{macrocode}
% \begin{macro}{\theGrandTotal}
% When an exam has multiple parts, the total of each part is computed
% and the grand total is computed with \cs{theGrandTotal}.
% \begin{macrocode}
\def\theGrandTotal{\csname eqeGrandTotal\endcsname}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\totalForPart}
% User access to the total for a exam environment, one argument, the name of the exam.
% \begin{macro}{\percentForPart}
% Attempts to calculate the percent of the total that the referenced exam (\texttt{\#1})
% contributes to the grand total.
% \begin{macrocode}
\newcommand{\totalForPart}[1]{\csname#1total\endcsname}
\newcommand{\percentForPart}[1]{\csname#1percent\endcsname\%}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%\subsection{Computing Number of Points within a Segment of the Exam}
%
% We add some commands for calculating number of points in a segment of the exam.
% A segment being defined subset of consecutive problems within an exam. We can
% define segments by placing markers (using \cs{placeMarkerHere}) between problems. We can
% then calculate the total number of points between markers.
%
% The counter below is a scratch counter for making the calculations. We assume the
% \texttt{calc} package is loaded, it does the work for us.
%
% \begin{macrocode}
\newcounter{markerCnt}
% \end{macrocode}
% \begin{macro}{\placeMarkerHere}
% Placed outside of any \texttt{problem}/\texttt{problem*} environment, this command
% takes one argument, the symbolic name for this marker. We write to the auxiliary file
% and define a command whose name is based on \texttt{\#1}, and whose value is
% the cumulative total \cs{theeqpointvalue}.
%\changes{v1.8}{2008/11/02}
%{
% Added a set of commands \cs{placeMarkerHere}, \cs{calcFromMarkers},
% and \cs{markerTotalFmt} to enable the calculation of totals of segments
% of the exam.
%}
% \begin{macrocode}
\def\placeMarkerHere#1{%
\immediate\write\@auxout{\string\expandafter\string\gdef
\string\csname\space#1SaveTotalHere\string\endcsname
{\theeqpointvalue}}%
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\calcFromMarkers}
% Once the markers are in place, we can calculate the number of points defined between
% two such markers. The \cs{calcFromMarkers} takes three arguments, \texttt{\#2} and
% \texttt{\#3} are the symbolic names of the two markers. While, \texttt{\#1} is an optional
% argument for formatting the calculation. The default is \cs{@markerTotalFmt}, defined
% below in \cs{markerTotalFmt}. The value of the total is \cs{themarkerCnt}.
% \begin{macrocode}
\newcommand{\calcFromMarkers}[3][\@markerTotalFmt]{%
\@ifundefined{#2SaveTotalHere}{}%
{\@ifundefined{#3SaveTotalHere}{}{\setcounter{markerCnt}%
{\@nameuse{#2SaveTotalHere}-\@nameuse{#3SaveTotalHere}}%
\ifnum\value{markerCnt}<0\relax
\setcountertotalHereCnt{-\value{markerCnt}}\fi#1}}%
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\markerTotalFmt}
% Used to set the global format of the marker totals. The value of the marker total
% is \cs{themarkerCnt}. The default follows the definition of \cs{markerTotalFmt}
% \begin{macrocode}
\newcommand{\markerTotalFmt}[1]{\def\@markerTotalFmt{#1}}
\markerTotalFmt{ (\themarkerCnt\space points)}
% \end{macrocode}
% \end{macro}
% \subsection{Useful Commands to Write Problems}
% \begin{macrocode}
\def\placeAtxy#1#2#3{%
\par\nointerlineskip
\ifdisplayworkarea
\ifeq@nosolutions\ifx\eq@insertverticalspace y%
\ifvmode\makebox[0pt][l]{%
\hspace*{-\parindent}\hspace*{#1}%
\raisebox{#2}[0pt][0pt]{#3}}\fi
\fi\fi
\fi
}
\newsavebox{\workareasb}
% \end{macrocode}
% \begin{environment}{workarea}
% A work area is used when we display vertical space such as when the
% \texttt{nosolutions} and \texttt{vspacewithsolns} options are in effect.
% \begin{macrocode}
\newenvironment{workarea}[2][\linewidth]
{%
\edef\workareadepth{\if\currhideopt H0pt\else#2\fi}%
\begin{lrbox}{\workareasb}\setlength{\eqetmplengtha}{#1}%
\begin{minipage}[b][\workareadepth][t]{\eqetmplengtha}\vspace*{3pt}%
}%
{%
\end{minipage}\end{lrbox}%
% \end{macrocode}
% \texttt{4/5/11} Changed the logic here, so the \texttt{workarea} is available
% for the \texttt{vspace\-with\-solns} option.
% \begin{macrocode}
\par\ifdisplayworkarea %\ifNotsolutionsafter{%
\ifx\eq@insertverticalspace y%
\vspace{-\baselineskip}\fi
\ifx\eq@insertverticalspace y%
\if\currhideopt H\else
\noindent\strut\smash{\usebox{\workareasb}}%
\fi\fi %}{}%
\fi
}
% \end{macrocode}
% \end{environment}
% \begin{environment}{splitsolution}
% This is a special solution environment designed for use with the \texttt{online} or \texttt{email}
% options.
% \begin{macrocode}
\newcommand\panelgap{3pt}
\newsavebox{\eqpanelbox}
\def\panelwidth{\the\wd\eqpanelbox}\def\panelheight{\the\ht\eqpanelbox}%
\newcounter{panel@cnt}
\newwrite\panel@write
\let\usepanelwidth=\relax
\newenvironment{panel}[2][l]
{%
\gdef\ss@Argi{#1}\gdef\ss@Argiii{#2}% #1 r or l #2 width of panel
\stepcounter{panel@cnt}%
\immediate\openout \panel@write panel\thepanel@cnt.cut
% need to manage the h, H, and global overrides.
\if\currhideopt H%
\immediate\write\panel@write{\vfill}%
\immediate\closeout\panel@write
\gdef\ss@Argii{0pt}%
\else
\if\currhideopt h\ifeq@solutionsafter\else
\ifeq@globalshowsolutions\else
\immediate\write\panel@write{\vfill}%
\immediate\closeout\panel@write
\gdef\ss@Argii{0pt}%
\fi\fi
\fi
\fi
\begingroup
\let\verbatim@out=\panel@write
\verbatimwrite
}
{%
\endverbatimwrite
\immediate\closeout\panel@write
\endgroup
\xdef\mp@Width{\ifeq@solutionsafter\noexpand\linewidth
\else\noexpand\linewidth-\ss@Argiii-\panelgap\fi}%
}
\long\def\eqe@IW#1{%
\ifeq@solutionsafter
\let\eqe@next=\@empty
\else
\def\eqe@next{\immediate\write\verbatim@out{#1}}%
\ifeq@nosolutions\else
\if\currhideopt H%
\gdef\ss@Argii{0pt}\let\eqe@next=\@empty
\else
\if\currhideopt h%
\ifeq@globalshowsolutions\else
\gdef\ss@Argii{0pt}\let\eqe@next=\@empty
\fi
\fi
\fi
\fi
\fi
\eqe@next
}
\newenvironment{@ssSolution}[1][\ss@Argii]%
{%
\xdef\eqe@depth{\ifeq@nosolutions\ss@Argii\else
\ifeq@solutionsafter\ss@Argii\else0pt\fi\fi}%
\xdef\mp@Width{\ifeq@solutionsafter\noexpand\linewidth\else
\noexpand\linewidth-\ss@Argiii-\panelgap\fi}%
\if\ss@Argi l%
\ifeq@solutionsafter
\def\eqe@lPanel{\parbox[b][\eqe@depth][t]{\ss@Argiii}
{\input{panel\thepanel@cnt.cut}\vfill}\hfill}%
\def\eqe@rPanel{\@empty}%
\else
\def\eqe@lPanel{\string\parbox[b][\string\eqe@depth]%
{\ss@Argiii}%
{\string\input{panel\thepanel@cnt.cut}\vfill}\hfill^^J}%
\def\eqe@rPanel{\@empty}%
\fi
\else
\ifeq@solutionsafter
\def\eqe@lPanel{\@empty}%
\def\eqe@rPanel{\hfill\parbox[b][\eqe@depth][t]{\ss@Argiii}
{\hfill\input{panel\thepanel@cnt.cut}\vfill}}%
\else
\def\eqe@lPanel{\@empty}%
\def\eqe@rPanel{\hfill\string\parbox[b][\string\eqe@depth]%
{\ss@Argiii}%
{\endgraf\string\noindent\hfill%
\string\input{panel\thepanel@cnt.cut}\vfill}}%
\fi
\fi
\let\verbatim@out=\ex@solns
\par\ifeq@solutionsafter\smallskip\fi\noindent\minipage{\linewidth}%
\if\ss@Argi l\noindent\parbox[b][\eqe@depth][t]{\ss@Argiii}%
{\vfill}\hfill\fi
\minipage[b][\eqe@depth][t]{\mp@Width}%
{\lccode`C=`\%\lowercase{\eqe@IW{\def\string\panelgap{\panelgap}%
\edef\string\eqe@depth
{\ifeq@nosolutions\ss@Argii\else\ss@Argii\fi}C}}}%
{\lccode`C=`\%\lowercase{\eqe@IW{%
\string\strut\string\par\string\nobreak\string\noindent%
\string\hbox\space to\string\linewidth\bgroup^^J%
\eqe@lPanel\string\minipage[b][\string\eqe@depth][t]%
{\string\linewidth-\ss@Argiii-\panelgap}C
}}}%
\ifeq@solutionsafter
\noindent\strut\hbox to\linewidth\bgroup
\eqe@lPanel
\minipage[b][\eqe@depth][t]{\linewidth-\ss@Argiii-\panelgap}%
\def\solutionsafterSkip{}%
\fi
\@sssolution[#1]%
}{%
\eqe@IW{\noexpand\endminipage\eqe@rPanel\egroup}%
\ifeq@solutionsafter\endminipage\eqe@rPanel\egroup\fi
\end@sssolution
\endminipage\endminipage
}
\newenvironment{splitsolution}[1] % #1 depth
{%
\gdef\ss@Argii{#1}%
\let\@sssolution = \solution
\let\end@sssolution = \endsolution
\let\solution = \@ssSolution
\let\endsolution = \end@ssSolution
\par\noindent\ignorespaces
}{%
\ifeq@solutionsafter\strut\par\fi
\edef\eqe@workwidth{\if\ss@Argi l\noexpand\ss@Argiii
\else\noexpand\linewidth\fi}%
\edef\eqe@workfill{\if\ss@Argi l\else\hfill\fi}%
\begin{workarea}[\eqe@workwidth]{\eqe@depth}%
\eqe@workfill\input{panel\thepanel@cnt.cut}%
\end{workarea}
\strut\par
}
% \end{macrocode}
% \end{environment}
% Redefine the \cs{paragraph} command
% \begin{macrocode}
\renewcommand{\paragraph}
{\@startsection{paragraph}{4}{0pt}{12pt}{-3pt}{\bfseries}}
% \end{macrocode}
% \begin{macro}{\defaultInstructions}
% For the \texttt{instructions} environment, defined next, the default string
% for the instructions is \cs{eq@default@Instructions}, this command is
% defined using \cs{defaultInstructions}.
% \begin{macrocode}
\newcommand{\defaultInstructions}[1]{\def\eq@default@Instructions{#1}}
\defaultInstructions{Instructions.}
% \end{macrocode}
% \end{macro}
%
% \begin{environment}{instructions}
% Each test, or a part of a test usually have instructions. This \texttt{instruction}
% environment is used in this purpose. Normally, the number of points for the part is
% displayed following the heading (the default is \textbf{Instructions.}). You can
% eliminate the total points from the instructions by taking the \texttt{nosummarytotals}
% option.
%
% \begin{macrocode}
\newenvironment{instructions}[1][\eq@default@Instructions]
{%
% \end{macrocode}
% (2011/05/08) We change the \cs{leftskip} to \texttt{-\string eqemargins}
% to reflect the change in formatting.
% \begin{macrocode}
% \leftskip-\eqemargin \rightskip0pt
\def\eq@argi{#1}%
% \end{macrocode}
% (2011/05/08) We also replace \cs{paragraph*} with just \cs{textbf}, within
% a list environment \cs{paragraph*} causes problems.
% \begin{macrocode}
\paragraph*{\textcolor{\@instructionsColor}{#1}\normalcolor%
\ifx\eq@nosummarytotals y\else\ifx\eq@argi\@empty\else\ \fi
{\normalfont\summaryTotalsTxt}\ \fi}\hskip-\lastskip
\ifx\eq@nosummarytotals y\ifx\eq@argi\@empty\else\ \fi\fi
\ignorespaces}{\par\vskip\medskipamount}
\newcommand\summaryPointTotal{\csname\thisexamlabel total\endcsname}
\newcommand\summaryTotalsTxt{($\summaryPointTotal\,\text{%
\@ifundefined{\thisexamlabel total}{\eq@pointsLabel}%
{\ifnum\summaryPointTotal=1\relax\eq@pointLabel\else
\eq@pointsLabel\fi}}$)}
\newcommand{\nQuesInExam}[1][\thisexamlabel]{%
\csname#1nQuestions\endcsname
}
% \end{macrocode}
% \end{environment}
% Make this definition for \texttt{hyperref}, so its anchors will be unique. Useful
% when there are multiple parts of the test.
% \begin{macrocode}
\ifx\hyper@anchor\@undefined\else
\renewcommand\theHeqquestionnoi
{\curr@quiz.\theeqquestionnoi}
\renewcommand\theHquizno{%
\if\probstar*\curr@quiz.%
\theeqquestionnoi.part\thepartno.\arabic{quizno}%
\else
\curr@quiz.%
\theeqquestionnoi.\arabic{quizno}%
\fi
}
\renewcommand\theHpartno{\curr@quiz.%
\theeqquestionnoi.part\thepartno}
\fi
% \end{macrocode}
% \begin{environment}{eqComments}
% Often, I want to make additional instructions between problems, you can use
% this comment environment.
% \begin{macrocode}
\newenvironment{eqComments}[1][\strut]
{%
\removelastskip\removelastskip\def\eqe@argi{#1}%
% \end{macrocode}
% (2011/05/08) We change the \cs{leftskip} to \texttt{-\string eqemargins}
% to reflect the change in formatting.
% \begin{macrocode}
\vskip\medskipamount %\leftskip-\eqemargin \rightskip0pt
\def\eqe@Strut{\strut}%
% \end{macrocode}
% (2011/05/08) We also replace \cs{paragraph*} with just \cs{textbf}, within
% a list environment \cs{paragraph*} causes problems.
% \begin{macrocode}
\paragraph*{\textcolor{\@eqCommentsColor}{#1}}%
\ifx\eqe@argi\eqe@Strut\hskip-\lastskip\else\space\fi
\color{\@eqCommentsColorBody}\ignorespaces
}{%
\vskip\medskipamount
}
% \end{macrocode}
% \end{environment}
% \subsection{The \texttt{exam} Environment}
% Each part of the exam is enclosed in an \texttt{exam} environment. The environment is
% a customized version of the \texttt{shortquiz} environment.
% \begin{macro}{\exambegdef}
% Some definitions that are executed at the beginning of each exam environment.
% \begin{macrocode}
\let\tb@beginexam@code\relax
\def\partialspillovertotals{0}
\def\exambegdef
{%
\csname\thisexamlabel pagemark\endcsname
\@ifundefined{partialtotalpg}{}{%
\ifnum\partialtotalpg=\arabic{page}%
{\count0=\partialspillovertotals
\advance\count0by\partialtotaleoe
\xdef\partialspillovertotals{\the\count0}%
\immediate\write\@auxout{\string\expandafter\string\gdef
\string\csname\space Page\partialtotalpg spilltotal\string\endcsname
{\partialtotaleoe}}%
}%
\fi
}
\expandafter
\ifx\csname\thisexamlabel pageno\endcsname\relax
\else
\expandafter
\ifx\csname pagenofirstprob\thisexamlabel\endcsname\relax
\else
\ifnum\csname\thisexamlabel pageno\endcsname
<\csname pagenofirstprob\thisexamlabel\endcsname
\else
\expandafter
\ifx\csname\thisexamlabel pagemark\endcsname\relax
\else
\ifnum\value{page}=%
\csname\thisexamlabel pageno\endcsname
\immediate\write\@auxout{%
\string\expandafter\string\gdef
\string\csname\space
\thisexamlabel pagemark\string\endcsname
{\string\newpage}}%
\fi
\fi
\fi
\fi
\fi
\setcounter{eqquestionnoi}{0}\setcounter{eqpointvalue}{0}%
\setcounter{eqpointsofar}{0}\setcounter{eqpointsthispage}{0}%
\setcounter{eq@count}{0}%
% \end{macrocode}
% We wrote \verb!\begin{eqequestions}! to the top of the solutions file (\cs{jobname.sol}.
% \begin{macrocode}
\writeBeginEqeQuestions
% \end{macrocode}
% \begin{macrocode}
\label{\thisexamlabel PageBegin}%
\immediate\write\@auxout{\string\expandafter\string\gdef
\string\csname\space\thisexamlabel pageno\string\endcsname
{\thepage}}%
% \let\sq@priorhook\@empty
\ifeqfortextbook
\global\examenvtrue\tb@beginexam@code
\fi
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\examenddef}
% Some definitions that are executed at the end of each exam environment.
% We place a totals box to report the total since the last page.
% \begin{macrocode}
\def\tb@insmargmark{\ifisinstred\ifismarginans
\insMidMarg{\mark{}}\fi\fi}
\def\examenddef
{%
\global\let\partialtotaleoe\relax
\global\let\partialtotalpg\relax
\expandafter\ifx\csname NumberOfParts\endcsname\relax
\else
\ifnum\value{eq@numparts}<\NumberOfParts
\setcounter{eq@count}{\value{eqpointvalue}}%
\addtocounter{eq@count}{-\value{eqpointsofar}}%
\xdef\partialtotaleoe{\arabic{eq@count}}%
\xdef\partialtotalpg{\arabic{page}}%
\if\eq@parttotals y%
% \end{macrocode}
% See if there is enough room at the bottom of the page to place the end of exam
% totals, if not, forget it, and start a new page.
% \begin{macrocode}
\@actionsAtPageBreak{\global\let\@spacetobreak1}%
{\global\let\@spacetobreak0}%
\ifx\@spacetobreak0\relax
\bgroup\@tempdima=\pagetotal
\advance\@tempdima32pt\relax
\ifdim\@tempdima>\pagegoal\aftergroup\newpage
\else
\ifnum\arabic{eq@count}>0
\ifx\@reportpoints1\else\@checkSpacing\fi
\textcolor{blue}{\eqeomarginbox%
{\arabic{eq@count}}{0}}%
\fi
\ifx\eqx@separationrule y\separationrule\fi
\fi\egroup
\fi
\else\ifx\eqx@separationrule y\separationrule\fi
\fi
\fi
\fi
\ifeqfortextbook\global\examenvfalse\fi
% \end{macrocode}
% (2011/05/08) Just before the file is closed and input, we write the end
% of the \texttt{eqequestions} environment, \verb!\end{eqequestions}!.
% \begin{macrocode}
\writeEndEqeQuestions
% \end{macrocode}
% \begin{macrocode}
\writetotalstoaux
\addtocounter{page}{-1}%
\writelastpage[\thisexamlabel]\addtocounter{page}{1}%
\ifeqfortextbook\tb@insmargmark\fi
}
\def\@actionsAtPageBreak#1#2{%
\bgroup\@tempdima\pagegoal\advance\@tempdima-\pagetotal
\@tempdimb\@fvsizeskip\vsize
\ifdim\@tempdima < \@tempdimb #1\else #2\fi\egroup
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\separationrule}
% For an exam with multiple parts, a separation rule is created, unless absorbed
% into a page break. The command \cs{separationrule} defines this separation rule,
% it can be redefined as desired.
% \changes{v1.7a}{2007/12/10}
%{
% Added \cs{separationrule} so user's can redesign the separation rule
% that is created between two parts of an exam.
%}
% \begin{macrocode}
\newcommand{\separationrule}{\makebox[\linewidth-\eqemargin]%
{\centering\rule{.67\linewidth}{.4pt}}}
% \end{macrocode}
% \end{macro}
% (2011/05/08) This is a new environment that makes an exam into a list of problems.
% This is an attempt to expand the use of \textsf{eqexam} to {\LaTeX}
% documents. We give control over the page layout so an eqexam document
% can be used within a textbook.
% \begin{macrocode}
\def\eqe@hspannerPrb{\ }
\newif\ifwithsoldoc \withsoldocfalse
\newcommand{\eqequestopsep}[1]{\def\eqeques@topsep{#1}}
\newcommand{\eqequesparsep}[1]{\def\eqeques@parsep{#1}}
\newcommand{\eqequesitemsep}[1]{\def\eqeques@itemsep{#1}}
\eqequestopsep{3pt}
\eqequesparsep{0pt}
\eqequesitemsep{3pt}
\newenvironment{eqequestions}{%
\begin{list}{}{%
\setlength{\labelwidth}{\eqemargin}%
\setlength{\topsep}{\eqeques@topsep}%
\setlength{\parsep}{\eqeques@parsep}%
\setlength{\itemsep}{\eqeques@itemsep}%
\setlength{\itemindent}{0pt}
\ifwithsoldoc\settowidth{\labelsep}{\eqe@hspannerSoln}\else
\settowidth{\labelsep}{\eqe@hspannerPrb}\fi
\setlength{\leftmargin}{\labelwidth}%
}\item\relax}{\end{list}}
% \end{macrocode}
% \begin{environment}{exam}
% Each part of the exam is enclosed in an \texttt{exam} environment. The one
% required parameter is the name of the part, for example, `Part1', `Part2'.
% These should be one word, no white spaces, just letters and possibly numbers.
% \begin{macrocode}
\def\setDefaultfvsizeskip#1{\def\default@fvsizeskip{#1}%
\def\@fvsizeskip{#1}}
\def\default@fvsizeskip{.3}
\edef\@fvsizeskip{\default@fvsizeskip}
\def\fvsizeskip#1{\def\@fvsizeskip{#1}}
\def\autoExamName{exam\the\value{eq@numparts}}
\def\nNumberOfP@rts{\csname NumberOfParts\endcsname}
\newenvironment{exam}[2][]
{%
\makeRoomForProb{\@fvsizeskip\textheight}{0}%
% \xdef\@fvsizeskip{\default@fvsizeskip}%
\stepcounter{eq@numparts}%
\xdef\thisexamlabel{#2}\xdef\curr@quiz{#2}%
\edef\eq@tmp{\the\partNames}%
\global\partNames=\expandafter{\eq@tmp\\{#2}}%
\expandafter\ifx\csname NumberOfParts\endcsname\relax\else
\ifnum\nNumberOfP@rts=1\relax\else
\def\eqe@argi{#1}\ifx\eqe@argi\@empty
\eqe@writetoSolns{#2}\eqe@writetoAux{%
\string\expandafter\string\gdef
\string\csname\space userFriendly#2\string\endcsname{#2}}
\else
\eqe@writetoSolns{#1}\eqe@writetoAux{%
\string\expandafter\string\gdef
\string\csname\space userFriendly#2\string\endcsname{#1}}
\fi
\fi\fi
\exambegdef
\expandafter\shortquiz\sqstar[#2]%
}{%
\examenddef
\endshortquiz
\par\penalty-1000\vskip0pt
}
% \end{macrocode}
% \end{environment}
% \begin{macro}{\EQEcalculateAllTotals}
% (4/22/11) Added the command \cs{EQEcalculateAllTotals}. The command is executed
% as part of the \cs{maketitle} command. If \cs{maketitle} is not used for some reason
% \cs{EQEcalculateAllTotals} can be executed just after \verb~\begin{document}~.
% \begin{macrocode}
\newcommand{\EQEcalculateAllTotals}{%
\begingroup
% \end{macrocode}
% We calculate the grand total of all the parts of the \texttt{exam} environments,
% and we define \cs{eqeGrandTotal}, which contains the total.
% \begin{macrocode}
\count0=0\relax
\def\\##1{\expandafter
\ifx\csname##1total\endcsname\relax\else
\advance\count0by\csname##1total\endcsname
% \end{macrocode}
% \cs{thePartNames} list all named exam environments in the document, e.g.,
%\begin{verbatim}
% \\{Part1}\\{Part2}...\\{LastPart}
%\end{verbatim}
% \begin{macrocode}
\fi}\csname thePartNames\endcsname
\xdef\eqeGrandTotal{\the\count0 }%
\ifnum\eqeGrandTotal=0 \else
% \end{macrocode}
% If there is a nonzero grandtotal, we move on to calculate
% the percentages.
% \begin{macrocode}
\def\\##1{\eqe@calc@percent{##1}}%
\csname thePartNames\endcsname\fi
\endgroup
}
% \end{macrocode}
%
% \begin{macro}{\eqe@calc@percent}
% We go through the parts listed in \cs{thePartNames} and create a
% calculation of the percentage for that part, and leave it in
% \verb!\csname#1percent\endcsname!, which can be accessed
% through the \cs{percentForPart} command, for example
% \verb!\percentForPart{}! might expand to \texttt{45.6\%}.
% \begin{macro}{\nPctDecPts}
% The number of decimal points to carry in the representation of the
% percentage.
% \begin{macrocode}
\newcommand{\nPctDecPts}{1}
\def\eqe@calc@percent#1{\@ifundefined{#1total}{%
\expandafter\gdef\csname#1percent\endcsname{??}}{%
% \end{macrocode}
% If the \textsf{fp} package is not loaded, we use register arithmetic,
% percentages are truncated to integers.
% \begin{macrocode}
\expandafter\ifx\csname FPdiv\endcsname\relax
\count2=\totalForPart{#1}%
\edef\expGT{\csname eqeGrandTotal\endcsname}%
\multiply\count2by100\relax\divide\count2by\expGT\relax
\expandafter\xdef\csname#1percent\endcsname{\the\count2 }\else
% \end{macrocode}
% If the \textsf{fp} package is loaded, we use this package to calculate
% the percentage, accurate to one decimal place.
% \begin{macrocode}
\FPdiv{\eqe@pForPart}{\csname#1total\endcsname}%
{\csname eqeGrandTotal\endcsname}%
\FPmul{\eqe@pForPart}{\eqe@pForPart}{100}%
\FPround{\eqe@pForPart}{\eqe@pForPart}{\nPctDecPts}%
\expandafter\xdef\csname#1percent\endcsname{\eqe@pForPart}\fi
}%
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macrocode}
\def\writetotalstoaux{%
\immediate\write\@auxout{\string\expandafter\string\gdef
\string\csname\space\thisexamlabel total\string\endcsname
{\theeqpointvalue}}%
\immediate\write\@auxout{\string\expandafter\string\gdef
\string\csname\space\thisexamlabel nQuestions\string\endcsname
{\theeqquestionnoi}}%
}
\newcommand{\writelastpage}[1][]{\def\eqe@argi{#1}%
\ifx\eqe@argi\@empty\else\label{#1PageEnd}\fi
\immediate\write\@auxout{\string\expandafter\string\gdef
\string\csname\space eqExamLastPage\string\endcsname{\arabic{page}}}%
}
\def\exlabel{}
\def\sqlabel{}
\def\exsolafter{\textit{Solution}:}
\def\sqsolafter{\textit{Solution}:}
% \end{macrocode}
% The exercise labels in the body of the text
% \begin{macrocode}
\def\exlabelformat{\textbf{\theeqquestionnoi.\ }}
\def\exlabelformatwp{\exlabelformat}%
% \end{macrocode}
% The exercise labels for solutions at the end of the document
% \begin{macrocode}
\def\exsllabelformat
{\string\llap{\string\textbf{\theeqquestionnoi.\ }}}
\def\exsllabelformatwp
{\string\llap{\string\textbf{\theeqquestionnoi.\ }}(\thepartno)\ }%
\ifeq@solutionsafter
\def\exrtnlabelformat{}
\def\exrtnlabelformatwp{}
\def\eq@sqslrtnlabel{}
\else
\def\exrtnlabelformat{$\square$}
\def\exrtnlabelformatwp{$\square$}
\def\eq@sqslrtnlabel{$\square$}
\fi
\def\sqslrtnlabel{\eq@sqslrtnlabel}
% \end{macrocode}
% (2010/08/21) Enable some localizations of strings
% \begin{macrocode}
\newcommand{\exsectitletext}{Solutions to \webtitle}
\def\exsectitle{\normalsize\exsectitletext}
%\def\exsectitle{\normalsize\hspace*
% {-\oddsidemargin}\exsectitletext}
\@ifpackageloaded{exerquiz}{%
\renewcommand{\exsecrunhead}{Solutions to \websubject}%
}{\newcommand{\exsecrunhead}{Solutions to \websubject}}
%\providecommand{\exsecrunhead}{Solutions to \websubject}%
\def\eq@sqslsectitle{}
\def\eq@sqslsecrunhead{}
\def\eq@sqsllabel{{\string\llap{\string\textbf{\theeqquestionnoi.\ }}}}
\def\eq@sqlabel{}
\let\include@quizsolutions=\relax
\let\solnhspace\@empty
% \end{macrocode}
% \subsection{\texttt{problem} Environments}
% A single question is posed with the \texttt{problem} environment, and a question with
% multiple parts with the \texttt{problem*} environment.
% \begin{macro}{\fillin}
% This macro is used for fill-in type questions. The first argument is the length
% of the underline blank to leave to fill-in, the second argument is the correct answer.
% \begin{macrocode}
\newcommand{\fillin}[3][u]{%
\ifx#1u\let\@fillinFmt\underbar
\else\ifx#1b\let\@fillinFmt\relax
\else\let\@fillinFmt\relax\fi\fi
\ifeq@proofing
\@fillinFmt{\makebox[#2]{%
\strut\hfil\bfseries\color{red}#3\hfil}}%
\else
\@fillinFmt{\makebox[#2]{\strut\hfil}}%
\@ifundefined{@quiz}{}{%
\ifx\eq@online y\relax
\ifeq@nosolutions
\ifeq@solutionsafter\else
\ifx\eq@insertverticalspace y\relax
\stepcounter{@cntfillin}%
\edef\fieldName{%
\if\probstar*eqexam.\curr@quiz.fillin.%
\theeqquestionnoi.part\thepartno.%
fi\the@cntfillin
\else
eqexam.\curr@quiz.fillin.%
\theeqquestionnoi.fi\the@cntfillin
\fi
}\makebox[0pt][r]{\textField[\BC{}]{%
\fieldName}{#2}{11bp}}%
\fi
\fi
\fi
\fi
}%
\fi\space\ignorespaces}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\TF}
% A specialized version of \cs{fillin} for True/False questions.
% \begin{macrocode}
\newcommand\defaultTFwidth{30pt}
\newcommand\TF[2][\defaultTFwidth]{%
\def\eqe@next{\fillin{#1}{#2}}%
\ifdim\eq@extralabelsep=0pt\relax\else
\if\probstar*\relax\if\exerwparts@cols x
\def\eqe@next{\makebox[0pt][r]{%
\fillin{#1}{#2}}\ignorespaces}%
\fi\fi\fi
\eqe@next}
\def\fillinWidth#1{%
\if\probstar*
\settowidth{\eq@tmplengthA}{\normalfont\ }%
\addtolength{\eq@tmplengthA}{#1}%
\edef\eq@extralabelsep{\the\eq@tmplengthA}%
\fi
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\Do..\of..}
% When I teach senior or graduate-level classes, I often give a problem with
% multiple parts (each of equal value) and ask them to ``do 3 of the following 5''
% parts.
% \begin{macrocode}
\def\makeDoNum#1{\xdef\nDoNum{#1}%
\xdef\DoNum{\ifcase#1??\or one\or two\or three\or
four\or five\or six\or seven\or eight\or nine\or ten\fi}}
\def\makeOutOfNum#1{\xdef\nOutOfNum{#1}%
\xdef\OutOfNum{\ifcase#1??\or one\or two\or three\or
four\or five\or six\or seven\or eight\or nine\or ten\fi}}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
\def\prob@Arg#1ea#2\end{\def\argi{#1}\def\argii{#2}}
\def\makeRoomForProb#1#2{\par %\endgraf % dps 11/11/10
\bgroup\@nobreakfalse\addpenalty{-500}%
\setlength{\@tempdimb}{#1}%
\@tempdima \pagegoal \advance \@tempdima -\pagetotal
\ifdim \@tempdima<\@tempdimb\ifnum\col@number>\@ne\columnbreak
\else\newpage\fi\fi\egroup
\ifx1#2\ifnum\@reportpoints>1 \@checkSpacing\fi\fi
}
% \end{macrocode}
% \begin{macro}{\promoteNewPage}
%\changes{v2.0n}{2011/05/13}{%
% A simple variation on \cs{makeRoomForProb} designed for user use.
%}
% A simple variation on \cs{makeRoomForProb} designed for user use.
% \begin{macrocode}
\newcommand{\promoteNewPage}[1][\@fvsizeskip\textheight]{%
\makeRoomForProb{#1}{0}}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
\def\@checkSpacing{\bgroup
\@tempdima = \lastPageTotal
\@tempdimb = \pagetotal
\ifdim\@tempdima < \@tempdimb
\advance\@tempdimb by-\@tempdima
\ifdim\@tempdimb < \eq@pointboxtotalheight
\@tempdima=\eq@pointboxtotalheight
\advance\@tempdima3pt\relax
\advance\@tempdima by-\@tempdimb
\vspace*{\@tempdima}%
\fi
\fi
\egroup}
\def\default@nbaselineskip{6}
\edef\@nbaselineskip{\default@nbaselineskip}
\def\nbaselineskip#1{\def\@nbaselineskip{#1}}
% \end{macrocode}
% \begin{environment}{problem}
% The \texttt{problem} is used to pose a single---non-multi-part---question.
% The optional argument is the number of points for this problem.
% \begin{macrocode}
\def\@gobbletoend#1\end{}
\def\@grabarg#1\end{\def\numpoints{#1}}
\newenvironment{problem}[1][]{%
\makeRoomForProb{\@nbaselineskip\baselineskip}{1}%
% \xdef\@nbaselineskip{\default@nbaselineskip}%
\gdef\probstar{x}\let\afterlabelhskip\@empty
\ifx\marginpoints\@empty\else\def\numpoints{#1}%
\ifx\numpoints\@empty\let\marginpoints\@empty\else
% \end{macrocode}
%\changes{v2.0n}{2011/05/13}{%
% Added \texttt{*} to signal in-line display of points.
%}
% (2011/5/13) We add a \texttt{*} feature. When the author types
% \texttt{[*3]}, it is a three point problem, but the value is expressed
% in-line, not in the margins.
% \begin{macrocode}
\@ifstar{\let\@isitstar=1\@grabarg}%
{\let\@isitstar=0\@gobbletoend}#1\end
\if\@isitstar1\addtocounter{eqpointvalue}{\numpoints}%
\@marktotalvalue
\def\marginparafterhook{\PTs{\numpoints}\space}\else
\def\marginparpriorhook{\noindent\probvalue{#1}{0}}\fi\fi
\fi\setcounter{eq@count}{\value{eqquestionnoi}}%
\addtocounter{eq@count}{1}%
\ifnum\value{eq@count}=1\relax
\immediate\write\@auxout{\string\expandafter\string\gdef\string
\csname\space pagenofirstprob\thisexamlabel\string\endcsname
{\thepage}}%
\fi
\proofingsymbol{\ding{52}}%
\begin{eqequestions}%
\begin{exercise}[eqquestionnoi]%
}{\end{exercise}%
\end{eqequestions}%
\ifeqlocalversion\ifeqglobalversion
\xdef\eqe@tmp{\noexpand\forVersion{\eq@selectedVersion}}%
\aftergroup\eqe@tmp
\fi\fi
\global\eqlocalversionfalse
}
% \end{macrocode}
% \end{environment}
% \begin{macro}{\PTs}
% \begin{macro}{\itemPTsTxt}
% \begin{macro}{\itemPTsFormated}
% When you specify \cs{auto} for the optional argument of the \texttt{problem*}
% environment, when each item must have the command \cs{PTs} to assign the
% value of that question. The \cs{PTs} has one optional star-parameter, and one
% required parameter. The required parameter is the number of points for this item,
% if the \texttt{*} is specified, then the point value is not typeset in the document.
%
% The command \cs{itemPTsTxt} has one argument, the number of points for this item. This
% argument is passed from the \cs{PTs} command. You can redefine the way the points appear
% in the document using \cs{itemPTsTxt}. As separate command \cs{itemPTsFormated} is used to
% put parentheses around \cs{itemPTsTxt}. If the \texttt{*} option is taken with \cs{PTs}, then
% you are free to place \cs{itemPTsTxt} anywhere in the problem statement.
% \changes{v1.6g}{2006/11/29}
%{
% Added \cs{itemPTsTxt} and \cs{itemPTsFormated} to work with \cs{PTs}.
% Also added a \texttt{*} option, to \cs{PTs}, in this case the points
% are not typeset.
%}
% \begin{macrocode}
\newcommand\itemPTsTxt[1]{$#1\,\text{%
\ifnum#1=1\relax\eqptLabel\else\eqptsLabel\fi}$}
\newcommand\itemPTsEaTxt[1]{$#1\,\text{%
\ifnum#1=1\relax\eqptLabel\else\eqptsLabel\fi\space\eq@eachLabel}$}
\newcommand{\itemPTsFormated}[1]{(#1)}
\def\PTs{\@ifstar{\@PTs{*}}{\@PTs{x}}}
\def\@PTs#1#2{%
\if\@reportpoints0\else
\if\eqe@pointsPartsId1%
\addtocounter{eqpointvalue}{#2}\@marktotalvalue
\addtocounter{eq@count}{#2}\fi\if#1*\else
\itemPTsFormated{\itemPTsTxt{#2}}\fi
\fi
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macrocode}
\let\auto\relax
\def\isItD@{\@ifnextchar\Do{\let\yest@D@=y\y@st@Do}
{\let\yest@D@=n\@gobblet@end}}
\let\yest@D@=n
\def\y@st@Do\Do#1\end{\gdef\D@Num{#1}}
\def\@gobblet@end#1\end{}
% \end{macrocode}
% \begin{environment}{problem*}
% The \texttt{problem*} environment is used to pose a multi-part question.
% The \texttt{parts} environment is used to enumerate the parts.
%\changes{v2.0c}{2011/01/11}{%
% Changed \cs{@next} to \cs{eqe@next}. There was conflict in
% the use of this command with one of the float environments. When user
% used the table environment inside the problem* environment, the
% compiled stopped because \cs{@next} was overwritten.
%}
% \begin{macrocode}
% \end{macrocode}
% We create a Id for the points specified by the first (and second) optional parameters:
% 0 (total points specified); 1 (\cs{auto} specified); 2 (points each
% specified); 4 (\cs{Do} second optional parameter); a value of \cs{relax} means
% no points specified (the default).
% \begin{macrocode}
\let\eqe@pointsPartsId\relax
% \end{macrocode}
% We now begin the code for the \texttt{problem*} environment.
% \begin{macrocode}
\expandafter\def\csname problem*\endcsname{%
\@ifnextchar[{\pr@bl@m@star}{\pr@bl@m@star[]}}
\def\pr@bl@m@star[#1]{%
\@ifnextchar[{\pr@blem@star{#1}}{\pr@blem@star{#1}[]}}
\def\pr@blem@star#1[#2]{%
\makeRoomForProb{\@nbaselineskip\baselineskip}{1}%
\proofingsymbol{\ding{52}}\gdef\probstar{*}%
\gdef\pr@b@secondarg{#2}\setcounter{eq@count}{0}%
\let\afterlabelhskip\@empty
\global\let\probpointseach\@empty\def\numpoints{#1}%
\@ifstar{\let\@isitstar=1\@grabarg}%
{\let\@isitstar=0\@gobbletoend}#1\end
% \end{macrocode}
% Check for the \cs{auto} keyword
% \begin{macrocode}
\expandafter\ifx\numpoints\auto\let\eqe@pointsPartsId1%
\global\let\probpointseach\relax
% \end{macrocode}
% The author has requested \cs{auto}
% \begin{macrocode}
\def\eqe@next{\autocalcparts}%
\else
\ifx\pr@b@secondarg\@empty\else
\let\eqe@pointsPartsId4%
% \end{macrocode}
% Second Optional Argument not empty
% \begin{macrocode}
\setcounter{eq@count}{\value{eqquestionnoi}}%
\addtocounter{eq@count}{1}%
\@ifundefined{nPartsThisProb\thisexamlabel.\theeq@count}
{\makeOutOfNum{0}\makeDoNum{0}}{%
\expandafter\makeOutOfNum{%
\csname nPartsThisProb\thisexamlabel.%
\theeq@count\endcsname}%
\expandafter\makeDoNum{%
\csname DoNumThisProb\thisexamlabel.%
\theeq@count\endcsname}%
}%
\fi
\def\eqe@next{\manualcalcparts{\numpoints}}%
\fi\eqe@next
\ifeqfortextbook
\writeToSolnFile{\global\protect\frstProbNumShownfalse}\fi
\begin{eqequestions}%
\begin{exercise}[eqquestionnoi]*}%
\expandafter\def\csname endproblem*\endcsname{%
\immediate\write\@auxout{\string\expandafter\string\gdef\string
\csname\space nPartsThisProb\thisexamlabel.\theeqquestionnoi
\string\endcsname{\arabic{partno}}}%
\ifx\probpointseach\@empty\else
\ifx\probpointseach\auto
\immediate\write\@auxout{%
\string\expandafter\string\gdef\string
\csname\space prob\thisexamlabel.\theeqquestionnoi
\string\endcsname{\theeq@count}}%
\else
\setcounter{eq@count}{\value{partno}}%
\ifx\pr@b@secondarg\@empty\else
\bgroup\toks0=\expandafter{\pr@b@secondarg}%
\expandafter\isItD@\the\toks0 \end
\ifx\yest@D@ y
\immediate\write\@auxout{%
\string\expandafter\string\gdef\string
\csname\space DoNumThisProb\thisexamlabel.%
\theeqquestionnoi\string\endcsname{\D@Num}}%
\@tempcnta = \value{eq@count}%
\advance\@tempcnta -\D@Num
\global\advance\value{eq@count}-\@tempcnta
% 3.0k
\@tempcnta=\value{partno}%
\advance\@tempcnta -\D@Num
\multiply\@tempcnta by\argi
\addtocounter{eqpointvalue}{-\@tempcnta}%
% end
\fi
\egroup
\fi
\multiply\value{eq@count}\argi
\immediate\write\@auxout{%
\string\expandafter\string\gdef\string
\csname\space prob\thisexamlabel.\theeqquestionnoi
\string\endcsname{\theeq@count}}%
\bgroup
\egroup
\fi\fi
\end{exercise}%
\end{eqequestions}%
\ifeqlocalversion\ifeqglobalversion
\xdef\eqe@tmp{\noexpand\forVersion{\eq@selectedVersion}}%
\aftergroup\eqe@tmp
\fi\fi
\global\eqlocalversionfalse
}
% \end{macrocode}
% \end{environment}
% \begin{macro}{\pushProblem}
% \begin{macro}{\popProblem}
% There may be an occasion when a multi-part question needs to be broken between parts.
% use the \cs{pushProblem} and \cs{popProblem} for this purpose. The push saves the
% counter value, and ends the \texttt{parts} environment. The pop restarts the
% \texttt{parts}, and resets the parts counter.
% \changes{1.6b}{2006/3/12}
% {
% Added \cs{pushProblem} and \cs{popProblem} to grant the ability to interrupt
% a parts environment for, for example, a multicolumn environment.
% }
%\par\medskip\noindent
%In the example below, we have our parts in a \texttt{multicols} environment, we
%\cs{pushProblem}, close \texttt{multicols}, \cs{popProblem} and continue with
% the multi-parts in single column.
%\begin{verbatim}
%\item Compute $\lim_{x\to2^{\text{$-$}}} f(x)$
%\begin{solution}[1in]\end{solution}
%\pushProblem
%\end{multicols}
%\popProblem
%\item What value(s) of $c$ make the function $f$
%continuous at $x=2$?
%\begin{solution}[.5in]\end{solution}
%\end{parts}
%\end{verbatim}
% \begin{macrocode}
\def\pushProblem{\xdef\nlastItem{\arabic{partno}}\end{parts}}
\def\popProblem{\begin{parts}\setcounter{partno}{\nlastItem}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macrocode}
\def\lastPageTotal{0pt}
\def\marginparafterhook{\xdef\lastPageTotal{\the\pagetotal}}
\def\manualcalcparts#1{%
\expandafter\prob@Arg#1ea\end
\ifx\argii\@empty\edef\numpoints{#1}%
% \end{macrocode}
% Total points specified, we should ignore any \cs{PTs} commands.
% \begin{macrocode}
\let\eqe@pointsPartsId0%
\else\gdef\probpointseach{x}\let\eqe@pointsPartsId2%
% \end{macrocode}
% Points each specified
% \begin{macrocode}
\setcounter{eq@count}{\value{eqquestionnoi}}%
\addtocounter{eq@count}{1}\expandafter
\ifx\csname prob\thisexamlabel.\theeq@count\endcsname\relax
\def\numpoints{\argi}%
\else
\def\numpoints{\expandafter
\csname prob\thisexamlabel.\theeq@count\endcsname}%
\fi
\fi
\ifx\marginpoints\@empty
% \end{macrocode}
% no points for this exam
% \begin{macrocode}
\else
\ifx\argi\@empty
% \end{macrocode}
% no points for this problem specified
% \begin{macrocode}
\let\marginpoints\@empty
\else
% \end{macrocode}
% points to be displayed in margins or inline, if \cs{NoPoints} not specified
% \begin{macrocode}
\ifx\argii\@empty
% \end{macrocode}
% \paragraph*{Total points specified}
% \begin{macrocode}
\ifx\marginpoints\@empty\else
\if\@isitstar1%
% \end{macrocode}
% Points to appear ``in-line'' rather than in the margins
% \begin{macrocode}
\addtocounter{eqpointvalue}{#1}%
\@marktotalvalue
\def\marginparafterhook{\itemPTsFormated{%
\itemPTsTxt{\numpoints}}\space}\else
\def\marginparpriorhook{\noindent
\probvalue{\numpoints}{0}}%
\fi
\fi
\else
% \end{macrocode}
% \paragraph*{Points each specified}
% \begin{macrocode}
\ifx\marginpoints\@empty\else
\if\@isitstar1%
% \end{macrocode}
% Points to appear ``in-line'' rather than in the margins
% \begin{macrocode}
\def\marginparafterhook{%
\itemPTsFormated{\itemPTsEaTxt{\argi}}\space}%
\else
\def\marginparpriorhook{\noindent
\marginpoints{\numpoints}{\argi}}%
\fi
\edef\eqp@rtc@lcm@rk{\noexpand
\addtocounter{eqpointvalue}{\argi}%
\noexpand\@marktotalvalue}%
\fi
\fi
\fi
\fi
\ifnum\value{eq@count}=1\relax
\immediate\write\@auxout{\string\expandafter\string\gdef\string
\csname\space pagenofirstprob\thisexamlabel\string\endcsname
{\thepage}}%
\else
\goodbreak
\fi
}
\def\autocalcparts{%
\setcounter{eq@count}{\value{eqquestionnoi}}%
\addtocounter{eq@count}{1}%
\expandafter
\ifx\csname prob\thisexamlabel.\theeq@count\endcsname\relax
\def\numpoints{0}% assume zero points until we get the total
\else
\edef\numpoints{\expandafter
\csname prob\thisexamlabel.\theeq@count\endcsname}%
\fi
\ifx\marginpoints\@empty\else
\if\@isitstar1%
\def\marginparafterhook{%
\itemPTsFormated{\itemPTsTxt{\numpoints}}\space}\else
\def\marginparpriorhook{%
\noindent\marginpoints{\numpoints}{0}}%
\fi\fi
\setcounter{eq@count}{0}%
}
% \end{macrocode}
% \begin{macro}{\forproblem}
% \begin{macro}{\foritem}
% When typing solutions from assigned problems in a textbook, the problems
% assigned are not consecutive. You can set the problem number before the problem
% environments by using the \cs{forproblem} command. The one required argument is
% the problem number: \verb!\forproblem{10)!.
% \changes{v1.6h}{2007/01/24}
% {
% Added \cs{forproblem}, \cs{foritem}, \cs{aNewPage}
% }
% \begin{macrocode}
\newcommand{\forproblem}[1]{\setcounter{eqquestionnoi}{#1 - 1}}
% \end{macrocode}
% A similar comment for \cs{item}. These are useful for making out solution
% sets to homework assignments where problems are assigned from the textbook
% and you want to give a solution to problem 12, part (b), An example of usage is
%\begin{verbatim}
%\forproblem{12}
%\begin{problem*}
%Factor each.
%\begin{parts}
% \foritem{b} $ x^2 + 2x + 1 = ( x + 1 )^2 $
% \item $ x^2 - x - 2 = ( x - 2 )( x + 1) $ % this is part (c)
% \foritem{e} $ x^2 + 7x + 10 = ( x - 2 )( x + 7) $
% \item ... % this will be part (f)
%\end{parts}
%\end{problem*}
%\end{verbatim}
% \begin{macrocode}
\newcommand{\foritem}[1]{%
\setcounter{partno}{0}%
\lowercase{\def\eq@selectedItem{#1}}%
\let\eq@initLoop=0
\loop
\stepcounter{partno}%
\expandafter\if\alph{partno}\eq@selectedItem
\let\eq@initLoop=1
\fi
\if\eq@initLoop0\repeat
\addtocounter{partno}{-1}%
\item
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% The command \cs{eqe@insertContAnnot} attempts to insert a string just prior
% to a part, if that part begins a new page. To get it right, it promotes a new
% page using the default of .25in. The optional parameter allows you to insert
% a new value; this may be needed to get the string \cs{annotContStr} placed properly.
% The commands
% \begin{macro}{\annotContStr}
% \changes{v3.0l}{2011/08/22}{Defined \cs{eqe@insertContAnnot} and related commands}
% The string that is typeset by the \cs{eqe@insertContAnnot} command.
% \begin{macro}{\acvspace}
% User access to changing the vertical spacing \cs{promoteNewPage} uses within
% \cs{eqe@insertContAnnot}.
% \begin{macro}{\resetacvspace}
% Resets the vertical spacing back to its default.
% \begin{macrocode}
\newcommand{\annotContStr}{%
\textbf{Problem~\eqeCurrProb\space continued.}}
\newcommand{\acvspace}[1]{\def\ic@vspace{#1}}
% \end{macrocode}
% \DescribeMacro{\ic@vspacedefault} is the default vertical spacing used
% by \cs{eqe@insertContAnnot}
% \begin{macrocode}
\newcommand{\ic@vspacedefault}{.25in}
\newcommand{\resetacvspace}{\edef\ic@vspace{\ic@vspacedefault}}
\resetacvspace
% \end{macrocode}
% \cs{eqe@insertContAnnot} promotes a new page, and if the current
% page is different than the starting page, \cs{eq@currProbStartPage}, we
% insert \cs{annotContStr}.
% \begin{macrocode}
\newcommand{\eqe@insertContAnnot}{\promoteNewPage[\ic@vspace]%
\ifnum\arabic{page}>\eq@currProbStartPage
\xdef\eq@currProbStartPage{\arabic{page}}%
{\settowidth{\eq@tmplength}{\parts@indent\eqe@prtsepPrb}%
\xdef\eqe@partsIndent{\the\eq@tmplength}}%
\noindent\hspace*{-\eqemargin}\hspace{-\eqe@partsIndent}%
\annotContStr\medskip
\fi
}
\let\insertContAnnot\eqe@insertContAnnot
% \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\turnContAnnotOff}
% \begin{macro}{\turnContAnnotOn}
% Turn off and on this feature. The default is on.
% \begin{macrocode}
\newcommand{\@gobbloptone}[1][]{}
\newcommand{\turnContAnnotOff}{\global\let\eq@insertContAnnot\relax}
\newcommand{\turnContAnnotOn}{%
\global\let\eq@insertContAnnot\eqe@insertContAnnot}
\turnContAnnotOff
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\aNewPage}
% \begin{macro}{\qNewPage}
% A simple command for inserting \cs{newpage}, only if the \cs{answerkey}
% option has been taken.
% \changes{v1.6h}{2007/01/24}
% {
% Added \cs{aNewPage} and \cs{qNewPage}
% }
% \begin{macrocode}
\newcommand\aNewPage{\ifanswerkey\newpage\fi}
\newcommand\qNewPage{\ifanswerkey\else\newpage\fi}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\OnBackOfPage}
%
% In an effort to make maximum use of the paper, I sometimes ask the
% students to solve the problem on the back of a page. The following
% command is an automated instruction. Generally, we work on the back
% of the previous page, unless we are on page 1, in this case we work
% on the back of page 1.
%
% \begin{macrocode}
\newcounter{backofpage}
\newcommand\bopText{on the back of page~\boPage}
\newcommand\bopCoverPageText{\space(the cover page)}
\newcommand\OnBackOfPage[1][\bopText]{%
\refstepcounter{backofpage}\label{bop\thebackofpage}
\begingroup
\expandafter\ifx\csname r@bop\thebackofpage\endcsname\relax
\def\boPage{??}%
\else
\edef\temp{\csname r@bop\thebackofpage\endcsname}%
\ifx\hyper@anchor\@undefined
\edef\boPage{\expandafter\@secondoftwo\temp}%
\else
\edef\boPage{\expandafter\@secondoffive\temp}%
\fi
\c@eq@count\boPage
\advance\c@eq@count-1\relax
% \end{macrocode}
% If on page 1, we work on the back of page 1, otherwise, we work on the
% back of the previous page.
% \begin{macrocode}
\edef\boPage
{%
\ifx\eqex@coverpage\relax
\expandafter\ifnum\value{eq@count}=0\relax
1%
\else
{\theeq@count}%
\fi
\else
\ifnum\value{eq@count}=1\relax
{\theeq@count}\bopCoverPageText
\else
{\theeq@count}%
\fi
\fi
}%
\fi
#1%
\endgroup
}
% \end{macrocode}
% \end{macro}
%
%\subsection{Vertical Space Filling Options}
%
% When the \texttt{nosolutions} or the \texttt{vspacewithsolns} is used, a
% vertical space is generated by the \texttt{solution} environment.
% Previously, this has just been a vertical white space, now, we provide
% the ability to fill the space with horizontal rules of different types.
% Below is the implementation of this.
% \begin{macro}{\eqWriteLineColor}
% The color of the rule to use.
% \begin{macrocode}
\newcommand{\eqWriteLineColor}[1]{\def\eq@WriteLineColor{#1}}
\eqWriteLineColor{gray}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\eqWLSpacing}
% The line spacing between the rules.
% \begin{macrocode}
\newcommand{\eqWLSpacing}[1]{\def\eq@WLSpacing{#1}}
\eqWLSpacing{14pt}
% \end{macrocode}
% \end{macro}
% \paragraph*{Fill Types.} We have three types of line fill:
% \cs{hrulefill}, \cs{dotfill}, and a custom rule \cs{eqdashrulefill}.
% The commands three \cs{eqWriteLineFill}, \cs{eqWriteLineDots}, and
% \cs{eqWriteLineDashFill} implements these three types. They are
% \cs{let} to \cs{eqWriteLine}, which is used in \cs{vspaceFillerLines}.
% \begin{macrocode}
\newcommand{\eqWriteLineFill}{%
\textcolor{\eq@WriteLineColor}{\hrulefill}}
\newcommand{\eqWriteLineDots}{%
\textcolor{\eq@WriteLineColor}{\dotfill}}
\def\eqdashrulefill{\leavevmode
\cleaders\hb@xt@ .44em{\hss\rule{.22em}{.4pt}\hss}\hfill\kern\z@}
\newcommand{\eqWriteLineDashFill}{%
\textcolor{\eq@WriteLineColor}{\eqdashrulefill}}
\newcommand{\vspaceFillerLines}[1]{\offinterlineskip
\parindent0pt\relax\parskip0pt\relax
\@tempdima\eq@WLSpacing\relax
\@whiledim\@tempdima<#1\relax\do{\vspace{\eq@WLSpacing}\eqWriteLine
\addtolength{\@tempdima}{.4pt+\eq@WLSpacing}\par}%
\vfill
}
% \end{macrocode}
% \begin{macro}{\useFillerLines}
% When used, the vertical space is written with lines (rules, dashes, dots).
%\changes{v2.0e}{2011/03/07}
%{%
% Added the feature of filling the vertical space with ruled lines of
% different types. This feature is available for paper options and for
% \texttt{nosolutions} and \texttt{vspacewithsolution} options.
%}
% \begin{macrocode}
\newcommand{\useFillerLines}{\let\vspaceFiller\vspaceFillerLines}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\useFillerDefault}
% Resets the vertical space to the original white space.
% \begin{macrocode}
\newcommand{\useFillerDefault}{\let\vspaceFiller\vspaceFillerDefault}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\fillTypeHRule}
% Writes the line as a solid line (\cs{hrulefill}).
% \begin{macrocode}
\newcommand{\fillTypeHRule}{\let\eqWriteLine\eqWriteLineFill}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\fillTypeDots}
% Writes the line as a dotted line (\cs{dotfill}).
% \begin{macrocode}
\newcommand{\fillTypeDots}{\let\eqWriteLine\eqWriteLineDots}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\fillTypeDashLine}
% Writes the line as a dotted line (\cs{eqdashrulefill}).
% \begin{macrocode}
\newcommand{\fillTypeDashLine}{\let\eqWriteLine\eqWriteLineDashFill}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\fillTypeDefault}
% Resets fill type back to the default, \cs{hrulefill}.
% \begin{macrocode}
\newcommand{\fillTypeDefault}{\let\eqWriteLine\eqWriteLineFill}
% \end{macrocode}
% \end{macro}
% Set the \textsf{eqexam} page style.
% \begin{macrocode}
\ifeqfortextbook\else\pagestyle{eqExamheadings}\fi
% \end{macrocode}
% \begin{macrocode}
%
%<*textbook>
% \end{macrocode}
%
% \section{Concerning the \texttt{fortextbook} option}
%
% What are my goals/desired features? Modern (U.S.) textbooks---at least
% the ones I'm familiar with---consist of some or all of the following
% resources:
% \begin{itemize}
% \item \textbf{Student Edition}: Answers to odd-numbered problems
% appear in the back of the text.
% \item[] We need to have a scheme where odd-numbered problems, under suitable options,
% are compiled. \textbf{Goal:} It does not need to be restricted to odd-numbered, however, need to latex only
% those problems that meet the ``include'' criteria.
% \item[] For chapter review problem sets, odd-number problems are have solutions in the
% back of the book.
% \item[] For chapter quizzes, odd-numbered (optionally all) solutions
% are in the back of the book.
%
% \item \textbf{Instructor Edition}: Answers to all problems appear in
% the back of the book. Answers may also appear in the body of the text,
% in the margins of the text, or immediately after the statement of the
% problem. If the answer is too long, there is a cross-reference to the
% solution in the appendix.
% \item[] Some publishers I've seen have wide margins where additional material can be inserted
% (historical sketches, instructor notes, pictures, etc.). In these margins, the answers to the problems
% can appear. Other publishers put answer immediately
% following the questions. The latter is easy to do; just have a macro, say \verb!\ANS{$12.5$}!, which only
% expands when the ``instructor'' option is used.
% \item \textbf{Student Solution Manual}: Contains solutions to all
% odd-problems, as well as any review problems and chapter quizzes.
% Some publishers include all solutions to chapter quizzes.
% \item[] A solution manual is a separate publication. This document would be
% created by latexing one or more of the auxiliary file (\texttt{.sol})
% These files might have to be edited before the final compile. We include only the solutions
% that meet the include criteria (i.e., odd-numbered ones).
% \item[] The current features of \textsf{eqexam} is what is needed here. The authors need only
% include solutions to each problem in a \texttt{solution} environment. Now, I realize that often times
% the authors create the solutions, but someone else, possibly a grade student or contractor, solves the problems.
% In the latter case, the authors would probably not like to turn over the source files to the one solving and typesetting
% the problems.
% \item \textbf{Instructor Solution Manual}: Contains solutions to all
% problems, review problems, chapter quizzes.
% \item[] Similar comments for the instructor solution manual.
% \end{itemize}
% Some other thoughts by a contributor:
% \begin{itemize}
%\item Often there is a diagram or graphic within the problem -- this has
% some figure caption and after the running counter of the figure it is
% named the NUMBER of the problem (cross-reference to the problem number)
%
%\item Often the probs with soln are setup in two-column style.
%
%\item Often the PROBLEM NUMBER has a special formatting (not only bold and
% black), maybe with a colorframebox around or some special formatting
% from the author
%
%\item Of course I have seen in some EXAMPLES that there is a wide margin
% to put in additional graphics etc. setup in two-side style -- wide left
% margin on even pages, wide right margins on odd pages. Here as well
% are captions setup and cross-references.
%\end{itemize}
%
%\subsection{Setting options with \texorpdfstring{\cs{textbookOpts}}{\textbackslash{textbookOpts}}}
% \begin{macro}{\textbookOpts}
% \begin{macro}{marginans}
% \begin{macro}{inlineans}
% \begin{macro}{marginsonleft}
% \begin{macro}{ssols}
% \begin{macro}{lsols}
% We set up a command for setting the options for the \texttt{fortextbook} option.
% \begin{macrocode}
\define@boolkey{eqe@tbopts}[is]{instred}[true]{}
\define@boolkey{eqe@tbopts}[is]{studented}[true]{%
\ifisstudented
% \end{macrocode}
% Now let's try to filter out the even-numbered problems for the student edition.
% \begin{macrocode}
\tbfilterOutEvenNums
% \end{macrocode}
% The above command is normally \cs{let} to \cs{@gobble}.
% \begin{macrocode}
\fi
}
% \end{macrocode}
% This code is executed in \cs{exambegdef}, the start up code of the \texttt{exam} environment.
% This enables problems with fill-ins, true/false, or multiple choice, to have the answer appear
% in the space provided.
% \begin{macrocode}
\def\tb@beginexam@code{%
\ifisinstred\answerkeytrue\eq@proofingtrue\fi}
% \end{macrocode}
% \verb!\eqEXt{\theeqquestionnoi}! and \verb!\endeqEXt\tok1\tok2! enclose each
% solution, \cs{tbfilterOutEvenNums} redefines \cs{eqEXt} to gobble everything,
% when the page number is even, through \cs{endeqEXt} and the two tokens it follows.
% This leaves only the odd-numbered problems.
% \begin{macrocode}
\newcommand{\tbfilterOutEvenNums}{%
\def\eqEXt##1{\ifodd##1\let\eqe@next\relax\else
\def\eqe@next{\gobbletoEndeqExt}\fi\eqe@next}%
}
\newcommand{\tballowAllNums}{%
\let\eqEXt\@gobble
\let\endeqEXt\relax
}
\define@boolkey{eqe@tbopts}[is]{marginans}[true]{}
\define@boolkey{eqe@tbopts}[is]{inlineans}[true]{}
\define@boolkey{eqe@tbopts}[]{marginsonleft}[true]
% \end{macrocode}
% If margins are always on left, we turn off switching of margin notes
% as placed by \cs{marginpar}, and use \cs{reversemarginpar} to get them
% on the left.
% \begin{macrocode}
{\@mparswitchfalse\reversemarginpar}
\define@boolkey{eqe@tbopts}[show]{ssols}[true]{}
\define@boolkey{eqe@tbopts}[show]{lsols}[true]{%
\ifshowlsols\let\tb@soln@choice\tb@showlsols\fi}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% The default settings are \texttt{true} for \texttt{studented} and
% \texttt{false} for \texttt{instred}.
%
% \begin{macrocode}
\newcommand{\textbookOpts}[1]{\setkeys{eqe@tbopts}{#1}%
% \end{macrocode}
% We do not allow both \texttt{instred} and \texttt{studented} to be true.
% \begin{macrocode}
\ifisinstred\global\isstudentedfalse\else
\ifisstudented\global\isinstredfalse
\fi\fi
}
% \end{macrocode}
% As mentioned above, the default settings are \texttt{true} for \texttt{studented} and
% \texttt{false} for \texttt{instred}.
% \begin{macrocode}
\isstudentedtrue
\isinstredfalse
\ismarginansfalse
\isinlineansfalse
% \end{macrocode}
% The command is available only in the preamble.
% \begin{macrocode}
\@onlypreamble{\textbookOpts}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\turnOffMarAnsOnAnsInline}
% \begin{macro}{\turnOnMarAnsOffAnsInline}
% \begin{macro}{\toggleInstrAns}
% These three command may not be useful in the creation of a textbook, but
% you never know, I used them in my demo doc \texttt{fortextbook.tex} to turn
% off and on the display of the answers (change margin to inline, change inline to margin,
% and toggle margin and inline).
% \begin{macrocode}
\newcommand{\turnOffMarAnsOnAnsInline}{%
\global\ismarginansfalse\global\isinlineanstrue
\insMidMarg{\global\ismarginansfalse
\global\isinlineanstrue}%
}
\newcommand{\turnOnMarAnsOffAnsInline}{%
\global\ismarginanstrue\global\isinlineansfalse
\insMidMarg{\global\ismarginanstrue
\global\isinlineansfalse}%
}
\newcommand{\toggleInstrAns}{%
\ifisinstred\ifismarginans
\global\ismarginansfalse\global\isinlineanstrue
\insMidMarg{\global\ismarginansfalse
\global\isinlineanstrue}%
\else
\global\ismarginanstrue\global\isinlineansfalse
\insMidMarg{\global\ismarginanstrue
\global\isinlineansfalse}%
\fi\fi
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{Macros to display answers/shortsolns}
% In this section, we develop some commands to display answers or short solutions. These
% would appear if \texttt{instred=true}, in-line, or in the margins.
% \begin{macro}{\ANS}
% Let us begin by creating a simple macro for saving an answer. The answer is displayed ``in-line.''
% No verbatim-type text allowed, no unbalanced braces unless escaped. \cs{ANS} displays the answer
% if the \texttt{instred} option of the \texttt{eqe@tbopts} family, i.e., by executing
% \begin{macrocode}
\newcommand{\ANS}{\@ifstar{\let\tb@istart=1\tb@ANS}
{\let\tb@istart=0\tb@ANS}}
\newcommand{\tb@ANS}[1]{%
\ifisinstred
\ifisinlineans\if\tb@istart0\ANSFmt{\theeqquestionnoi}{#1}\fi\fi
\ifismarginans
\edef\eqe@prehold{\noexpand\par\kern0pt\noindent
\if\probstar*%
\noexpand\begin{eqeList}[\tb@wparts@len]{%
\noexpand\eqedsplyOnlyFrst{\theeqquestionnoi}%
{\thepartno}\noexpand\eqe@hspannerMrg
\noexpand\makebox[\noexpand\tbmrgpartwdth]%
{\noexpand\tb@mrgPartFmt{\thepartno}}}%
\else
\noexpand\begin{eqeList}%
{\noexpand\tb@mrgDigitFmt{%
\theeqquestionnoi\eqe@decPointMrg}}%
\fi
}\expandafter\insMidMarg%
\expandafter{\eqe@prehold#1\end{eqeList}}%
\fi
\fi
}
% \end{macrocode}
% \begin{environment}{eqeList}
% An environment used to format the answers in the margins, when
% \texttt{marginans} is in effect.
% \begin{macrocode}
\newenvironment{eqeList}[2][\tb@woparts@len]{\begin{list}{#2}{%
\def\argi{#1}\setlength{\labelwidth}{#1}%
\ifx\argi\tb@wparts@len
\settowidth{\labelsep}{\eqe@prtsepMrg}\else
\settowidth{\labelsep}{\eqe@hspannerMrg}\fi
\setlength{\leftmargin}{\labelwidth+\labelsep}%
\setlength{\parskip}{0pt}\setlength{\partopsep}{0pt}%
\setlength{\topsep}{1pt}\setlength{\parsep}{0pt}%
\setlength{\itemindent}{0pt}\setlength{\itemsep}{3pt}%
}\item\relax}{\end{list}}
% \end{macrocode}
% \end{environment}
% \paragraph*{Formatting Answers and Solutions}
% \begin{macro}{\mrgDigitFmt}
% Format of the digit (and the decimal point) for the answers in the margins.
%\begin{verbatim}
%\mrgDigitFmt{\textbf{#1}}
%\mrgPartFmt{\textbf{(\hfil#1\hfil)}}
%\setMarIndents[\bfseries\normalsize\normalfont]{00}{(d)}
%\end{verbatim}
% \begin{macrocode}
\newcommand{\mrgDigitFmt}[1]{\def\tb@mrgDigitFmt##1{#1}}
\mrgDigitFmt{#1}
% \end{macrocode}
% \begin{macro}{\mrgPartFmt}
% Format of the part (including possibly the parentheses), example give above.
% \begin{macrocode}
\newcommand{\mrgPartFmt}[1]{\def\tb@mrgPartFmt##1{#1}}
\mrgPartFmt{(\hfil#1\hfil)}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{ANScolor}
% The default color of the answers that appear in the margins or inline.
% \begin{macrocode}
\definecolor{ANScolor}{rgb}{0,0,.8}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\ANSFmt}
% The command that sets the format, may be redefined as needed. Used in the
% \cs{ANS} command above.
% \begin{macrocode}
\newcommand{\ANSFmt}[2]{\textcolor{ANScolor}{#2}}
% \end{macrocode}
% \end{macro}
% We have two environments that we use in three different situations:
%\begin{itemize}
% \item \texttt{eqequestions} environment: (1) Used to control the display of the
% \texttt{probset} environment within the body of the textbook; (2) used
% to control the display of the solutions ``in the back of the book.''
% \item \texttt{eqeList} environment: Used for displaying answers in the margin of
% the book, when the appropriate options allow it.
%\end{itemize}
% We want to be able to manipulate some of the parameters of these three
% situation, independently of each other. There are several issues, setting
% what I have been calling the gutter width, and the display of the problem
% numbers.
%\par\medskip\noindent
% We define four commands for each of the three situations described above. The names
% have a pattern to them, and similarly named commands have the same use.
%
% The numbering of the problems has the pattern: \verb*!dd. (a) !
% We provide convenience commands to give these internal macros values
% \begin{macro}{\prbDecPt}
% \begin{macro}{\prbPrtsep}
% \begin{macro}{\prbNumPrtsep}
% Basic parameters for the problems in the body of the text.
% \begin{macrocode}
\def\eqe@decPointPrb{.} % decimal point of prob number
\def\eqe@prtsepPrb{\ } % prob with parts, space after part
\def\eqe@hspannerPrb{\ } % space after prob number
\newcommand{\prbDecPt}[1]{\def\eqe@decPointPrb{#1}}
\newcommand{\prbPrtsep}[1]{\def\eqe@prtsepPrb{#1}}
\newcommand{\prbNumPrtsep}[1]{\def\eqe@hspannerPrb{#1}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\solDecPt}
% \begin{macro}{\solPrtsep}
% \begin{macro}{\solNumPrtsep}
% Basic parameters for the problems in the solution sets.
% \begin{macrocode}
\def\eqedecPointSoln{.} % decimal point of prob number
\def\eqe@prtsepSoln{\ } % prob with parts, space after part
\def\eqe@hspannerSoln{\ } % space after prob number
\newcommand{\solDecPt}[1]{\def\eqedecPointSoln{#1}}
\newcommand{\solPrtsep}[1]{\def\eqe@prtsepSoln{#1}}
\newcommand{\solNumPrtsep}[1]{\def\eqe@hspannerSoln{#1}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\mrgDecPt}
% \begin{macro}{\mrgPrtsep}
% \begin{macro}{\mrgNumPrtsep}
% Basic parameters for the problems in the margins.
% \begin{macrocode}
\def\eqe@decPointMrg{.} % decimal point of prob number
\def\eqe@prtsepMrg{\ } % prob with parts, space after part
\def\eqe@hspannerMrg{\ } % space after prob number
\newcommand{\mrgDecPt}[1]{\def\eqe@decPointMrg{#1}}
\newcommand{\mrgPrtsep}[1]{\def\eqe@prtsepMrg{#1}}
\newcommand{\mrgNumPrtsep}[1]{\def\eqe@hspannerMrg{#1}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\setMarIndents}
% Sets some dimensions used by the \texttt{eqeList} environment.
% \cs{tb@woparts@len} is calculated and
% is used as the default gutter width in \texttt{eqeList}. \cs{tb@wparts@len}
% is used for the gutter width for the gutter width when there is a problem
% with parts. Finally, \cs{tbmrgpartwdth} in \cs{ANS} and is used for the width
% of a \cs{makebox} that enclosed the part letter.
% \begin{macrocode}
\newcommand{\setMarIndents}[3][\normalsize\normalfont]{{%
\settowidth{\@tempdima}{#1#2\eqe@decPointMrg}%
\xdef\tb@woparts@len{\the\@tempdima}%
\settowidth{\@tempdima}%
{#1#2\eqe@decPointMrg\eqe@hspannerMrg#3}%
\xdef\tb@wparts@len{\the\@tempdima}%
\settowidth{\@tempdima}{#1#3}%
\xdef\tbmrgpartwdth{\the\@tempdima}%
}}
\setMarIndents{00}{(d)}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\setSolnIndent}
% Used to set the some parameters used by \texttt{eqequestions}, in the solutions file.
% \begin{macrocode}
\newdimen\solnGutter
\newcommand{\setSolnIndent}[3][\normalsize\normalfont\bfseries]{%
{\settowidth{\@tempdima}{#1#2\eqedecPointSoln\eqe@hspannerSoln}%
\global\solnGutter=\@tempdima
% \xdef\solnGutter{\the\@tempdima}%
\settowidth{\@tempdima}{#1#3}%
\xdef\tbsolnpartwdth{\the\@tempdima}%
}}
\setSolnIndent{00}{(d)}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\setSolnMargins}
% This command is written to the solution file, and expanded when that file
% is input back in. If \cs{solnGutter} is not \texttt{0pt}, we set the length
% of \cs{eqemargin} using the current value; otherwise, we use the value
% determined by \cs{setSolnIndent}, above.
% \begin{macrocode}
\renewcommand{\setSolnMargins}[1]{%
\ifdim\solnGutter=0pt \setlength\eqemargin{#1}\else
\setlength\eqemargin{\solnGutter}\fi}
%\newcommand{\defaultSolnIndent}{\gdef\solnGutter{0pt}}
\newcommand{\defaultSolnIndent}{\global\solnGutter=0pt}
\defaultSolnIndent
% \end{macrocode}
% \end{macro}
% \begin{macro}{\prbNumFmt}
% \begin{macro}{\solWoPrtsFmt}
% \begin{macro}{\solWPrtsFmt}
% We redefine \cs{exlabelformat}, \cs{exsllabelformat}, and
% \cs{exsllabelformatwp}. They are defined in such a way as
% to simply their modification through a series of simple
% formatting commands. The defaults are
%\begin{verbatim}
%\prbNumFmt{\textbf{#1}}
%\solWoPrtsFmt{\textbf{#1}}
%\solWPrtsFmt{\textbf{#1}}{(\hfil#2\hfil)}
%\end{verbatim}
% \begin{macrocode}
\renewcommand{\exlabelformat}{%
\tbprbNumFmt{\theeqquestionnoi\eqe@decPointPrb}}
% \end{macrocode}
% \cs{prbNumFmt} is the format for the number of the problems
% in the body of the text. The argument \texttt{\#1} is a symbolic
% argument for the question number.
% \begin{macrocode}
\newcommand{\prbNumFmt}[1]{\def\tbprbNumFmt##1{#1\eqe@hspannerPrb}}
\prbNumFmt{\textbf{#1}}
% \end{macrocode}
% Redefine \cs{exsllabelformat}, and \cs{exsllabelformatwp}
% \begin{macrocode}
\renewcommand{\exsllabelformat}{\string\tbsolWoPrtsFmt{%
\theeqquestionnoi\string\eqedecPointSoln}}
\renewcommand{\exsllabelformatwp}{\string\tbsolWPrtsFmt%
{\string\eqedsplyOnlyFrst{\theeqquestionnoi}{\thepartno}}%
{\thepartno}%
}
% \end{macrocode}
% \cs{solWoPrtsFmt} is the format for the number of the problems
% in the solution set. The argument \texttt{\#1} is a symbolic
% argument for the question number. \cs{solWPrtsFmt} is the format
% for a problem with parts in the solution file. \texttt{\#1} is
% symbolically the question number, and \texttt{\#2} is a
% symbolic for the part letter.
% \begin{macrocode}
\newcommand{\solWoPrtsFmt}[1]{\def\tbsolWoPrtsFmt##1{%
\makebox[0pt][r]{#1\eqe@hspannerSoln}}}
\solWoPrtsFmt{\textbf{#1}}
\newcommand{\solWPrtsFmt}[2]{\def\tbsolWPrtsFmt##1##2{%
\makebox[0pt][r]{#1\eqe@hspannerSoln}%
\makebox[\tbsolnpartwdth][l]{#2}\eqe@prtsepSoln%
}}
\solWPrtsFmt{\textbf{#1}}{(\hfil#2\hfil)}
% \end{macrocode}
% An alternate definition for \cs{solWPrtsFmt}, used by \cs{hangSolWPrtsFmt}.
% \begin{macrocode}
\newcommand{\solWPrtsFmt@hang}[2]{%
\def\tbsolWPrtsFmt##1##2{%
\makebox[0pt][r]{#1\eqe@prtsepSoln%
\makebox[\tbsolnpartwdth][l]{#2}\eqe@hspannerSoln}%
}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\hangSolWPrtsFmt}
% The command takes two arguments, the same as \cs{solWPrtsFmt}. When this
% command is executed in the preamble, we get hanging indentation for problems
% with parts.
%\changes{v3.0g}{2011/08/15}{Use this to use ``hanging indentation'' for the
% parts for problems with parts in the solutions file.}
% \begin{macrocode}
\let\bpartsmrk\relax
\let\epartsmrk\relax
\newcommand{\hangSolWPrtsFmt}[2]{%
% \end{macrocode}
% At the beginning and ending of a parts environment, we begin and end
% a special \texttt{eqepartsquestions} environment, designed to give
% the desired indentation.
% \begin{macrocode}
\def\prior@parts@hook{%
\writeToSolnFile{^^J\protect\bpartsmrk}}%
% \writeToSolnFile{\protect\begin{eqepartsquestions}}}%
\def\post@parts@hook{%
\writeToSolnFile{\protect\epartsmrk^^J}}%
% \writeToSolnFile{\protect\end{eqepartsquestions}}}%
\def\bpartsmrk{\begin{eqepartsquestions}}%
\def\epartsmrk{\end{eqepartsquestions}}%
% \end{macrocode}
% We must also redefine \cs{solWPrtsFmt} by letting it to
% \cs{solWPrtsFmt@hang}, then executing it using the parameters passed.
% \begin{macrocode}
\let\solWPrtsFmt\solWPrtsFmt@hang
\solWPrtsFmt{#1}{#2}%
}
\@onlypreamble\hangSolWPrtsFmt
% \end{macrocode}
% \end{macro}
% Define some switches, token registers, and boxes for managing
% the answers and marginal notes.
% \begin{macrocode}
\newif\ifexamenv \examenvfalse
\newif\iffirstemit \firstemittrue
\newtoks\txtbkt@ks \txtbkt@ks={}
\newtoks\txtbkt@ksi \txtbkt@ksi={}
\newbox\txtbkb@xb@t
\newbox\txtbkb@xt@p
\newbox\txtbkb@xh@ld
\let\tbTopMargin\relax
\let\tbBotMargin\relax
\long\def\tb@addtoTopMargin#1{\txtbkt@ksi={#1}%
\edef\eqe@tmphold{\the\txtbkt@ksi\the\txtbkt@ks}%
\global\txtbkt@ks=\expandafter{\eqe@tmphold}%
}
\newcommand{\tb@addtoMargin}[1]{%
\edef\eqe@tmphold{\the\txtbkt@ks}%
\global\txtbkt@ks=\expandafter{\eqe@tmphold#1}%
}
% \end{macrocode}
% As my first attempt, let's create two comment environmets to be used within
% the \texttt{solution} environment.
%\begin{verbatim}
%\begin{solution}
%\begin{ssol}
%
%\end{ssol}
%\begin{lsol}
%
%\end{lsol}
%\end{solution}
%\end{verbatim}
% The control of these environments are made through
% \begin{environment}{lsol}
% \begin{macro}{\tb@showlsols}
% Place full (or long) solutions in this environment.
% \begin{macrocode}
\newcommand{\tb@showlsols}{\includecomment{lsol}\excludecomment{ssol}}
% \end{macrocode}
% \end{macro}
% \end{environment}
% \begin{environment}{ssol}
% \begin{macro}{\tb@showssols}
% Place short solutions in this environment.
% \begin{macrocode}
\newcommand{\tb@showssols}{\includecomment{ssol}\excludecomment{lsol}}
% \end{macrocode}
% \end{macro}
% \end{environment}
% The default is to show the short solutions.
% \begin{macrocode}
\let\tb@soln@choice\tb@showssols
%\let\tb@sols@choice\tb@showssols
% \end{macrocode}
% \subsection{Marginal Matter.} There are three levels in the margins:
% \begin{enumerate}
% \item \textbf{Top level}: This is a command \cs{tbTopMargin} with may be
% redefined between pages. It should have the width of the \cs{parbox}
% that contains all the content of the margin, this width is \cs{tb@marparboxwidth}
% (\texttt{\cs{oddsidemargin}-\cs{marginparsep}}). The content \emph{must} be
% unbreakable across pages. The content of \cs{tbTopMargin} will appear \emph{on
% every page subsequent to its definition}.
% \item[] \DescribeMacro{\clearTopMargin} We can clear the top level using the following command
% \begin{macrocode}
\newcommand{\clearTopMargin}{\global\let\tbTopMargin\relax}
% \end{macrocode}
% \item[] Clearing will take effect on the following page.
% \item[] \DescribeMacro{\setTopMargin} As a convenience macro, we can create top margin content.
% Redefinitions will appear on the next page from where the definition was made.
% \begin{macrocode}
\newcommand{\setTopMargin}[1]{\gdef\tbTopMargin{#1}%
\gdef\tbSaveTopMargin{#1}}
\let\tbTopMargin\@empty
\let\tbSaveTopMargin\@empty
% \end{macrocode}
% \item \textbf{Middle level}: The middle level is the most interesting. You write to it
% using \cs{insMidMarg}. Normally, this is text. If there is too much text,
% it will be split off and placed in the middle level of the next page. The command
% \cs{ANS} also writes to the middle level when the \texttt{instred} and \texttt{marginans} options are
% taken.
% \item \textbf{Bottom level}: This is similar to the top level, but on the bottom. The
% command is named \cs{tbBotMargin} and follows the same rules as \cs{tbTopMargin}.
% Again, the content of \cs{tbBotMargin} will appear \emph{on every
% page subsequent to its definition}.
% \item[] \DescribeMacro{\clearBotMargin} We can clear the bottom level using the following command
% \begin{macrocode}
\newcommand{\clearBotMargin}{\global\let\tbBotMargin\relax}
% \end{macrocode}
% \item[] Clearing will take effect on the following page.
% \item[] \DescribeMacro{\setBotMargin} As a convenience macro, we can create bottom margin content.
% Redefinitions will appear on the next page from where the definition was made.
% \begin{macrocode}
\newcommand{\setBotMargin}[1]{\gdef\tbBotMargin{#1}%
\gdef\tbSaveBotMargin{#1}}
\let\tbBotMargin\@empty
\let\tbSaveBotMargin\@empty
% \end{macrocode}
% \begin{macrocode}
\newcommand{\restoreLastTopMargin}{\expandafter\setTopMargin
\expandafter{\tbSaveTopMargin}}
\newcommand{\restoreLastBotMargin}{\expandafter\setBotMargin
\expandafter{\tbSaveBotMargin}}
% \end{macrocode}
% \end{enumerate}
%
% \begin{macro}{\insMidMarg}
% \cs{insMidMarg} is a \cs{parbox} that will hold the material in the margin.
% \begin{macro}{\MarParBoxFmt}
% The formatting for the marginal \cs{parbox}
% \begin{macrocode}
\newcommand{\MarParBoxFmt}{\normalsfcodes
\normalfont\normalsize\normalbaselines\parindent0pt
\vbadness\@Mi \hbadness5000 \tolerance9999
\parskip0pt\raggedright %\spaceskip=0pt\xspaceskip=0pt
\setlength{\linewidth}{\tbmarparboxwidth}%
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\tbmarparboxwidth}
% The width of the margin box. Initial value of \texttt{1sp}, if the user does not
% reset the value, it is a package error.
% \begin{macrocode}
\newlength\tbmarparboxwidth
\setlength\tbmarparboxwidth{1sp}
% \end{macrocode}
% \end{macro}
% \begin{macro}{MidMargcolor}
% The default color of text of the middle level
% \begin{macrocode}
\definecolor{MidMargcolor}{rgb}{0,0,.8}
\newcommand{\midMargFmt}[1]{%
\def\tb@midMargFmt{\normalfont\normalsize\normalcolor#1}}
\midMargFmt{\color{MidMargcolor}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\eqe@MarParBox}
% This is the actual \cs{parbox} that holds the marginal material. I have two versions
% of this box, the first one has height \cs{textheight}, the second one has height
% \texttt{\cs{textheight}+\cs{footskip}}.
% \begin{macrocode}
%\def\eqe@MarParBox#1{\parbox[b][\textheight][t]%
% {\tbmarparboxwidth}{\color{MidMargcolor}#1}}
\def\eqe@MarParBox#1{\lower\footskip\hbox{%
\leavevmode\parbox[b][\textheight+\footskip][t]%
{\tbmarparboxwidth}{\tb@midMargFmt#1}}} %
% \end{macrocode}
% \end{macro}
% Finally, we get to the \cs{insMidMarg}, this is used to write to the middle
% level.
% \begin{macrocode}
\newcommand{\insMidMarg}[1]{%
\let\eqe@margininsert\@empty
\expandafter\tb@addtoMargin\expandafter{\eqe@margininsert#1}%
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\tbPreMarginHeader}
% Executed prior to the marginal heading
% \begin{macro}{\tbPostMarginHeader}
% Executed after the marginal heading
% \begin{macro}{HEADERcolor}
% Default color of a marginal header
% \begin{macro}{\tbMarginHeaderFmt}
% Formatting for a marginal header.
% \begin{macrocode}
\newcommand\tbPreMarginHeader{\par\penalty-200\vskip0pt plus 24pt
\kern3pt\noindent\strut}
\newcommand\tbPostMarginHeader{\par\nobreak\vskip0pt}
\definecolor{HEADERcolor}{named}{black}
\newcommand\tbMarginHeaderFmt[1]{\textcolor{HEADERcolor}{\textbf{#1}}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\insMargHead}
% Used to insert a general marginal heading into the middle level. The
% optional parameter allows you to set a mark.
%
% \begin{macro}{\insProbHead}
% Used to insert a marginal heading for a problem set into the middle level.
% The optional parameter allows you to insert a mark, the default mark is
% \verb!#1 \tbcontinued!.
% \begin{macrocode}
\newcommand{\insMargHead}[2][]{%
\protected@edef\temp@exp{\noexpand
\insMidMarg{\noexpand\tb@marginHeader{#1}{#2}}}\temp@exp
}
\newcommand{\insProbHead}[2][]{%
\def\tb@argi{#1}\ifx\tb@argi\@empty
\protected@xdef\currProbHead{#2 \tbcontinued}\else
\protected@xdef\currProbHead{#1}\fi
\ifisinstred\ifismarginans
\insMidMarg{\tb@marginProbHeader{#1}{#2}}\fi\fi
}
\newcommand{\tb@marginProbHeader}[2]{%
\def\tb@argi{#1}\ifx\tb@argi\@empty
\tb@marginHeader{#2 \tbcontinued}{#2}\else
\tb@marginHeader{#1}{#2}\fi
}
\newcommand{\tb@marginHeader}[2]{\tbPreMarginHeader
\tbMarginHeaderFmt{#2}\def\tb@argi{#1}\ifx\tb@argi\@empty
\mark{#2}\else\mark{#1}\fi\tbPostMarginHeader
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\tbcontinued}
% The continue annot that appear when a problem set flows over to the next page.
% \begin{macrocode}
\newcommand{\tbcontinued}{(cont.)}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\tbplaceMargins}
% Redefine this macro to set the locations of the margins we are writing to.
% \begin{macrocode}
\newcommand{\marparboxwidth}[1]{%
\setlength\tbmarparboxwidth{#1}%
\setlength{\marginparwidth}{\tbmarparboxwidth}%
\tbMakeFinalCalcs
}
\@onlypreamble\marparboxwidth
\newcommand{\chkmarginboxwidth}{%
\ifdim\tbmarparboxwidth=1sp \PackageError{eqexam}%
{You have not set the value of\MessageBreak
\string\marparboxwidth}%
{Define the \string\marparboxwidth\space command}\fi
}
% \end{macrocode}
% \begin{macro}{\ifmarginsonleft}
% A Boolean switch, if true, all margins are on the left; otherwise, they alternate
% \begin{macrocode}
\newif\ifmarginsonleft \marginsonleftfalse
% \end{macrocode}
% \end{macro}
% \begin{macro}{\tbSetupForMargins}
% We compute \cs{oddsidemargin}, \cs{evensidemargin}, and \cs{textwidth}
% \begin{macrocode}
\newcommand{\tbSetupForMargins}{%
\ifmarginsonleft
\setlength{\oddsidemargin}{\tbmarparboxwidth+\marginparsep}%
\setlength{\evensidemargin}{\oddsidemargin}%
\setlength{\textwidth}{\paperwidth-2in-\oddsidemargin}%
\else
\setlength{\oddsidemargin}{0pt}%
\setlength{\evensidemargin}{\tbmarparboxwidth+\marginparsep}%
\setlength{\textwidth}{%
\paperwidth-2in-\oddsidemargin-\evensidemargin}%
\fi
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\tbplaceMargins}
% We calculate the coordinates of the lower left hand corner of the margin \cs{parbox}
% depending on the value of \cs{ifmarginsonleft}.
% \begin{macrocode}
\newcommand{\tbplaceMargins}{{%
\setlength{\@tempdima}{%
\paperheight-1in-\topmargin-\headheight-\headsep-\textheight}%
\xdef\@evenlly{\strip@pt\@tempdima}%
\xdef\@oddlly{\@evenlly}%
\setlength{\@tempdima}{1in}%
\xdef\@evenllx{\strip@pt\@tempdima}%
\ifmarginsonleft\else
\setlength{\@tempdima}{1in+\textwidth+\marginparsep}\fi
\xdef\@oddllx{\strip@pt\@tempdima}%
}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\tbMakeFinalCalcs}
% Executed by \cs{marparboxwidth}
% \begin{macrocode}
\newcommand{\tbMakeFinalCalcs}{%
\tbSetupForMargins
\tbplaceMargins
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\tbminskipbtnlayers}
% \cs{tbminskipbtnlayers} is the minimum skip between layers (top, middle, bottom)
% Executed by \cs{marparboxwidth}
% \begin{macrocode}
\newlength\tbminskipbtnlayers
\setlength{\tbminskipbtnlayers}{6pt}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
\newif\ifiscarryover \iscarryoverfalse
% \end{macrocode}
% \begin{environment}{carryoverFmt}
% is a work-around for the color problem
% experienced with carry over text: Suppose there is a change of
% color of the text on the previous page, the carry over text will naturally be
% colored the default color, \texttt{MidMargcolor}. To continue the text with the same color
% as the one the previous page, we enclose the text in the
% \texttt{carryoverFmt} environment.
% \begin{macrocode}
\newenvironment{carryOverFmt}[1]{#1\c@rryoverFmt{#1}}{}
% \end{macrocode}
% \end{environment}
% This command is called by the \texttt{carryOverFmt} environment.
% it takes its argument, which is a change in color or style, and
% defines \cs{tb@carryoverFmt}, which will be executed on the next page.
% \begin{macrocode}
\def\c@rryoverFmt#1{%
\ifx\tb@carryoverFmt\@empty
\global\let\tb@carryoverFmt\@empty
\xdef\tb@co@page{\thepage}%
\gdef\tb@carryoverFmt{\ifnum\thepage>\tb@co@page
#1\global\let\tb@carryoverFmt\@empty\fi}%
\fi
}
\let\tb@carryoverFmt\@empty
% \end{macrocode}
% \cs{tb@insertCarryOver} takes its argument, that is always
% \verb!\unvbox\txtbkb@xb@t}!, and if there is any carryover
% content, will insert its argument followed by a copy,
% \cs{tb@rest@reMarginFmt} of the default margin format. This seems
% to work for recovering from a change of text or style over a page
% boundary.
% \begin{macrocode}
\let\tb@rest@reMarginFmt\relax
\def\tb@insertCarryOver#1{%
\let\tb@rest@reMarginFmt\relax
\ifiscarryover\ifx\tb@carryoverFmt\@empty\else
\let\tb@rest@reMarginFmt\tb@midMargFmt
\tb@carryoverFmt\fi\fi
#1 \tb@rest@reMarginFmt
}
% \end{macrocode}
% \begin{macro}{\eqe@tb@shipout}
% We define the shipout to the margins.\par\medskip\noindent
% \textbf{Bug:} When I use \textsf{graphicxsp}, embed the picture (such as a logo),
% and use that picture as the \cs{setTopMargin}, the shipout routine is executed
% twice for each page. I haven't figured out what causes this, but here is a
% work around. We record the most recent page number, if it equals the page number
% of the last iteration of \cs{eqe@tb@shipout}, we do nothing; otherwise,
% execute the shipout code.
% \begin{macrocode}
\newcommand{\eqe@tb@shipout}{%
\ifnum\arabic{page}=\tblastpageshipped
\let\tb@so@next\relax\else
\xdef\tblastpageshipped{\arabic{page}}%
\def\tb@so@next{\eqe@tb@ship@ut}\fi\tb@so@next
}
\def\tblastpageshipped{-100}
% \end{macrocode}
% Here is the actual shipout code for writing to the margins.
% \begin{macrocode}
\newcommand{\eqe@tb@ship@ut}{%
\fboxsep=0pt\setlength{\unitlength}{1pt}%
\global\setbox\txtbkb@xb@t=\vbox\bgroup
\color@begingroup
\hsize=\tbmarparboxwidth\vsize=\textheight
\MarParBoxFmt
\csname tbTopMargin\endcsname
\vskip\tbminskipbtnlayers
\the\txtbkt@ks
\color@endgroup
\egroup
\global\setbox\txtbkb@xt@p=\vsplit\txtbkb@xb@t to\textheight
\ifvoid\txtbkb@xb@t\global\iscarryoverfalse
\else\global\iscarryovertrue\fi
% \end{macrocode}
% We have three levels the top (\cs{tbTopMargin}), the bottom (\cs{tbBotMargin}),
% and the middle (\cs{txtbkt@ks}). \cs{tbTopMargin} is no problem but \cs{tbBotMargin}
% requires some special attention.
% \begin{macrocode}
\ifx\tbBotMargin\relax\else
% \end{macrocode}
% If \cs{tbBotMargin} is not \cs{relax}, we begin by putting \cs{tbBotMargin}
% into a \cs{vbox} under the same assumptions, and get its height.
% \begin{macrocode}
\bgroup\setbox2=\vbox{%
\hsize=\tbmarparboxwidth\kern0pt
\MarParBoxFmt\csname tbBotMargin\endcsname
\kern0pt
}%
% \end{macrocode}
% We reduce \cs{textheight} by the height of \cs{tbBotMargin}
% \begin{macrocode}
\dimen0=\textheight
\advance\dimen0-\ht\txtbkb@xh@ld
\advance\dimen0-\tbminskipbtnlayers
% \end{macrocode}
% We split off the top material by this amount, the new bottom
% is in \cs{txtbkb@xt@p} the new top is in \cs{box0}
% \begin{macrocode}
\setbox0=\vsplit\txtbkb@xt@p to \dimen0
% \end{macrocode}
% The new bottom (which will overflow to the next page) is the content
% we clipped off bottom of \cs{txtbkb@xt@p} and the original overflow
% material still in \cs{txtbkb@xb@t}.
% \begin{macrocode}
\global\setbox\txtbkb@xb@t=\vbox{%
\unvbox\txtbkb@xt@p\unvbox\txtbkb@xb@t}%
% \end{macrocode}
% We then patch everything together the new top
% is in \cs{txtbkb@xt@p} the new top is in \cs{@tempboxa} followed by
% \cs{tbBotMargin} (in \cs{box}\cs{txtbkb@xh@ld}).
% \begin{macrocode}
\global\setbox\txtbkb@xt@p=\vbox{\unvbox0
\vfill\vskip\tbminskipbtnlayers
\unvbox2\relax}%
\egroup
\fi
\ifodd\value{page}
\put(\@oddllx,\@oddlly){%
\eqe@MarParBox{\unvbox\txtbkb@xt@p}}\else
\put(\@evenllx,\@evenlly){%
\eqe@MarParBox{\unvbox\txtbkb@xt@p}}\fi
% \end{macrocode}
% We see if there is any carry over, if yes, we insert into
% \cs{txtbkt@ks} for use on the next page, along with a heading,
% if any.
% \begin{macrocode}
\global\txtbkt@ks={}\ifvoid\txtbkb@xb@t\else
% \end{macrocode}
% We test whether these is a \cs{splitbotmark}, if yes, then we will
% insert it at the top of the next page with formatting.
% \begin{macrocode}
\if!\splitbotmark!\global\let\tb@sbm@exp\relax\else
\xdef\tb@sbm@exp{\noexpand\tbPreMarginHeader
\noexpand\tbMarginHeaderFmt{\splitbotmark}%
\noexpand\tbPostMarginHeader
\noexpand\par\kern3pt}%
\fi
% \end{macrocode}
% Here is the content that will be carried over to the next page,
% we insert a \cs{splitbotmark} if it is non-empty (\cs{tb@tmp@exp}).
% \begin{macrocode}
\global\txtbkt@ks=\expandafter{\tb@sbm@exp
\tb@insertCarryOver{\unvbox\txtbkb@xb@t}}%
\fi
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\insertpageifcarryover}
% This macro is use to generate a blank page if there is carry over from the
% previous page. It is place just after the exercises, and before a new chapter of section.
% The optional argument allows you to insert something into the new page, if one is
% automatically created. The default is \cs{null}.
% \begin{macrocode}
\newcommand{\insertpageifcarryover}[1][\null]{%
% \end{macrocode}
% We begin by starting a new page, the shipout routine of previous page
% will be initialized and can then get an accurate result for
% \cs{ifiscarryover}.
% \begin{macrocode}
\newpage
% \end{macrocode}
% If there is carryover, we create a new page by inserting
% a content into the page. If there is no carry over, we do
% now insert any content, and the page will not be created.
% \begin{macrocode}
\ifiscarryover\def\eqeifnext{\csname iftrue\endcsname}%
\PackageInfo{eqexam}{Carry over of content in margin
from page \thepage.\MessageBreak Creating a blank page}\else
\def\eqeifnext{\csname iffalse\endcsname}\fi\eqeifnext#1\fi}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\setFullWidthHeader}
% Makes the running header full width.
% \begin{macrocode}
\newcommand{\setFullWidthHeader}{%
\setlength{\@tempdima}{%
\evensidemargin+\tbmarparboxwidth+\marginparsep}%
\edef\@headoffset{\the\@tempdima}%
\def\@evenhead{\makebox[0pt]{\makebox[0pt][l]
{\thepage}\hspace{\@headoffset}}\hfil\slshape\leftmark}%
\ifmarginsonleft
\def\@oddhead{\makebox[0pt]{\makebox[0pt][l]
{\slshape\rightmark}\hspace{\@headoffset}}\hfil\thepage}%
\else
\def\@oddhead{{\slshape\rightmark}\hfil\makebox[0pt]
{\hspace{\@headoffset}\makebox[0pt][r]{\thepage}}}%
\fi
}
% \end{macrocode}
% \end{macro}
%
% \subsection{In support of solutions at end of document and chapter}
%
% A feature that may not be used much is to have solutions at the end of each chapter.
% \begin{macro}{\chaptersolutions}
% If \cs{tb@EndOfChapterExercises} is executed, and
% \cs{chaptersolutions} is placed between chapters, we can generate
% solutions at the end of the chapters, instead of at the end of the book.
% \cs{chaptersolutions} is \cs{let} to \cs{relax} unless
% \cs{tb@EndOfChapterExercises} is executed. In this case
% \cs{chaptersolutions} inputs the the \texttt{.sol} file, then
% then opens it
% \begin{macrocode}
\newif\ifchapterexercises \chapterexercisesfalse
\let\chaptersolutions\relax
\def\tb@EndOfChapterExercises{%
\let\include@solutions@chapter\include@solutions
\def\includeexersolutions{%
\include@solutions@chapter
\global\let\include@solutions\relax
}%
% \end{macrocode}
% \cs{chaptersolutions} is redefined from \cs{relax}. Input current solutions,
% close stream, open stream.
% \begin{macrocode}
\def\chaptersolutions{%
\includeexersolutions
\immediate\closeout\ex@solns
\newwrite \ex@solns \global\let\quiz@solns\ex@solns
\immediate\openout \ex@solns \jobname.sol
\ifvspacewithsolns\writeAllAnsAtEnd\fi
}%
}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
\def\writeallsolutions{\let\chaptersolutions\relax}
% \end{macrocode}
% \begin{macro}{\exercisesAtEndOfChapter}
% If you want solutions at the end of each chapter, you'll have to
% execute this command in the preamble. See \cs{initChapAfterSolns} for an
% example of usage.
% \begin{environment}{afterChapSolns}
% This comment environment is a convenience for placing content between
% chapters.
% \begin{macrocode}
\excludecomment{afterChapSolns}
\includecomment{solnsAtEnd}
\newcommand{\exercisesAtEndOfChapter}{%
\ifeq@nosolutions\else
\typeout{^^J!!!!!Executing in chapter solutions!!!!!^^J}
\chapterexercisestrue\tb@EndOfChapterExercises
\ifchapterexercises
\csarg\let{solnsAtEnd}\@gobble
\excludecomment{solnsAtEnd}%
\csarg\let{AftersolnsAtEndComment}\relax
\includecomment{afterChapSolns}\else
\excludecomment{afterChapSolns}\fi
\fi
}
\@onlypreamble\exercisesAtEndOfChapter
% \end{macrocode}
% \end{environment}
% \end{macro}
% \subsection{Modifying and restoring the Layout}
% The book may need a wide page format and use multi-columns to display homework sets, or
% solutions at the end if the book.
% \begin{macro}{\setFullWidthLayout}
% A command to set the page layout for the solutions in the back of the book. Typically,
% we do away with the wide margins. We also save the current values of the parameters
% we are changing so we can restore them later.
% \begin{macrocode}
\newcommand{\setFullWidthLayout}{%
\saveBasicLayoutParams
\setlength{\oddsidemargin}{0in}%
\setlength{\evensidemargin}{\oddsidemargin}%
\setlength{\textwidth}{\paperwidth-2in}%
\setlength{\linewidth}{\paperwidth-2in}%
\setlength{\columnseprule}{0pt}%
\def\@evenhead{\thepage\hfil\slshape\leftmark}%
\def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
}
% \end{macrocode}
% \begin{environment}{fullwidthtext}
% When \cs{setFullWidthLayout} is in effect, we have the problem of writing text.
% Originally, I used a \cs{parbox} with width of \cs{linewidth}, but this has it problems
% when breaking across pages. We have instead an environment for writing; the list environment
% obeys the current \cs{linewidth}, which is set to \cs{paperwidth-2in}, this latter value
% may not always be correct (especially when the margins are smaller than 2in.
% \begin{macrocode}
\newenvironment{fullwidthtext}{%
\begin{list}{}{%
\setlength{\labelwidth}{0pt}\setlength{\labelsep}{0pt}%
\setlength{\itemindent}{0pt}\setlength{\itemsep}{0pt}%
\setlength{\topsep}{0pt}\setlength{\parsep}{0pt}%
\setlength{\listparindent}{\parindent}%
\setlength{\leftmargin}{0pt}\setlength{\rightmargin}{0pt}
}\item\relax}{\end{list}}
% \end{macrocode}
% \begin{macro}{\restorePageLayout}
% Restore the last saved page parameters.
% \begin{macrocode}
\newcommand{\restorePageLayout}{\newpage
\setlength{\oddsidemargin}{\tb@osms}
\setlength\evensidemargin{\tb@esms}
\setlength{\textwidth}{\tb@tws}
\setlength{\linewidth}{\tb@lws}
\setlength{\columnseprule}{\tb@csr}
}
% \end{macrocode}
% Used by \cs{setFullWidthLayout} just before the page layout parameters are changed.
% \begin{macrocode}
\newcommand{\saveBasicLayoutParams}{%
\xdef\tb@osms{\the\oddsidemargin}%
\xdef\tb@esms{\the\evensidemargin}%
\xdef\tb@tws{\the\textwidth}%
\xdef\tb@lws{\the\linewidth}%
\xdef\tb@csr{\the\columnseprule}%
}
% \end{macrocode}
% \begin{macro}{\initChapAfterSolns}
% Initializes the environment when solutions appear after each chapter.
% Example of usage, taken from fortextbook.ltx,
%\begin{verbatim}
%\begin{afterChapSolns}
%\initChapAfterSolns
%\section{Solutions to Chapter Exercises}
%\begin{fullwidthtext}
%We present short solutions to the problems.
%We present short solutions to the problems.
%We present short solutions to the problems.
%We present short solutions to the problems.
%\end{fullwidthtext}
%\bigskip
%\begin{multicols}{2}\forceNoColor
%\chaptersolutions
%\end{multicols}
%\restoreFromChapAfterSolns
%\end{afterChapSolns}
%\end{verbatim}
% \begin{macrocode}
\newcommand{\initChapAfterSolns}{\newpage
\clearTopMargin\clearBotMargin
\setFullWidthLayout
}
% \end{macrocode}
% \begin{macro}{\restoreFromChapAfterSolns}
% Restores the saved parameters at the end of the chapter solutions, see
% above for an example.
% \begin{macrocode}
\newcommand{\restoreFromChapAfterSolns}{\newpage
\restorePageLayout\setFullWidthHeader
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{environment}
% \end{macro}
% \begin{macrocode}
%
%<*package>
% \end{macrocode}
% \subsection{We shipout in support of \texttt{fortextbook}}
% We shipout \cs{eqe@tb@shipout} to be placed in the margins on every page.
% \begin{macrocode}
\ifeqfortextbook
\AtBeginDocument{\tb@soln@choice
\ifeqwritetomargins\chkmarginboxwidth
\AddToShipoutPicture{\eqe@tb@shipout}\fi}
\fi
%
%<*textbook>
% \end{macrocode}
%
% \subsection{Modify \texttt{eqequestions} environment}
%
% We adjust the \texttt{eqequestions} environment to minimize spacing between problems.
% \begin{macrocode}
\eqequestopsep{0pt}
\eqequesparsep{0pt}
\eqequesitemsep{3pt}
\renewenvironment{eqequestions}{%
\begin{list}{}{%
\setlength{\labelwidth}{\eqemargin}%
\setlength{\topsep}{\eqeques@topsep}%
\setlength{\parsep}{\eqeques@parsep}%
\setlength{\itemsep}{\eqeques@itemsep}
\setlength{\itemindent}{0pt}%
\ifwithsoldoc\settowidth{\labelsep}{\eqe@hspannerSoln}\else
\settowidth{\labelsep}{\eqe@hspannerPrb}\fi
\setlength{\leftmargin}{\labelwidth}%
}\item\relax}{\end{list}}
% \end{macrocode}
% \begin{environment}{eqepartsquestions}
% \begin{macrocode}
\newenvironment{eqepartsquestions}{%
\begin{list}{}{%
\settowidth{\labelwidth}{\eqe@prtsepSoln\hspace{\tbsolnpartwdth}}
\setlength{\topsep}{\eqeques@topsep}%
\setlength{\parsep}{\eqeques@parsep}%
\setlength{\itemsep}{\eqeques@itemsep}%
\setlength{\itemindent}{0pt}%
\settowidth{\labelsep}{\eqe@hspannerSoln}
\setlength{\leftmargin}{\labelwidth}%
}\item\relax}{\end{list}}
% \end{macrocode}
% \end{environment}
%
% \subsection{Modifications for solutions page}
%
% \cs{gobbletoEndeqExt} is a command to gobble all content from the current position \cs{eqEXt}
% down to \cs{endeqEXt}. In the solutions file ends with \cs{par}\cs{medskip}, which
% we gobble up too. We define \cs{eqExtArg} to \cs{thequestionno} so we can use the problem
% number to filter out the even-problems.
% \begin{macrocode}
\long\def\gobbletoEndeqExt#1\endeqEXt{\@gobbletwo}
\def\eqExtArg{\theeqquestionnoi}
% \end{macrocode}
% \begin{macrocode}
\if\load@exerquiz n\DoNotFitItIn\fi
\if\eq@usexkeys y\newcommand{\fillInFormatDefault}{}\fi
\def\exerSolnsHeadnToc{}
\renewcommand{\exerSolnInput}{%
\let\webnewpage\relax
\ifsolutionsonly\else\immediate\closeout\ex@solns\fi
\ifeq@nosolutions\else
\eqsolutionshook
\iftherearesolutions\ifsolutionsonly\else\newpage\fi
% \markright{\exsectitle}% removed for this option
\ifx\webnewpage\relax
\def\webnewpage{\let\webnewpage\newpage}%
\fi
\priorexsectitle\exerSolnsHeadnToc\priorexslinput
\InputIfFileExists{\jobname.sol}{}{\PackageWarning{exerquiz}
{!!! Solutions to exercises not found}}%
\fi
\fi
}
% \end{macrocode}
% \begin{macro}{\eqedsplyOnlyFrst}
% The default listing of a problem with multiple parts is to typeset
% \texttt{.}~\texttt{()}. Here, we do not typeset the number after
% the first time.
% \begin{macrocode}
\setcounter{partno}{1}\edef\firstPartLtr{\thepartno}
% \end{macrocode}
% ???? 6/2/11 When part (a) is hidden we need to generate the questions number
% for the the first non-hidden part. Created \cs{iffrstProbNumShown} to help
% but it not working yet.
% \begin{macrocode}
\newif\iffrstProbNumShown\frstProbNumShownfalse
\def\tb@insertDecPoint{\ifwithsoldoc\eqedecPointSoln\else
\eqe@decPointMrg\fi}
\newcommand{\eqedsplyOnlyFrst}[2]{\def\thisPart{#2}%
\ifx\thisPart\firstPartLtr\global\frstProbNumShowntrue
\tb@mrgDigitFmt{#1}\tb@insertDecPoint\else
\iffrstProbNumShown\tb@GenProbNum{#1}\else
\global\frstProbNumShowntrue\tb@mrgDigitFmt{#1}%
\tb@insertDecPoint\fi\fi\global\eqeGenProbNumfalse
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\displayProbNumOnce}
% If a part is carried over to the next page, it may be necessary to manually
% force the display of the first digit.
%\begin{verbatim}
%\insMidMarg{\displayProbNumOnce}
%\end{verbatim}
% \begin{macrocode}
\newif\ifeqeGenProbNum \eqeGenProbNumfalse
\newcommand{\displayProbNumOnce}{\global\eqeGenProbNumtrue} %
%\def\tb@GenProbNum#1{\ifeqeGenProbNum#1\eqe@decPointMrg\else
\def\tb@GenProbNum#1{\ifeqeGenProbNum#1\tb@insertDecPoint\else
\phantom{#1\tb@insertDecPoint}\fi}%
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
\def\sq@priorhook{\medskip}
% \end{macrocode}
% Adjustments of spacing between problems \cs{eqexerskip}, and the check for enough
% room for the next problem.
% \begin{macrocode}
\def\default@fvsizeskip{.1}
% \end{macrocode}
% The skip prior to the beginning of an exercise
% \begin{macrocode}
\priorexskip{0pt}
% \end{macrocode}
% The skip after the end of an exercise
% \begin{macrocode}
\eqexerskip{0pt}
% \end{macrocode}
% The skip in the solutions file following an exercise OR a part of an exercise
% The text of this command should be a single token, that's why I've enclosed
% it in braces. (There is a \cs{@gobbletwo} that gobbles it up for the \texttt{studented} option.)
% \begin{macrocode}
\renewcommand\eqafterexersolnskip{{}}
% \end{macrocode}
% We remove the \cs{mark} from this definition, see original definition in \texttt{eqexam.def}
% \begin{macrocode}
\renewcommand\exerSolnHeader[3]{%
\ifeqforpaper\else\webnewpage\fi\par
\noindent\@ifundefined{hypertarget}
{#3}{\hypertarget{#2}{#3}\relax}\solnhspace
}
% \end{macrocode}
% This causes the \texttt{eqexam} environment to write the user friendly name of the exam
% even if there is only one exam.
% \begin{macrocode}
\def\nNumberOfP@rts{0}
% \end{macrocode}
%
% \subsection{Some Convenience/Formatting Commands}
%
% \begin{macro}{\preExamSolnHead}
% \begin{macro}{\examSolnHeadFmt}
% \begin{macro}{\postExamSolnHead}
% These are redefinitions of commands defined in \texttt{eqexam},
% They control the vertical spacing before and after a heading in the
% solutions at the end of the book, as well as the formatting.
% \begin{macrocode}
\renewcommand{\preExamSolnHead}{\medbreak\noindent}
\renewcommand{\examSolnHeadFmt}[1]{\textbf{#1}}
\renewcommand{\postExamSolnHead}{\smallbreak}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\wrtChapSolnHead}
% Writes a chapter heading to the solution file, usage,
%\begin{verbatim}
%\wrtChapSolnHead{The New {\eqexam}}
%\end{verbatim}
% \begin{macrocode}
\newcommand{\wrtChapSolnHead}[1]{%
\writeToSolnFile{%
\protect\preChapSolnHead
\protect\chapHeadSolnFmt{\protect\ftbFmtChapter{\thechapter}#1}%
\protect\postChapSolnHead
}}
% \end{macrocode}
% \begin{macro}{\preChapSolnHead}
% \begin{macro}{\chapHeadSolnFmt}
% \begin{macro}{\postChapSolnHead}
% Same as above, except for chapter headings.
% \begin{macrocode}
\newcommand{\preChapSolnHead}{\bigbreak\noindent}
\newcommand{\chapHeadSolnFmt}[1]{{\large\textbf{#1}}}
\newcommand{\postChapSolnHead}{\medbreak}
% \end{macrocode}
% \begin{macro}{\ftbFmtChapter}
% This command may (optionally) insert the chapter number into the chapter title passed
% to \cs{wrtChapSolnHead}. The default is to pass the chapter name (``Chapter'') and chapter number.
% If you say \verb!\let\ftbFmtChapter\@gobble!, the chapter name and number will not appear.
% You can redefine this command as desired.
% \begin{macrocode}
\newcommand{\ftbFmtChapter}[1]{\chaptername\space#1.\space\ignorespaces}
% \end{macrocode}
% In the solution manual, all these
%chapter commands may be redefined like so
%\begin{verbatim}
%\let\preChapSolnHead\relax
%\let\chapHeadSolnFmt\chapter
%\let\ftbFmtChapter\@gobble
%\let\postChapSolnHead\relax
%\end{verbatim}
% In fact, let's make this into a command.
% \begin{macro}{\convertChapHeadToChapters}
%In the solutions manual, the chapter headings will become chapters of the manual, rather than
%just a bold faced heading.
% \begin{macrocode}
\newcommand{\convertChapHeadToChapters}{%
\let\preChapSolnHead\relax
\let\chapHeadSolnFmt\chapter
\let\ftbFmtChapter\@gobble
\let\postChapSolnHead\relax
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\probSet}
% A simple command to announce the problem set.
%\begin{verbatim}
%\subsection*{\probSet{\thesection}}
%\end{verbatim}
% See also the definition for the \texttt{probset} environment below.
% \begin{macrocode}
\newcommand{\probSet}[1]{Problem Set #1}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\annotPage}
% Use to annotation the page number onto a solution heading, for example,
%\begin{verbatim}
%\begin{exam}[\thesection. Another Section\annotPage]{\autoExamName}
%\end{verbatim}
% or using the \texttt{probset} environment defined below
%\begin{verbatim}
%\begin{probset}{{\thesection} Setting the page layout\annotPage}
%\end{verbatim}
% \begin{macrocode}
\newcommand{\annotPage}{\protect\annotThePage{\thepage}}
\newcommand{\annotThePage}[1]{\space(page\protect~#1)}
% \end{macrocode}
% \end{macro}
% \subsection{The \texttt{probset} and \texttt{example} environments}
% We define two environments based. The first (\texttt{probset}) is based on the
% \texttt{exam} environment; the second (example) is based on the \texttt{exercise} environment.
% \begin{environment}{probset}
% A convenience environment, it is the \texttt{exam} environment, renamed, with
% different arguments. \texttt{\#1} is the heading that will appear in the margins,
% and \texttt{\#2} is the heading to appear in the back of the book.
% \begin{macrocode}
\newenvironment{probset}[2][\probSet{\thesection}]{%
\exam[#2]{\autoExamName}\insProbHead{#1}}{\endexam}
% \end{macrocode}
% \end{environment}
% \begin{environment}{example}
% A simple example environment, based on the \texttt{exercise} environment.
% \begin{macrocode}
\newcounter{exampleno}[section]
\renewcommand{\theexampleno}{\arabic{section}.\arabic{exampleno}}
\newenvironment{example}{\medskip
\renewcommand\exlabel{Example}%
\renewcommand\exlabelformat{\textbf{\exlabel~\theexampleno.}}%
\let\eq@fititin\eqfititin
\renewcommand\exrtnlabelformat{$\square$}%
\def\eqexheader@wrapper{\eqexheader}%
\SolutionsAfter
\begin{exercise}[exampleno]}{\end{exercise}}
% \end{macrocode}
% \end{environment}
% \subsection{Commands in support of Solution Manuals}
% Generally, the solution manual source file should have the same
% packages as the source file for the book itself, perhaps with a few exceptions,
% but definitely the \textsf{eqexam} package is required with its \texttt{fortextbook} option.
%
% At this time, we provide only two commands, these are \cs{ftbInputBookAux} and
% \cs{ftbInputSolnFiles}.
% \begin{macro}{\ftbInputBookAux}
% This command is used to input the auxiliary files of the master source file. It takes
% one argument, the name of the master source file (\texttt{myBook.ltx} or \texttt{myBook.tex}).
% If the extension is not present, it is assumed to be \texttt{.tex}.
%\changes{v3.0f}{2011/08/13}{Added \cs{ftbInputBookAux} to support solution manual}
% \begin{macrocode}
\newcommand{\ftbInputBookAux}[1]{%
\filename@parse{#1}\@ifundefined{filename@ext}%
{\def\filename@ext{tex}}{}%
\xdef\tbBaseName{\filename@base}%
\xdef\tbSourceFile{\filename@base.\filename@ext}%
% \end{macrocode}
% In the next 4 lines, we save \cs{@writefile} and \cs{@setckpt}, and \cs{let}
% them to \cs{@gobbletwo}. We restore their definitions after we input the aux files.
% We include the aux files of the source file in case there are some cross references
% in the solution files, or the body of the text would like to refer back to the
% original book. (Seems unlikely.)
% \begin{macrocode}
\let\save@writefile\@writefile
\let\@writefile\@gobbletwo
\let\save@setckpt\@setckpt
\let\@setckpt\@gobbletwo
\makeatletter
\InputIfFileExists{\tbBaseName.aux}{%
\PackageInfo{eqexam}
{Inputting auxiliary files of\MessageBreak\tbSourceFile}%
}{%
\PackageError{eqexam}
{Auxiliary files for \tbSourceFile\space were not found}
{Compile the source file \tbSourceFile\space
three times\MessageBreak%
to create the required auxiliary files.}%
}%
\makeatother
% \end{macrocode}
% The solution files really shouldn't have a label, but if we do
% we'll save the {\LaTeX} definition of \cs{label}, and \cs{let}
% it two \cs{@gobble}. Within the body of the solutions, the
% command \cs{ftblabel} may be used to cross reference, if needed.
%
% \begin{macrocode}
\global\let\ftblabel\label
\let\label\@gobble
\let\@writefile\save@writefile
\let\@setckpt\save@setckpt
}
\@onlypreamble\ftbInputBookAux
% \end{macrocode}
% \begin{macro}{\restorelabel}
% \begin{macro}{\gobblelabel}
% These two are used to restore the usual definition of \cs{label}, and to
% cancel it out by letting it to \cs{@gobble}.
% \begin{macrocode}
\newcommand{\restorelabel}{\global\let\label\ftblabel}
\newcommand{\gobblelabel}{\let\label\@gobble}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\ftbInputSolnFiles}
% In the body of the text, place \cs{ftbInputSolnFiles} in vertical mode.
% This will input the \texttt{.sol} file of the master source document.
% The optional argument is the name of the solution file. The default name
% is \verb!\tbBaseName.sol!, where \cs{tbBaseName} was defined in
% \cs{ftbInputBookAux}. If no extension is specified, an extension of \texttt{.sol}
% is assumed. The original \texttt{.sol} may have changed its name, if someone
% renamed it (to keep it from being overwritten). The solution file may be editing (by hand)
% as needed.
%\changes{v3.0f}{2011/08/13}{Added \cs{ftbInputSolnFiles} to support solution manual}
% \begin{macrocode}
\newcommand{\ftbInputSolnFiles}[1][\tbBaseName.sol]{%
\filename@parse{#1}\@ifundefined{filename@ext}%
{\def\filename@ext{sol}}{}%
\xdef\tbBaseName{\filename@base}%
\xdef\tbSourceFile{\filename@base.\filename@ext}%
\InputIfFileExists{\tbBaseName.sol}{%
\PackageInfo{eqexam}
{Inputting solutions file \tbBaseName.sol\MessageBreak}%
}{%
\PackageError{eqexam}
{Solutions file for \tbSourceFile\space was not found}%
{Compile the source files three times}%
}%
}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
%
%<*package>
% \end{macrocode}
% \paragraph*{Input \texttt{eqtextb.def}.}
% \begin{macrocode}
\def\ftbInputEqTextb{\InputIfFileExists{eqtextb.def}{}{}}
\ifeqfortextbook\expandafter\ftbInputEqTextb\fi
% \end{macrocode}
%
% \section{\textsf{xkeyval} Extensions}
%
% We load this material if \textsf{xkeyval} exists, and if the document author has specified
% the \texttt{usexkv} option.
%
% \begin{macrocode}
\IfFileExists{xkeyval}{%
\if\eq@usexkeys y\RequirePackage{xkeyval}\else
\endinput\fi}{\endinput}
% \end{macrocode}
% We redefine selected commands if the user has specified the \texttt{usexkv} option.
%
%\paragraph*{New options for \cs{fillin}}
% \begin{macro}{underline}
% Underline the fillin
% \begin{macro}{u,b}
% Legacy parameters, underlines (\texttt{u}) or leaves a blank space (\texttt{b})
% \begin{macro}{boxed}
% Boxes in the response region
% \begin{macro}{boxpretext}
% When boxed is use, use this to insert text in front of the answer, for example, \texttt{x=}
% \begin{macro}{boxsize}
% When boxed is taken, use boxsize to set the size of the box; permissible choices are
% tiny, scriptsize, footnotesize, small, normalsize, large, Large, LARGE, huge, Huge
% \begin{macro}{align}
% Align the answer within the response region, permissible values are \texttt{l}, \texttt{c}, \texttt{r}.
% \begin{macro}{color}
% The color of the response (named color)
% \begin{macro}{format}
% Special formatting for the answer, the default is \cs{bfseries}
% \begin{macro}{enclosesoln}
% This Boolean key only takes effect when the
% \texttt{boxed} key is used, and when either the \texttt{nosolutions} or the
% \texttt{vspacewithsolns} option is taken. When these conditions are
% met, a box is created around the solution (the third parameter of \cs{fillin}); the solution
% is enclosed in a \cs{phantom} so it is not seen, but the dimensions of the solution are used.
% This key allows you to create a box or arbitrary dimension.
%\changes{v2.0j}{2011/04/19}{added the \texttt{enclosesoln} key to \texttt{eqFillin} family.}
% \begin{macro}{fitwidth}
%\changes{v3.0i}{2011/08/18}{added the \texttt{fitwidth} key to \texttt{eqFillin} family.}
% The \texttt{fitwidth} option uses the natural width of the answer to create the fillin
% when the \texttt{answerkey} option is in effect; otherwise it uses the second parameter \texttt{\#2}.
%\par\medskip\noindent
% Below are the \textsf{xkeyval} definitions of the keys recognized by \cs{fillin}.
%
% \begin{macrocode}
\define@boolkey{eqFillin}{underline}[true]{}
\define@key{eqFillin}{u}[]{\KV@eqFillin@underlinetrue}
\define@key{eqFillin}{b}[]{\KV@eqFillin@underlinefalse}
\define@boolkey{eqFillin}{boxed}[true]{}
\define@key{eqFillin}{boxpretext}[]{\def\eq@fillintext{#1}}
\let\eq@fillintext\@empty
\define@boolkey{eqFillin}{enclosesoln}[true]{}
\define@choicekey+{eqFillin}{boxsize}{tiny,scriptsize,footnotesize,%
small,normalsize,large,Large,LARGE,huge,Huge}[normalsize]{%
\def\eq@eqFillin@boxsize{\text{\csname#1\endcsname\strut}}%
}{\PackageWarning{eqexam}{Bad choice for boxsize, permissible values
are tiny, scriptsize, footnotesize, small, normalsize,
large, Large, LARGE, huge and Huge. Try again}}
\def\eq@eqFillin@boxsize{\text{\normalsize\strut}}
\define@key{eqFillin}{color}[\eq@fillinColor]{\edef\eq@fillin@color{#1}}
\define@choicekey+{eqFillin}{align}{l,r,c}[c]{%
\def\eq@eqFillin@align{#1}}{%
\PackageWarning{eqexam}{Bad choice for align, permissible values
are l, r, and c. Try again}}
\providecommand{\fillInFormatDefault}{\bfseries}
\define@key{eqFillin}{format}[\fillInFormatDefault]{%
\def\eq@fillin@format{#1}}
\edef\eq@fillin@format{\bfseries}
\def\eqe@fbox@corr#1{#1-2\fboxsep-2\fboxrule}
\define@boolkey{eqFillin}{fitwidth}[true]{} %
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%\paragraph*{Redefine the \cs{fillin} command}
% \begin{macro}{\fillin}
% Re-worked \cs{fillin} to have \textsf{xkeyval} in the optional first parameter.
% The syntax is illustrated below.
%\begin{verbatim}
% \fillin[
% underline=true|false,u,b,boxed=true|false,boxpretext=,
% align=l|r|c,boxsize=\tiny|..\normalsize|\large|...|\Huge,
% color=,format=<\bfseries|\ttfamily|\Large|whatever>
% ]{}{}
%\end{verbatim}
% \begin{macrocode}
\renewcommand{\fillin}[3][]{\begingroup%
\setkeys{eqFillin}{boxsize,underline=false,boxed=false,%
boxpretext,color,align,format,enclosesoln=false,fitwidth=false}%
\protected@edef\eq@temp@exp{\noexpand\setkeys{eqFillin}{#1}}%
\eq@temp@exp
% \end{macrocode}
% If the second argument is empty, we set width based on the
% natural width of \texttt{\#3}
% \begin{macrocode}
\edef\eqe@argii{#2}%
\ifmmode\let\@eqmath\ensuremath\else\let\@eqmath\text\fi
\ifx\eqe@argii\@empty
\settowidth{\eqetmplengthb}{\@eqmath{\eq@fillin@format
\ifKV@eqFillin@boxed\eq@fillintext\fi#3}}%
\ifKV@eqFillin@boxed
\setlength{\eqetmplengthb}{%
\eqetmplengthb+2\fboxsep+2\fboxrule}%
\fi
\else\setlength{\eqetmplengthb}{#2}%
\fi
\edef\eqe@bw{\the\eqetmplengthb}%
\ifKV@eqFillin@underline\let\@fillinFmt\underbar
\else\let\@fillinFmt\relax\fi
\ifeq@proofing
\ifKV@eqFillin@fitwidth
\settowidth{\eqetmplengthb}{\@eqmath{\eq@fillin@format
\ifKV@eqFillin@boxed\eq@fillintext\fi #3}}%
\ifKV@eqFillin@boxed
\setlength{\eqetmplengthb}{%
\eqetmplengthb+2\fboxsep+2\fboxrule}%
\fi
\edef\eqe@bw{\the\eqetmplengthb}%
\fi
\ifKV@eqFillin@boxed
\ifmmode\let\@eqmath\ensuremath\else\let\@eqmath\text\fi
\mbox{\eq@fillin@format\ensuremath{\boxed{%
\eq@eqFillin@boxsize\@eqmath{\eq@fillintext}
\@fillinFmt{%
\ifx\eq@fillintext\@empty
% \end{macrocode}
%\changes{v2.0h}{2011/04/14}{Modified the calculation of the width
%of \cs{fillin}, the width of enclosing box now equals the requested
%width}
% When the boxed option is taken, we adjust the width of the \cs{makebox}
% to get the desired width \texttt{\#2}.
% \begin{macrocode}
\makebox[\eqe@fbox@corr{\eqe@bw}][\eq@eqFillin@align]{%
\strut\eq@fillin@format\color{\eq@fillin@color}%
\@eqmath{#3}}\else
% \end{macrocode}
% If \texttt{boxpretext} is nonempty, we subtract off its width.
% \begin{macrocode}
\settowidth{\eqetmplengthb}{\@eqmath{\eq@fillintext}}%
\makebox[\eqe@fbox@corr{\eqe@bw}-\eqetmplengthb]%
[\eq@eqFillin@align]{%
\strut\eq@fillin@format\color{\eq@fillin@color}%
\@eqmath{#3}}\fi}%
}}}%
\else % not boxed
\ifmmode\let\@eqmath\ensuremath\else\let\@eqmath\relax\fi
\@fillinFmt{\makebox[\eqe@bw][\eq@eqFillin@align]{%
\strut\eq@fillin@format\color{\eq@fillin@color}%
\@eqmath{#3}}}%
\fi
\else
\ifKV@eqFillin@boxed
\mbox{\eq@fillin@format\ensuremath{\boxed{%
\eq@eqFillin@boxsize\eq@fillintext
\@fillinFmt{%
% \end{macrocode}
% We do a similar thing if proofing is not active (\texttt{nosolutions} is taken).
% \begin{macrocode}
\ifx\eq@fillintext\@empty
\ifKV@eqFillin@enclosesoln
\makebox[\eqe@fbox@corr{\eqe@bw}]%
{\phantom{#3}}\else
\makebox[\eqe@fbox@corr{\eqe@bw}]%
{\strut\hfill}\fi
\else
\settowidth{\eqetmplengthb}{%
\ensuremath{\eq@fillintext}}%
\ifKV@eqFillin@enclosesoln
\makebox[\eqe@fbox@corr{\eqe@bw}-\eqetmplengthb]%
{\phantom{#3}}\else
\makebox[\eqe@fbox@corr{\eqe@bw}-\eqetmplengthb]%
{\strut\hfill}\fi
\fi}%
}}}
\else
\@fillinFmt{\makebox[\eqe@bw]{\strut\hfil}}%
\fi
\@ifundefined{@quiz}{}{%
\ifx\eq@online y\relax
\ifeq@nosolutions
\ifeq@solutionsafter\else
\ifx\eq@insertverticalspace y\relax
\stepcounter{@cntfillin}%
\edef\fieldName{%
\if\probstar*eqexam.\curr@quiz.fillin.%
\theeqquestionnoi.part\thepartno.%
fi\the@cntfillin
\else
eqexam.\curr@quiz.fillin.%
\theeqquestionnoi.fi\the@cntfillin
\fi
}\makebox[0pt][r]{\textField[\BC{}]{%
\fieldName}{\eqe@bw}{11bp}}%
\fi
\fi
\fi
\fi
}%
\fi\endgroup\space\ignorespaces}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\TF}
% The \cs{TF} command depends on \cs{fillin}, so we make the appropriate changes.
% \begin{macrocode}
\renewcommand\TF[2][\defaultTFwidth]{%
\def\eqe@next{\fillin[underline]{#1}{#2}}%
\ifdim\eq@extralabelsep=0pt\relax\else
\if\probstar*\relax\if\exerwparts@cols x
\def\eqe@next{\makebox[0pt][r]{%
\fillin[underline]{#1}{#2}}\ignorespaces}%
\fi\fi\fi\eqe@next
}
% \end{macrocode}
% \end{macro}
% This marks the end of the \textsf{eqexam} package. dps
% \begin{macrocode}
%
% \end{macrocode}
\endinput
The hidden feature \item[h] does not work correctly when exerquiz is
loaded.