diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/probsoln/probsoln.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/probsoln/probsoln.dtx | 136 |
1 files changed, 89 insertions, 47 deletions
diff --git a/Master/texmf-dist/source/latex/probsoln/probsoln.dtx b/Master/texmf-dist/source/latex/probsoln/probsoln.dtx index d555fc87f5e..b15dc024005 100644 --- a/Master/texmf-dist/source/latex/probsoln/probsoln.dtx +++ b/Master/texmf-dist/source/latex/probsoln/probsoln.dtx @@ -1,12 +1,12 @@ %\iffalse -% probsoln.dtx generated using makedtx version 0.91b (c) Nicola Talbot +% probsoln.dtx generated using makedtx version 0.94b (c) Nicola Talbot % Command line args: % -src "(.+)\.(sty)=>\1.\2" % -doc "manual.tex" % -author "Nicola Talbot" % -dir "source" % probsoln -% Created on 2007/7/18 20:23 +% Created on 2007/8/21 16:58 %\fi %\iffalse %<*package> @@ -47,7 +47,7 @@ \newcommand{\cmdlink}[1]{\hyperlink{#1}{\cmdname{#1}}} \newcommand{\problabel}[2]{\hypertarget{#1}{\texttt{#2}}} \newcommand{\probref}[1]{\hyperlink{#1}{\texttt{#1}}} -\newcommand{\cmdname}[1]{\texttt{\symbol{92}#1}} +\newcommand{\cmdname}[1]{\cs{#1}} %hyperindex conflicts with doc %(end up with |usage|hyperpage in indexentry) \renewcommand{\usage}[1]{\textit{\hyperpage{#1}}} @@ -56,9 +56,10 @@ \makeatletter \def\index@prologue{\section*{Index}} \makeatother +\CheckSum{499} +\OnlyDescription -\OnlyDescription \PageIndex \begin{document} @@ -66,11 +67,9 @@ \end{document} %</driver> %\fi -% -% -% \title{probsoln.sty v2.03: \LaTeXe\ Package to help create problem sheets} +% \title{probsoln.sty v2.04: \LaTeXe\ Package to help create problem sheets} % \author{Nicola L.C. Talbot} -% \date{20th June 2006} +% \date{21st August 2007} % \maketitle % \tableofcontents % @@ -563,16 +562,24 @@ % required. And specify the package provided. % \begin{macrocode} \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{probsoln}[2006/06/20 v2.03 Problems and their Solutions Package (NLCT)] +\ProvidesPackage{probsoln}[2007/08/21 v2.04 Problems and their Solutions Package (NLCT)] \RequirePackage{ifthen} % \end{macrocode} % Define newif to determine whether or not to show the answers. % (Changed to |\provideboolean| 21 Mar 2004.) % \begin{macrocode} \provideboolean{showanswers} -\newcommand{\showanswers}{\showanswerstrue} -\newcommand{\hideanswers}{\showanswersfalse} % \end{macrocode} +%\begin{macro}{\showanswers} +% \begin{macrocode} +\let\showanswers=\showanswerstrue +% \end{macrocode} +%\end{macro} +%\begin{macro}{\hideanswers} +% \begin{macrocode} +\let\hideanswers=\showanswersfalse +% \end{macrocode} +%\end{macro} % Now define the package options % \begin{macrocode} \DeclareOption{answers}{\showanswerstrue} @@ -586,12 +593,15 @@ \newif\iffirstpass \newif\ifselected % \end{macrocode} +%\begin{macro}{\newproblem} % Define the command that creates a new problem. As from version % 2.03 this command now has a starred version for problems without % solutions. % \begin{macrocode} \newcommand{\newproblem}{\@ifstar\@snewproblem\@newproblem} % \end{macrocode} +%\end{macro} +%\begin{macro}{\@newproblem} % The unstarred version. % \begin{macrocode} \newcommand{\@newproblem}[4][0]{% @@ -634,6 +644,8 @@ \fi } % \end{macrocode} +%\end{macro} +%\begin{macro}{\@snewproblem} % The starred version (new to version 2.03). Note that there is one % less argument, because the problem doesn't have a solution. % \begin{macrocode} @@ -674,15 +686,18 @@ \fi } % \end{macrocode} +%\end{macro} +%\begin{macro}{\useproblem} % Define the command that uses a problem % \begin{macrocode} -\newcommand{\useproblem}[1]{% +\newcommand*{\useproblem}[1]{% \@ifundefined{@prob@#1}{% \PackageError{probsoln}{Label #1 undefined}% -{Can't find problem defined with label identifier '#1'}% +{Can't find problem defined with label identifier `#1'}% }{\csname @prob@#1\endcsname}% } % \end{macrocode} +%\end{macro} % Now deal with the stuff for random selection. % First define some registers for later use. % \begin{macrocode} @@ -691,21 +706,24 @@ \newcount\@ps@randtmp \r@ndcur=1\relax % \end{macrocode} +%\begin{macro}{\PSNrandseed} % Set the random generator seed % \begin{macrocode} -\newcommand{\PSNrandseed}[1]{% +\newcommand*{\PSNrandseed}[1]{% \ifnum#1=0\relax -\PackageWarning{probsoln}{Can't have 0 as random seed, changing to 1}% -\r@ndcur=1\relax + \PackageWarning{probsoln}{Can't have 0 as random seed, changing to 1}% + \r@ndcur=1\relax \else -\r@ndcur=#1\relax + \r@ndcur=#1\relax \fi -\PackageInfo{probsoln}{Random Seed = \the\r@ndcur}% +\PackageInfo{probsoln}{Random Seed = \number\r@ndcur}% } % \end{macrocode} +%\end{macro} +%\begin{macro}{\PSNrand} % Generate a random integer. % \begin{macrocode} -\newcommand{\PSNrand}{% +\newcommand*{\PSNrand}{% \@ps@randtmp=\r@ndcur \multiply\@ps@randtmp by 16807\relax \r@ndcur=\@ps@randtmp @@ -716,41 +734,51 @@ \ifnum\r@ndcur=0\relax\r@ndcur=1\fi } % \end{macrocode} -% |\PSNrandom{|\meta{count}|}{|\meta{n}|}| stores a random number +%\end{macro} +%\begin{macro}{\PSNrandom} +% \cs{PSNrandom}\marg{count}\marg{n} stores a random number % from 1 to \meta{n} % in the TeX count register \meta{count} % \begin{macrocode} \newcommand{\PSNrandom}[2]{% +% \end{macrocode} % generate new random number. +% \begin{macrocode} \PSNrand #1=\r@ndcur \@ps@randtmp=\r@ndcur -% now (#1 mod #2) + 1 +% \end{macrocode} +% now set \meta{count} to (\meta{count} mod \meta{n}) + 1 +% \begin{macrocode} \divide\@ps@randtmp by #2\relax \multiply\@ps@randtmp by #2\relax \advance#1 by -\@ps@randtmp \advance#1 by 1\relax } % \end{macrocode} -% |\random{|\meta{counter}|}{|\meta{a}|}{|\meta{b}|}|: +%\end{macro} +%\begin{macro}{\random} +% \cs{random}\marg{counter}\marg{a}\marg{b}: % Generate a random number in the range $[a,b]$, and store this % number in the \LaTeX\ counter \meta{counter}. % \begin{macrocode} \newcommand{\random}[3]{% \ifnum#2=1\relax -\PSNrandom{\value{#1}}{#3}% + \PSNrandom{\value{#1}}{#3}% \else -\@rndselctr=#3% -\advance\@rndselctr by -#2\relax -\advance\@rndselctr by 1\relax -\PSNrandom{\value{#1}}{\@rndselctr}% -\addtocounter{#1}{#2}% -\addtocounter{#1}{-1}% + \@rndselctr=#3% + \advance\@rndselctr by -#2\relax + \advance\@rndselctr by 1\relax + \PSNrandom{\value{#1}}{\@rndselctr}% + \addtocounter{#1}{#2}% + \addtocounter{#1}{-1}% \fi } % \end{macrocode} +%\end{macro} +%\begin{macro}{\selectallproblems} % Define command to use all problems from a given file. -% Syntax: |\selectallproblems{|\meta{filename}|}|. +% Syntax: \cs{selectallproblems}\marg{filename}. % \begin{macrocode} \newcommand*{\selectallproblems}[1]{% \global\@probN=0\relax @@ -768,22 +796,25 @@ \global\advance\@rndselctr by 1\relax }} % \end{macrocode} +%\end{macro} +%\begin{macro}{\selectrandomly} % Now define command to randomly select \meta{n} problems from % a given file. -% Syntax: |\selectrandomly{|\meta{filename}|}{|\meta{n}|}|. +% Syntax: \cs{selectrandomly}\marg{filename}\meta{n}. % \begin{macrocode} -\newcommand{\selectrandomly}[2]{% +\newcommand*{\selectrandomly}[2]{% \global\@probselN=#2\relax \global\@probN=0\relax \selectrandomtrue \firstpasstrue \input{#1}% \ifnum\@probselN>\@probN -\PackageError{probsoln}{Requested number too large}% -{You have asked for \the\@probselN \space problems, but there are only -\the\@probN \space problems defined in the file #1. I will only select \the\@probN \space -problems.}% -\global\@probselN=\@probN + \PackageError{probsoln}{Requested number too large}% + {You have asked for \the\@probselN \space problems, + but there are only \the\@probN \space problems defined in the + file #1. I will only select \the\@probN \space + problems.}% + \global\@probselN=\@probN \fi \shuffle{@problabel}{\@probN}% \firstpassfalse @@ -798,26 +829,32 @@ problems.}% }% } % \end{macrocode} +%\end{macro} +%\begin{macro}{\PSNitem} % What to do at start and end of each randomly selected item: % (I may turn this into a normal environment at a later date. At the % moment, I have kept \verb|\PSNitem| for compatibility with earlier % versions.) % \begin{macrocode} -\newcommand{\PSNitem}{\item} +\newcommand*{\PSNitem}{\item} \@ifundefined{endPSNitem}{\def\endPSNitem{}}{% \PackageError{probsoln}{\string\endPSitem\ already defined}{}} % \end{macrocode} +%\end{macro} +%\begin{macro}{\solutionname} % How to display each solution % \begin{macrocode} -\providecommand{\solutionname}{Solution} +\providecommand*{\solutionname}{Solution} \@ifundefined{solution}{% \newenvironment{solution}{\par\noindent\textbf{\solutionname:} }{}}{% } % \end{macrocode} +%\end{macro} +%\begin{macro}{\checkselected} % Check to see if label has been selected % \begin{macrocode} \newcount\@ckselctr -\newcommand{\checkselected}[1]{% +\newcommand*{\checkselected}[1]{% \selectedfalse \@ckselctr=1\relax \whiledo{\@ckselctr < \@probselN \TE@or \@ckselctr = \@probselN}{% @@ -827,6 +864,8 @@ problems.}% }% } % \end{macrocode} +%\end{macro} +%\begin{macro}{\shuffle} % Shuffle contents of pseudo-array. For example, suppose you have % the following definitions: |\def\fooi{A}|, |\def\fooii{B}| and % |\def\fooiii{C}|, then |\shuffle{foo}{3}| will shuffle the @@ -840,18 +879,20 @@ problems.}% \PSNrandom{\@shfA}{#2}\PSNrandom{\@shfB}{#2}% \ifnum\@shfA=\@shfB \else -\edef\@@tmpA{\csname#1\romannumeral\@shfA\endcsname}% -\let\@tmpA=\@@tmpA -\edef\@@tmpB{\csname#1\romannumeral\@shfB\endcsname}% -\let\@tmpB=\@@tmpB -\expandafter\xdef\csname#1\romannumeral\@shfA\endcsname{\@tmpB}% -\expandafter\xdef\csname#1\romannumeral\@shfB\endcsname{\@tmpA}% + \edef\@@tmpA{\csname#1\romannumeral\@shfA\endcsname}% + \let\@tmpA=\@@tmpA + \edef\@@tmpB{\csname#1\romannumeral\@shfB\endcsname}% + \let\@tmpB=\@@tmpB + \expandafter\xdef\csname#1\romannumeral\@shfA\endcsname{\@tmpB}% + \expandafter\xdef\csname#1\romannumeral\@shfB\endcsname{\@tmpA}% \fi \advance\@shfctr by 1\relax }% } % \end{macrocode} -% Syntax: |\doforrandN{|\meta{n}|}{|\meta{cmd}|}{|\meta{list}|}{|\meta{text}|}|. +%\end{macro} +%\begin{macro}{\doforrandN} +% Syntax: \cs{doforrandN}\marg{n}\marg{cmd}\marg{list}\marg{text}. % A bit like |\@for| but only for a random subset of the given list. % For example, %\begin{verbatim} @@ -885,6 +926,7 @@ are only \number\@ps@forrand item(s) in the list}% \fi }} % \end{macrocode} +%\end{macro} %\iffalse % \begin{macrocode} %</probsoln.sty> |