% \iffalse %<*copyright> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Exerquiz.sty package, 2000-8-16 %% %% Copyright (C) 1999-2004 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{exerquiz} % [2007/05/05 v6.08 Exerquiz Exercises and Quizzes for LaTeX/PDF package (dps)] %<*driver> \documentclass{ltxdoc} \usepackage[dviwindo,colorlinks,hyperindex]{hyperref} \pdfstringdefDisableCommands{\let\\\textbackslash} \OnlyDescription % comment out for implementation details \EnableCrossrefs \CodelineIndex \begin{document} \GetFileInfo{exerquiz.sty} \title{Exerquiz: Exercises and Quizzes for \LaTeX/PDF} \author{D. P. Story\\ Email: \texttt{dpstory@uakron.edu}} \date{processed \today} \maketitle \tableofcontents \let\Email\texttt \DocInput{exerquiz.dtx} \PrintIndex \end{document} % % \fi % % \MakeShortVerb{|} % % \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} % % \begin{macrocode} %<*package> % \end{macrocode} % \newpage % \section{Change History} % \makeatletter % \renewenvironment{theglossary}{% % % \let\efill=\relax % \begin{itemize}}% % {\end{itemize}} % \global\c@GlossaryColumns = 1 % \makeatother % \PrintChanges % \section{Package options and setup}\label{options} % % Introduce a number of useful options for \textsl{exerquiz}. % \subsection{Options for paper, solutions, JavaScript and preview} % \begin{macrocode} \IfFileExists{xcolor.sty}% {\def\eq@ColorPackage{xcolor}\PassOptionsToPackage{table,hyperref}{xcolor}} {\def\eq@ColorPackage{color}} \DeclareOption{noxcolor}{\def\eq@ColorPackage{color}} % \end{macrocode} % \begin{macro}{forpaper} % \begin{macro}{forcolorpaper} % Pass the |monochrome| option to the color package %\changes{v6.06a}{2007/04/09} %{ % Added the \texttt{forcolorpaper} option for those using \textsf{exerquiz} without \textsf{web}. %} % \begin{macrocode} \DeclareOption{forpaper}{% \eqforpapertrue\PassOptionsToPackage{monochrome}{\eq@ColorPackage} \AtBeginDocument{\ifnum\eq@drivernum=4 \else\AllowPeeking\fi} } \DeclareOption{forcolorpaper}{\eqforpapertrue % for print \AtBeginDocument{\ifnum\eq@drivernum=4 \else\AllowPeeking\fi} } % \end{macrocode} % \end{macro} % \end{macro} % \begin{macro}{preview} % With this option, the bounding boxes of all form fields appear in the % dvi preview. Use this option of properly positioning your fields, then % remove this option on the final build of the document. This option is no % appropriate for the \texttt{pdftex} option which does not have a dvi preview. % \begin{macrocode} \DeclareOption{preview}{\PassOptionsToPackage{preview}{eforms}} % \end{macrocode} % \end{macro} % \begin{macro}{nosolutions} % With the option, the solutions to the exercises are not % included in the typeset document. % \begin{macrocode} \DeclareOption{nosolutions}{\eq@nosolutionstrue\eq@nolinktrue} % \end{macrocode} % \end{macro} % \begin{macro}{noquizolutions} % No solutions for quizzes (shortquiz and quiz environments). % \begin{macrocode} \DeclareOption{noquizsolutions}{\eq@noquizsolutionstrue\eq@nolinktrue} % \end{macrocode} % \end{macro} % \begin{macro}{online} % An \texttt{online} options. % \begin{macrocode} \DeclareOption{online}{\let\eq@online=y} \let\eq@online=n % \end{macrocode} % \end{macro} % \begin{macro}{nohiddensolutions} % Overrides any hidden solutions specified with the \texttt{exercise} % environment. % \begin{macrocode} \DeclareOption{nohiddensolutions}{\eq@globalshowsolutionstrue} \DeclareOption{noHiddensolutions}% {\eq@globalshowsolutionstrue\AtBeginDocument{\def\Hidesymbol{h}}} % \end{macrocode} % \end{macro} % \begin{macro}{solutionsafter} % Solutions will appear after the statement of the exercise. % \begin{macrocode} \DeclareOption{solutionsafter}{\eq@solutionsaftertrue\eq@nolinktrue} % \end{macrocode} % \end{macro} % \begin{macro}{nocorrections} % The code for correcting the |quiz| environment is % not written; this results in a smaller file. % \begin{macrocode} \DeclareOption{nocorrections}{\eq@nocorrectionstrue} % \end{macrocode} % \end{macro} % \begin{macro}{proofing} % An option for marking the correct answers for shortquiz and quiz % \begin{macrocode} \DeclareOption{proofing}{\eq@proofingtrue} % \end{macrocode} % \end{macro} % \begin{macro}{showgrayletters} % When this option is in effect, capital letters in gray appear under % the multiple choice question boxes of quizzes. % \begin{macrocode} \newif\ifaebshowgrayletters\aebshowgraylettersfalse \DeclareOption{showgrayletters}{\aebshowgrayletterstrue} % \end{macrocode} % \end{macro} % \begin{macro}{nodljs} % An option for excluding all DLJS from the document. Useful with the % \texttt{forpaper} option, or a document destined to be printed. Pass % on to insdljs package. % \begin{macrocode} \DeclareOption{nodljs}{\PassOptionsToPackage{nodljs}{insdljs}% \AtEndOfPackage{\let\importdljs=y}} % \end{macrocode} % \end{macro} % \begin{macro}{execAfter} % Execute any JS defined within the \texttt{execJS} environment. Works only for % authors using Acrobat 5.0 or Acrobat Approval. % \begin{macrocode} \DeclareOption{execJS}{\PassOptionsToPackage{execJS}{insdljs}} % \end{macrocode} % \end{macro} % \begin{macro}{exercisesonly} % If the document author wants only to create a series of exercises, no quizzes, there is no % need for the Document-level JavaScript. So, we have a couple of convenience options. % \begin{macrocode} \DeclareOption{exercisesonly}{\PassOptionsToPackage{nodljs}{insdljs}} % \end{macrocode} % \end{macro} % \begin{macro}{debug} % An option for debugging JavaScript. Pass on to insdljs package. % \begin{macrocode} \DeclareOption{debug}{\PassOptionsToPackage{debug}{insdljs}} % \end{macrocode} % \end{macro} % \subsection{Driver Options} % The \textsf{web} package passes these driver options to \textsf{exerquiz}. % These options are needed is \textsf{exerquiz} is used without % \textsf{web}; in this case, the options below must explicitly included. % \begin{macro}{dvipsone} % Set the driver dependent code for the |quiz| environments. % \begin{macrocode} % \def\eq@drivernum{5} % 5 = no choice \DeclareOption{dvipsone}{\def\eq@drivernum{0}% \PassOptionsToPackage{dvipsone}{eforms} % \PassOptionsToPackage{dvipsone}{insdljs} } \DeclareOption{dvips}{\def\eq@drivernum{0}% \PassOptionsToPackage{dvips}{eforms} \PassOptionsToPackage{dvips}{insdljs}} \DeclareOption{pdftex}{\def\eq@drivernum{1}% \def\eq@driver{pdftex}% \PassOptionsToPackage{pdftex}{\eq@ColorPackage} \PassOptionsToPackage{pdftex}{eforms} \PassOptionsToPackage{pdftex}{insdljs} } % \end{macrocode} % \end{macro} % \begin{macro}{dvipdfm} % Set the driver dependent code for the \texttt{quiz} and \texttt{quiz} % environments. % \begin{macrocode} \DeclareOption{dvipdfm}{\def\eq@drivernum{2}% \def\eq@driver{dvipdfm}% \PassOptionsToPackage{dvipdfm}{\eq@ColorPackage} \PassOptionsToPackage{dvipdfm}{eforms} \PassOptionsToPackage{dvipdfm}{insdljs} } % \end{macrocode} % \end{macro} % \begin{macro}{textures} % This option, and testing are due to Ross Moore 3/6/02 % \begin{macrocode} \DeclareOption{textures}{\def\eq@drivernum{3}% \def\eq@driver{textures}% \PassOptionsToPackage{textures}{\eq@ColorPackage}% \PassOptionsToPackage{textures}{eforms} \PassOptionsToPackage{textures}{insdljs}% } % \end{macrocode} % \end{macro} % \begin{macro}{dviwindo} % Set \cmd{\eq@noformstrue}, this inserts an \cmd{\endinput} just after % the end of the |exercise| environment. No quizzes for % \texttt{dviwindo}. % \begin{macrocode} \DeclareOption{dviwindo}{\def\eq@drivernum{4}\def\eq@driver{dviwindo}% \eq@noformstrue\PassOptionsToPackage{nodljs}{insdljs}} % \end{macrocode} % \end{macro} % If no driver is passed to \textsf{exerquiz}, assume it is % dvipsone or dvips---\textsf{hyperref} defines the specials. % Default driver dvipsone/dvips % \begin{macrocode} % \def\eq@drivernum{5} % \def\eq@driver{dvipsone/dvips} % \def\eq@driver{no driver specified} % \end{macrocode} % \subsection{Language Options} % \textsf{exerquiz} uses many language dependent typeset labels % and JavaScript messages. These messages are defined in the % English language in Section~\ref{ss:ldm}. The language options % defines the macro \cmd{\LangRedefinition} to input language % dependent redefinitions of these messages. Initially, % \cmd{\LangRedefinition} is set to relax and no redefinition files % are input. % \begin{macrocode} \let\LangRedefinitions=\relax % \end{macrocode} % \begin{macro}{french} % Translations due to Jean-Michel SARLAT. % \begin{macrocode} \DeclareOption{french}{% \def\LangRedefinitions{\InputIfFileExists{eqfr.def}% {\typeout{exerquiz: Inputting French Option}}% {\typeout{exerquiz: French Option: Cannot find the file eqfr.def, using the default, English.}}}} % \end{macrocode} % \end{macro} % \begin{macro}{german} % Translation due to Michael Wiedmann. % \begin{macrocode} \DeclareOption{german}{% \def\LangRedefinitions{\InputIfFileExists{eqde.def}% {\typeout{exerquiz: Inputting German Option}}% {\typeout{exerquiz: German Option: Kann die Datei eqde.def nicht finden, benutze Default, Englisch.}}}} % \end{macrocode} % \end{macro} % \begin{macro}{norsk} % Translation due to Hans Fredrik Nordhaug. % \begin{macrocode} \DeclareOption{norsk}{% \def\LangRedefinitions{\InputIfFileExists{eqno.def}% {\typeout{exerquiz: Inputting Norsk Option}}% {\typeout{exerquiz: Norsk Option: Cannot find the file eqno.def, using the default, English.}}}} % \end{macrocode} % \end{macro} % \begin{macro}{dutch} % Translation due to Henny Wilbrink % \begin{macrocode} \DeclareOption{dutch}{% \def\LangRedefinitions{\InputIfFileExists{eqnl.def}% {\typeout{exerquiz: Inputting Dutch Option}}% {\typeout{exerquiz: Dutch Option: Kan bestand eqnl.def niet vinden, gebruik default, Engels.}}}} % \end{macrocode} % \end{macro} % \begin{macro}{spanish} % Translation due to Pedro Luis Luque % \begin{macrocode} \DeclareOption{spanish}{% \def\LangRedefinitions{\InputIfFileExists{eqes.def}% {\typeout{exerquiz: Inputting Spanish Option}}% {\typeout{exerquiz: Spanish Option: Opci\'on Espa\~nola: no puede encontrar el fichero eqes.def, usar\'a por defecto, English.}}}} % \end{macrocode} % \end{macro} % \begin{macro}{italian} % Translation due to PierLuigi Zezza % \begin{macrocode} \DeclareOption{italian}{% \def\LangRedefinitions{\InputIfFileExists{eqit.def}% {\typeout{exerquiz: Opzione Lingua Italiana}}% {\typeout{exerquiz, Opzione Italiano: Non trovo il file eqit.def, utilizzo quello di default, English.}}}} % \end{macrocode} % \end{macro} % \begin{macro}{russian} % Translation due to Sergei V. Znamenskii % \begin{macrocode} \DeclareOption{russian}{% \def\LangRedefinitions{\InputIfFileExists{eqru.def}% {\typeout{exerquiz: Inputting Russian Option}}% {\typeout{exerquiz: Russian Option: Cannot find the file eqru.def, using the default, English.}}}} % \end{macrocode} % \end{macro} % \begin{macro}{dansk} % Translation due to Erik Leimand % \begin{macrocode} \DeclareOption{dansk}{% \def\LangRedefinitions{\InputIfFileExists{eqda.def}% {\typeout{exerquiz: Inputting Dansk Option}}% {\typeout{exerquiz: Dansk Option: Cannot find the file eqda.def, using the default, English.}}}} % \end{macrocode} % \end{macro} % \begin{macro}{polish} % Translation due to Jerzy Mycielski % \begin{macrocode} \DeclareOption{polish}{% \def\LangRedefinitions{\InputIfFileExists{eqpo.def}% {\typeout{exerquiz: Inputting Polish Option}}% {\typeout{exerquiz: Polish Option: Cannot find the file eqpo.def, using the default, English.}}}} % \end{macrocode} % \end{macro} % \begin{macro}{finnish} % Translation due to Paivi Porras % \begin{macrocode} \DeclareOption{finnish}{% \def\LangRedefinitions{\InputIfFileExists{eqfin.def}% {\typeout{exerquiz: Inputting Finnish Option}}% {\typeout{exerquiz: Finnish Option: Cannot find the file eqfin.def, using the default, English.}}}} % \end{macrocode} % \end{macro} % \begin{macro}{catalan} % Translation due to Ramon Ballester % \begin{macrocode} \DeclareOption{catalan}{% \def\LangRedefinitions{\InputIfFileExists{eqcat.def}% {\typeout{exerquiz: Inputting Catalan Option}}% {\typeout{exerquiz: Catalan Option: Cannot find the file eqcat.def, using the default, English.}}}} % \end{macrocode} % \end{macro} % \begin{macro}{czech} % Translation due to Robert Marik % \begin{macrocode} \DeclareOption{czech}{% \def\LangRedefinitions{\InputIfFileExists{eqcz.def}% {\typeout{exerquiz: Inputting Czech Option}}% {\typeout{exerquiz: Czech Option: Cannot find the file eqcz.def, using the default, English.}}}} % \end{macrocode} % \end{macro} % \begin{macro}{brazil} % Translation due to Koichi Sameshima % \begin{macrocode} \DeclareOption{brazil}{% \def\LangRedefinitions{\InputIfFileExists{eqbr.def}% {\typeout{exerquiz: Inputting Brazilian Portuguese Option}}% {\typeout{exerquiz: Portuguese Option: Opc\~ao Portugu\^es: n\~ao foi poss\'ivel encontrar o arquivo eqbr.def, usaremos o padr\~ao, English.}}}} % \end{macrocode} % \end{macro} % \begin{macrocode} \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{\eq@ColorPackage}} \@ifpackageloaded{xcolor}% {% \@ifpackagelater{xcolor}{2004/07/04}{} {% \PackageError{exerquiz}{% *************************************************\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]{exerquiz}\MessageBreak *************************************************}{}% }% }{} % \end{macrocode} % \subsection{Switches} % Boolean switches used by the declared options. % \begin{macrocode} %\newif\ifpreview \previewfalse \let\iterate\relax \newif\ifeq@solutionsafter \eq@solutionsafterfalse \newif\ifeq@hidesolution \eq@hidesolutionfalse \newif\ifeq@globalshowsolutions \eq@globalshowsolutionsfalse \newif\ifeq@nosolutions \eq@nosolutionsfalse \newif\ifeq@proofing \eq@proofingfalse \newif\ifeqforpaper \eqforpaperfalse % %<*package|eqexam> %\newif\ifeqforpaper \eqforpaperfalse \newif\ifeq@noforms \eq@noformsfalse %\newif\ifeq@nosolutions \eq@nosolutionsfalse \newif\ifeq@noquizsolutions \eq@noquizsolutionsfalse % dps new %\newif\ifeq@solutionsafter \eq@solutionsafterfalse \newif\ifeq@nocorrections \eq@nocorrectionsfalse %\newif\ifeq@proofing \eq@proofingfalse \newif\ifeq@nolink \eq@nolinkfalse %\newif\ifeq@globalshowsolutions \eq@globalshowsolutionsfalse %\newif\ifeq@hidesolution \eq@hidesolutionfalse \def\eq@ckglobalhide{\ifeq@globalshowsolutions\eq@hidesolutionfalse\fi} \def\hidesymbol{h}\def\Hidesymbol{H} % \end{macrocode} % When the first solution is written, \cs{therearesolutions} is % made true. When the solutions are input back into the file, and % this switch is still false, then no exercise header is typeset; % this avoids an empty exercise section with only the header. % \begin{macrocode} \newif\iftherearesolutions \therearesolutionsfalse % \end{macrocode} % \begin{macro}{\SolutionsAfter} % \begin{macro}{\SolutionsAtEnd} % Some macros to turn \cs{eq@solutionsafter} on or off % \begin{macrocode} \def\SolutionsAfter{\eq@solutionsaftertrue\eq@nolinktrue} \def\SolutionsAtEnd{\eq@solutionsafterfalse\eq@nolinkfalse} \def\NoSpaceToWork{\let\eq@insertverticalspace=n} \def\SpaceToWork{\let\eq@insertverticalspace=y} \SpaceToWork % %<*package> % \end{macrocode} % \end{macro} % \end{macro} % \begin{macro}{\CorrectionsOn} % \begin{macro}{\CorrectionsOff} % Use these macros to locally turn on or off the inclusion % of the correction code. % \begin{macrocode} \def\CorrectionsOn{\global\eq@nocorrectionsfalse} \def\CorrectionsOff{\global\eq@nocorrectionstrue} % \end{macrocode} % \end{macro} % \end{macro} % \subsection{Process Options and Require Packages} % The \texttt{quiz} environments use Acrobat forms and JavaScript % so we need to load in the AcroForm Dictionary---unless the % \texttt{dviwindo} (\cmd{\eq@noformstrue}) option is requested. % \begin{macrocode} \AtBeginDocument{\ifeq@noforms\else\begin{Form}\fi} \AtEndDocument {% \include@solutions \ifeq@noforms\else \include@quizsolutions \fi \end{Form} % \end{macrocode} % (04/12/07) I put a \cs{clearpage} for some good reason, can't remember, I think % it had to do with templates, but dvipdfm has problems with this. The document % level JavaScript are not inserted, they are cleared out by the \cs{clearpage}. % So, we'll only to a \cs{clearpage} if the driver is not dvipdfm. % \begin{macrocode} \if\eq@drivernum2\else\clearpage\fi } % \end{macrocode} % \subsection{Load Configuration File: exerquiz.cfg} % Look for configuration file, exerquiz.cfg. %\begin{verbatim} % \ExecuteOptions{noquizsolutions,nocorrections} %\end{verbatim} % sets several options. % \begin{macrocode} \InputIfFileExists{exerquiz.cfg}{}{} % \end{macrocode} % \begin{macrocode} \ProcessOptions %\def\eq@xcolor{xcolor}\ifx\eq@ColorPackage\eq@xcolor %\def\eq@coloropts{hyperref,table}\else\def\eq@coloropts{}\fi %\RequirePackage[\eq@coloropts]{\eq@ColorPackage} \RequirePackage{\eq@ColorPackage} %\RequirePackage{color} \RequirePackage{verbatim} \RequirePackage{hyperref} \RequirePackage{insdljs} \RequirePackage{eforms} % \end{macrocode} % \begin{macrocode} \@ifundefined{eq@drivernum}{% \PackageError{Exerquiz}% {You have not specified dvips, dvipsone, pdftex or dvipdfm \MessageBreak in the option list of the exerquiz package} {Place one of the driver names dvips, dvipsone, pdftex or dvipdfm \MessageBreak in the option list of the exerquiz package.} }{} % \end{macrocode} % \begin{macrocode} % % \end{macrocode} % \subsection{The Template \& Language dependent messages}\label{ss:ldm} % The following define labels and messages for the exercise and % various quiz environments. They are all redefined when a % language option is used. All of them can be redefined to % customize a users document. % % In attempt to better manage the language localizations, I've placed the % template for Web and Exerquiz in the Exerquiz.dtx file. % \begin{macrocode} %