summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/probsoln/probsoln-manual.tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-08-24 00:09:20 +0000
committerKarl Berry <karl@freefriends.org>2011-08-24 00:09:20 +0000
commit00e6529c140ad1858c21526e6f8044aabb399270 (patch)
tree39e376e2630a9135fa211e3945879224c4c8e83b /Master/texmf-dist/doc/latex/probsoln/probsoln-manual.tex
parent9acea66f478ccf41a96c04350796f74e5e74757e (diff)
probsoln 3.01 (22aug11)
git-svn-id: svn://tug.org/texlive/trunk@23668 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/latex/probsoln/probsoln-manual.tex')
-rw-r--r--Master/texmf-dist/doc/latex/probsoln/probsoln-manual.tex573
1 files changed, 276 insertions, 297 deletions
diff --git a/Master/texmf-dist/doc/latex/probsoln/probsoln-manual.tex b/Master/texmf-dist/doc/latex/probsoln/probsoln-manual.tex
index aae8befbed2..c7454082cc1 100644
--- a/Master/texmf-dist/doc/latex/probsoln/probsoln-manual.tex
+++ b/Master/texmf-dist/doc/latex/probsoln/probsoln-manual.tex
@@ -1,99 +1,31 @@
-\documentclass[a4paper]{ltxdoc}
+\documentclass[a4paper]{nlctdoc}
+
+\usepackage[utf8]{inputenc}
+\usepackage[T1]{fontenc}
+\usepackage{lmodern}
+\usepackage{color}
+\usepackage{creatdtx}
+\usepackage{probsoln}
+
\usepackage[colorlinks,
bookmarks,
hyperindex=false,
pdfauthor={Nicola L.C. Talbot},
pdftitle={probsoln: creating problem sheets optionally with solutions}]{hyperref}
+\doxitem{Option}{option}{package options}
-\usepackage{color}
-\usepackage{creatdtx}
-\ifmakedtx{
-\usepackage{probsoln}
\RecordChanges
\PageIndex
-\CheckSum{886}
-
-\renewcommand{\usage}[1]{\textit{\hyperpage{#1}}}
-\renewcommand{\main}[1]{\hyperpage{#1}}
-\newcommand{\see}[2]{\emph{see} #1}
-\makeatletter
-\def\index@prologue{\section*{Index}}
-\makeatother
-\CodelineNumbered
-\newcommand{\dq}[1]{``#1''}
-
-\definecolor{defbackground}{rgb}{0.8,1,1}
-
-\newsavebox\defsbox
-\newlength\defwidth
-\newenvironment{definition}{%
-\setlength{\fboxsep}{4pt}\setlength{\fboxrule}{1.25pt}%
-\begin{lrbox}{\defsbox}%
-\setlength\defwidth\linewidth
-\addtolength\defwidth{-2\fboxrule}%
-\addtolength\defwidth{-2\fboxsep}%
-\begin{minipage}{\defwidth}\flushleft
-}{%
-\end{minipage}
-\end{lrbox}%
-\vskip10pt
-\noindent
-\fcolorbox{black}{defbackground}{\usebox\defsbox}%
-\vskip10pt
-}
+\CheckSum{1144}
-\newlength\boxlength
-\newsavebox\importantbox
-\newenvironment{important}{%
-\setlength{\fboxrule}{4pt}%
-\setlength\boxlength{\linewidth}%
-\addtolength\boxlength{-2\fboxsep}%
-\addtolength\boxlength{-2\fboxrule}%
-\begin{lrbox}{\importantbox}%
-\begin{minipage}{\boxlength}%
-}{\end{minipage}\end{lrbox}%
-\par\vskip10pt\noindent
-\fcolorbox{red}{white}{\usebox{\importantbox}}\par\vskip10pt}
-}
-{
-\usepackage{html}
-\usepackage{makeidx}
-\renewcommand{\LaTeX}{LaTeX}
-\renewcommand{\LaTeXe}{LaTeX2e}
-\newcommand{\dq}[1]{"#1"}
-\newenvironment{important}{\textbf{NOTE:} }{}
-\newenvironment{definition}{\htmlrule}{\htmlrule}
-\html{\newcommand{\SpecialMainIndex}[1]{\index{#1@\cs{#1}}}}
-}
-
-\newcommand*{\ics}[1]{\cs{#1}\SpecialMainIndex{#1}}
+\newcommand*{\dq}[1]{``#1''}
-\ifmakedtx{
-\newcommand{\pkgopt}[1]{\textsf{#1}\index{package options>#1=\textsf{#1}|hyperpage}}
-\newcommand*{\sty}[1]{\textsf{#1}}
-\newcommand*{\isty}[1]{\sty{#1}\index{#1 package=\sty{#1} package|hyperpage}}
-\newcommand*{\env}[1]{\textsf{#1}}
-\newcommand{\ienv}[1]{\env{#1}\index{#1 environment=\env{#1} environment|hyperpage}}
-\newcommand*{\bool}[1]{\textsf{#1}\index{#1 boolean variable=\textsf{#1} boolean variable|hyperpage}}
-\newcommand{\csdef}[1]{\cs{#1}}
-}
-{
-\newcommand{\pkgopt}[1]{\texttt{#1}\index{package options!#1@\texttt{#1}}}
-\newcommand{\sty}[1]{\texttt{#1}}
-\newcommand{\isty}[1]{\sty{#1}\index{#1@\sty{#1}}}
-\newcommand{\env}[1]{\texttt{#1}}
-\newcommand{\ienv}[1]{\env{#1}\index{#1 environment@\env{#1} environment}}
-\newcommand*{\bool}[1]{\texttt{#1}\index{#1 boolean variable@\texttt{#1} boolean variable}}
-\newcommand{\csdef}[1]{\ics{#1}}
-\renewcommand{\DescribeEnv}[1]{\index{#1 environment@\env{#1} environment}}
-\newcommand{\toTop}{\mbox{}\par\htmlref{Top}{top}}
-}
-
-\begin{document}\ifmakedtx{}{\label{top}}
+\begin{document}
\MakeShortVerb{"}
\DeleteShortVerb{\|}
- \title{probsoln v3.0: creating problem sheets optionally with solutions}
+ \title{probsoln v3.01:
+creating problem sheets optionally with solutions}
\author{Nicola L.C. Talbot\\[10pt]
School of Computing Sciences\\
University of East Anglia\\
@@ -101,28 +33,25 @@ Norwich. Norfolk\\
NR4 7TJ. United Kingdom.\\
\url{http://theoval.cmp.uea.ac.uk/~nlct/}}
- \date{26th August 2008}
+ \date{2011-08-22}
\maketitle
\tableofcontents
\section{Introduction}
-The \sty{probsoln} package is designed for teachers or
-lecturers who want to create problem sheets for their
-students. This package was designed with specifically
-mathematics problems in mind, but can be used for other
-subjects as well. The idea is to create a file containing a
-large number of problems with their solutions which can be
-read in by \LaTeX, and then select a number of problems to
-typeset. This means that once the database has been set up,
-each year you can easily create a new problem sheet that is
-sufficiently different from the previous year, thus
-preventing the temptation of current students seeking out
-the previous year's students, and checking out their
-answers. There is also an option that can be passed to the
-package to determine whether or not the solutions should be
-printed. In this way, one file can either produce the
-student's version or the teacher's version.
-\ifmakedtx{}{\toTop}
+The \styfmt{probsoln} package is designed for teachers or lecturers
+who want to create problem sheets for their students. This package
+was designed with mathematics problems in mind, but can be used for
+other subjects as well. The idea is to create a file containing a
+large number of problems with their solutions which can be read in
+by \LaTeX, and then select a number of problems to typeset. This
+means that once the database has been set up, each year you can
+easily create a new problem sheet that is sufficiently different
+from the previous year, thus preventing the temptation of current
+students seeking out the previous year's students, and checking out
+their answers. There is also an option that can be passed to the
+package to determine whether or not the solutions should be printed.
+In this way, one file can either produce the student's version or
+the teacher's version.
\section{Package Options}\label{sec:pkgopt}
The following options may be passed to this package:
@@ -131,18 +60,29 @@ The following options may be passed to this package:
\item[\pkgopt{noanswers}] Don't show the answers (default)
\item[\pkgopt{draft}] Display the label and dataset name when a problem is used
\item[\pkgopt{final}] Don't display label and dataset name when a problem is used
+\item[\pkgopt{usedefaultargs}] Make \ics{thisproblem} use the
+default arguments supplied in the problem definition.
+\item[\pkgopt{nousedefaultargs}] Make \ics{thisproblem} prompt for
+problem arguments (default).
\end{description}
-\ifmakedtx{}{\toTop}
\section{Showing and Hiding Solutions}\label{sec:showanswers}
In addition to the \pkgopt{answers} and \pkgopt{noanswers} package
options, it is also possible to show or suppress the solutions
-using \DescribeMacro{\showanswers}\cs{showanswers} and
-\DescribeMacro{\hideanswers}\cs{hideanswers}, respectively.
+using
+\begin{definition}[\DescribeMacro{\showanswers}]
+\cs{showanswers}
+\end{definition}
+and
+\begin{definition}[\DescribeMacro{\hideanswers}]
+\cs{hideanswers}
+\end{definition}
+respectively.
+
The boolean variable \bool{showanswers} determines whether the
answers should be displayed. You can use this value with the
-\isty{ifthen} package to specify different text depending on
+\sty{ifthen} package to specify different text depending on
whether the solutions should be displayed. For example:
\begin{verbatim}
Assignment 1\ifthenelse{\boolean{showanswers}}{ (Solution Sheet)}{}
@@ -176,87 +116,85 @@ Solution: $f'(x) = 2x$
\end{verbatim}
\begin{important}
You can't use verbatim text in the body of the
-\ienv{onlyproblem} or \ienv{onlysolution} environments.
+\envfmt{onlyproblem} or \envfmt{onlysolution} environments.
If you need verbatim-like text, then try packages such as
-\isty{alltt}. Remember that you also can't use verbatim
+\sty{alltt}. Remember that you also can't use verbatim
text in command arguments.
\end{important}
-\ifmakedtx{}{\toTop}
+
+If you use \envfmt{onlysolution} within the \env{defproblem}
+environment, the problem will be tagged as having a solution
+and will be added to the list used by \ics{foreachsolution}.
\section{General Formatting Commands}\label{sec:formatting}
The commands and environments described in this section are
provided to assist formatting problems and their solutions.
-\DescribeEnv{solution}
-\begin{definition}
+\begin{definition}[\DescribeEnv{solution}]
\verb|\begin{solution}|\meta{text}\verb|\end{solution}|
\end{definition}
-This is equivalent to
-\verb|\par\noindent\textbf{\solutionname}:|\meta{text}
+By default, this is equivalent to
+\begin{display}
+\verb|\par\noindent\textbf{\solutionname}: |\meta{text}
+\end{display}
where \DescribeMacro{\solutionname}\cs{solutionname} defaults
-to \dq{Solution}. Note that you must place the \env{solution}
-environment inside the \ienv{onlysolution} environment or
+to \dq{\solutionname}. Note that you must place the \env{solution}
+environment inside the \envfmt{onlysolution} environment or
between \ics{ifshowanswers}\ldots\cs{fi} to ensure that it
is suppressed when the solutions are not wanted. (See
-\ifmakedtx{\autoref{sec:showanswers}}{\htmlref{Showing and
-Hiding Solutions}{sec:showanswers}}.)
+\sectionref{sec:showanswers}.)
-Note that the \sty{probsoln} package will only define the
+Note that the \styfmt{probsoln} package will only define the
\env{solution} environment if it is not already defined.
-\DescribeEnv{textenum}
-\begin{definition}
+\begin{definition}[\DescribeEnv{textenum}]
\verb|\begin{textenum}|\ldots\verb|\end{textenum}|
\end{definition}
-The \env{textenum} environment is like the \ienv{enumerate}
+The \envfmt{textenum} environment is like the \env{enumerate}
environment but is in-line. It uses the same counter that the
-\env{enumerate} environment would use at that level so the
-question can be compact but the answer can use \env{enumerate}
+\envfmt{enumerate} environment would use at that level so the
+question can be compact but the answer can use \envfmt{enumerate}
instead. For example:
\begin{verbatim}
\begin{onlyproblem}%
-Differentiate the following:
-\begin{textenum}
-\item $f(x)=2^x$;
-\item $f(x)=\cot(x)$
-\end{textenum}
+ Differentiate the following:
+ \begin{textenum}
+ \item $f(x)=2^x$; \item $f(x)=\cot(x)$
+ \end{textenum}
\end{onlyproblem}
\begin{onlysolution}
-\begin{enumerate}
-\item
-\begin{align*}
-f(x) &= 2^x = \exp(\ln(x^2)) =\exp(2\ln(x))\\
-f'(x) &= \exp(2\ln(x))\times \frac{2}{x}\\
- &= f(x)\frac{2}{x}
-\end{align*}
-\item
-\begin{align*}
-f(x) &= \cot(x) = (\tan(x))^{-2}\\
-f'(x) &= -(\tan(x))^{-2}\times\sec^2(x)\\
-&=-\csc^2x
-\end{align*}
-\end{enumerate}
+ \begin{enumerate}
+ \item
+ \begin{align*}
+ f(x) &= 2^x = \exp(\ln(x^2)) =\exp(2\ln(x))\\
+ f'(x) &= \exp(2\ln(x))\times \frac{2}{x}\\
+ &= f(x)\frac{2}{x}
+ \end{align*}
+ \item
+ \begin{align*}
+ f(x) &= \cot(x) = (\tan(x))^{-2}\\
+ f'(x) &= -(\tan(x))^{-2}\times\sec^2(x)\\
+ &=-\csc^2x
+ \end{align*}
+ \end{enumerate}
\end{onlysolution}
\end{verbatim}
In this example, the items in the question are brief, so an
-\ienv{enumerate} environment would result in a lot of
-unnecessary white space,
-but the answers require more space, so an \env{enumerate}
-environment is more appropriate. Since the \ienv{textenum}
-environment uses the same counters as the \env{enumerate}
-environment, the question and answer sheets use consistent
-labelling. Note that there are other packages available on
-CTAN that you can use to create in-line lists. Check the
-\ifmakedtx{\href{http://www.tex.ac.uk/tex-archive/help/Catalogue/bytopic.html\#enumeration}{TeX
-Catalogue}}{\htmladdnormallink{TeX
-Catalogue}{http://www.tex.ac.uk/tex-archive/help/Catalogue/bytopic.html\#enumeration}} for
-further details.
+\env{enumerate} environment would result in a lot of unnecessary
+white space, but the answers require more space, so an
+\envfmt{enumerate} environment is more appropriate. Since the
+\envfmt{textenum} environment uses the same counters as the
+\envfmt{enumerate} environment, the question and answer sheets use
+consistent labelling. Note that there are other packages available
+on CTAN that you can use to create in-line lists. Check the
+\urlfootref{http://www.tex.ac.uk/tex-archive/help/Catalogue/bytopic.html\#enumeration}{TeX
+Catalogue} for further details.
\DescribeMacro{\correctitem}\DescribeMacro{\incorrectitem}
\begin{definition}
-\csdef{correctitem}\\
-\csdef{incorrectitem}
+\cs{correctitem}\\
+\cs{incorrectitem}
\end{definition}
You can use the commands \cs{correctitem} and \cs{incorrectitem}
in place of \ics{item}. If the solutions are suppressed, these
@@ -264,8 +202,8 @@ commands behave in the same way as \cs{item}, otherwise they
format the item label using one of the commands:
\DescribeMacro{\correctitemformat}\DescribeMacro{\incorrectitemformat}
\begin{definition}
-\csdef{correctitemformat}\marg{label}\\
-\csdef{incorrectitemformat}\marg{label}
+\cs{correctitemformat}\marg{label}\\
+\cs{incorrectitemformat}\marg{label}
\end{definition}
For example:
\begin{verbatim}
@@ -278,52 +216,50 @@ become a probability space?
\incorrectitem $P(a_1)=\frac{5}{4}$, $P(a_2)=-\frac{1}{4}$
\end{enumerate}
\end{verbatim}
-\ifmakedtx{}{\toTop}
+The default definition of \cs{correctitemformat} puts a frame around
+the label.
\section{Defining a Problem}\label{sec:defproblem}
-It is possible to construct a problem sheet with solutions using
-the commands described in the previous sections, however it is
-also possible to define a set of problems for later use. In this
-way you can create an external file containing many problems some
-or all of which can be loaded and used in a document. The
-\sty{probsoln} package has a default data set labelled
-\dq{default} in which you can store problems or you can create
-multiple data sets. You can then iterate through each problem
-in a problem set. You can use a previously defined problem more
-than once, which means that by judicious use of \ienv{onlyproblem},
-\ienv{onlysolution} or the \bool{showanswers} boolean variable
-in conjunction with \ics{showanswers} and \ics{hideanswers},
-you can print the solutions in a different location to the
-questions (for example in an appendix).
-
-\DescribeEnv{defproblem}
-\begin{definition}
-\verb|\begin{defproblem}|\oarg{n}\marg{label}\meta{definition}\verb|\end{defproblem}|
+It is possible to construct a problem sheet with solutions using the
+commands described in the previous sections, however it is also
+possible to define a set of problems for later use. In this way you
+can create an external file containing many problems some or all of
+which can be loaded and used in a document. The \styfmt{probsoln}
+package has a default data set labelled \dq{default} in which you
+can store problems. Alternatively, you can create multiple data
+sets. You can then iterate through each problem in a problem set.
+You can use a previously defined problem more than once, which means
+that by judicious use of \env{onlyproblem}, \env{onlysolution} or
+the \bool{showanswers} boolean variable in conjunction with
+\ics{showanswers} and \ics{hideanswers}, you can print the solutions
+in a different location to the questions (for example in an
+appendix).
+
+\begin{definition}[\DescribeEnv{defproblem}]
+\verb|\begin{defproblem}|\oarg{n}\oarg{default args}\marg{label}\newline
+\meta{definition}\newline
+\verb|\end{defproblem}|
\end{definition}
-This defines the problem whose label is given by \meta{label}.
-The label must be unique for a given data set and should not
-contain active characters. (Active characters include the special
-characters such as \$ and \&, but some packages may make other
-symbols active. For example, the \isty{ngerman} and \isty{babel}
-packages make certain punctuation active. Check the relevant
-package documentation for details.)
+This defines the problem whose label is given by \meta{label}. The
+label must be unique for a given data set and should not contain
+active characters or a comma. (Active characters include the special characters
+such as \$ and \&, but some packages may make other symbols active,
+such as the colon (:) character. For example, the \sty{ngerman} and
+\sty{babel} packages make certain punctuation active. Check the
+relevant package documentation for details.)
If \env{defproblem} occurs in the document or is included via
-\cs{input} or \cs{include}, then the problem will be added to
-the default data set. If \env{defproblem} occurs in an external
+\ics{input} or \ics{include}, then the problem will be added to
+the default data set. If \envfmt{defproblem} occurs in an external
file that is loaded using one of the commands defined in
-\ifmakedtx{\autoref{sec:load}}{\htmlref{Loading Problems From
-External Files}{sec:load}} then the problem will be added to
+\sectionref{sec:load} then the problem will be added to
the specified data set.
-The contents of the \env{defproblem} environment should be the
-text that defines the problem. This may include any of the
-commands defined in
-\ifmakedtx{\autoref{sec:showanswers} and
-\autoref{sec:formatting}}{\htmlref{Showing and Hiding
-Solutions}{sec:showanswers} and \htmlref{General Formatting
-Commands}{sec:formatting}}.
+The contents of the \env{defproblem} environment should be the text
+that defines the problem. This may include any of the commands
+defined in \sectionref{sec:showanswers} and
+\sectionref{sec:formatting}.
The problem may optionally take \meta{n} arguments (where
\meta{n} is from 0 to 9). The arguments can be referenced
@@ -335,20 +271,35 @@ The following example defines a problem with one argument:
\begin{defproblem}[1]{diffsin}
Differentiate $f(x)=\sin(#1x)$.
\begin{onlysolution}%
-\begin{solution}
-$f'(x) = #1\cos(#1x)$
-\end{solution}
+ \begin{solution}
+ $f'(x) = #1\cos(#1x)$
+ \end{solution}
\end{onlysolution}
\end{defproblem}
\end{verbatim}
-\DescribeMacro{\newproblem}
-\begin{definition}
-\csdef{newproblem}\oarg{n}\marg{label}\marg{problem}\marg{solution}
+The second optional argument \meta{default args} supplies
+default problem arguments that will automatically be used within
+\ics{thisproblem} when used in \ics{foreachproblem} in conjunction
+with the package option \pkgopt{usedefaultargs}. (See \sectionref{sec:foreach}.)
+For example:
+\begin{verbatim}
+\begin{defproblem}[1][{2}]{diffsin}
+Differentiate $f(x)=\sin(#1x)$.
+\begin{onlysolution}%
+ \begin{solution}
+ $f'(x) = #1\cos(#1x)$
+ \end{solution}
+\end{onlysolution}
+\end{defproblem}
+\end{verbatim}
+
+\begin{definition}[\DescribeMacro{\newproblem}]
+\cs{newproblem}\oarg{n}\oarg{default args}\marg{label}\marg{problem}\marg{solution}
\end{definition}
This is a shortcut command for:
\begin{ttfamily}\obeylines
-\cs{begin}\{defproblem\}\oarg{n}\marg{label}\%
+\cs{begin}\{defproblem\}\oarg{n}\oarg{default args}\marg{label}\%
\meta{problem}\%
\cs{begin}\{onlysolution\}\%
\cs{begin}\{solution\}\%
@@ -360,65 +311,72 @@ This is a shortcut command for:
For example:
\begin{verbatim}
\newproblem[1]{diffsin}{%
-\(f(x) = \sin(#1x)\)
-}{%
-\(f'(x) = #1\cos(#1x)\)
+ \(f(x) = \sin(#1x)\)
+}%
+{%
+ \(f'(x) = #1\cos(#1x)\)
}
\end{verbatim}
is equivalent to
\begin{verbatim}
\begin{defproblem}[1]{diffcos}%
-\(f(x) = \cos(#1x)\)
+ \(f(x) = \cos(#1x)\)
\begin{onlysolution}%
-\begin{solution}%
-\(f'(x) = -#1\sin(#1x)\)
-\end{solution}%
+ \begin{solution}%
+ \(f'(x) = -#1\sin(#1x)\)
+ \end{solution}%
\end{onlysolution}%
\end{defproblem}
\end{verbatim}
(In this example, the argument will need to be a positive number
to avoid a double minus in the answer. If you want to perform
floating point arithmetic on the arguments, then try the
-\isty{fp} package.)
+\sty{fp} or \sty{pgfmath} packages.)
-\DescribeMacro{\newproblem*}
-\begin{definition}
-\csdef{newproblem*}\oarg{n}\marg{label}\marg{definition}
+Alternatively, if you want to supply default arguments to use when
+iterating through problems with \ics{foreachproblem}:
+\begin{verbatim}
+\newproblem[1][{3}]{diffsin}{%
+ \(f(x) = \sin(#1x)\)
+}%
+{%
+ \(f'(x) = #1\cos(#1x)\)
+}
+\end{verbatim}
+
+
+\begin{definition}[\DescribeMacro{\newproblem*}]
+\cs{newproblem*}\oarg{n}\oarg{default args}\marg{label}\marg{definition}
\end{definition}
This is a shortcut for:
\begin{ttfamily}\obeylines
-\cs{begin}\{defproblem\}\oarg{n}\marg{label}\%
+\cs{begin}\{defproblem\}\oarg{n}\oarg{default args}\marg{label}\%
\meta{definition}\%
\cs{end}\{defproblem\}
\end{ttfamily}
\begin{important}
-Verbatim text must not be used in the contents of \ienv{defproblem}
+Verbatim text must not be used in the contents of \env{defproblem}
or in any of the arguments to \cs{newproblem} or
\cs{newproblem*}. If you need verbatim-like text consider using
-\cs{texttt} or the \isty{alltt} package.
+\cs{texttt} or the \sty{alltt} package.
\end{important}
-\ifmakedtx{}{\toTop}
\section{Using a Problem}\label{sec:useproblem}
-Once you have defined a problem using \ienv{defproblem} or
-\cs{newproblem} (see
-\ifmakedtx{\autoref{sec:defproblem}}{\htmlref{Defining a
-Problem}{sec:defproblem}}), you can later display the problem
-using:
-\DescribeMacro{\useproblem}
-\begin{definition}
-\csdef{useproblem}\oarg{data set}\marg{label}\marg{arg\ifmakedtx{$_1$}{\HTMLcode{SUB}{1}}}\ldots
-\marg{arg\ifmakedtx{$_N$}{\HTMLcode{SUB}{N}}}
+Once you have defined a problem using \env{defproblem} or
+\ics{newproblem} (see \sectionref{sec:defproblem}), you can
+later display the problem using:
+\begin{definition}[\DescribeMacro{\useproblem}]
+\cs{useproblem}\oarg{data set}\marg{label}\marg{arg$_1$}\ldots
+\marg{arg$_N$}
\end{definition}
where \meta{data set} is the name of the data set that contains
the problem (the default data set is used if omitted),
\meta{label} is the label identifying the required problem and
-\meta{arg\ifmakedtx{$_1$}{\HTMLcode{SUB}{1}}}, \ldots,
-\meta{arg\ifmakedtx{$N$}{\HTMLcode{SUB}{N}}}
+\meta{arg$_1$}, \ldots, \meta{arg$_N$}
are the arguments to pass to the problem, if the problem was
-defined to have arguments (where \ifmakedtx{$N$}{N} is the number
+defined to have arguments (where $N$ is the number
of arguments specified when the problem was defined).
For example, in the previous section the problem \texttt{diffcos}
@@ -435,26 +393,22 @@ This will be equivalent to:
\end{solution}%
\end{onlysolution}%
\end{verbatim}
-\ifmakedtx{}{\toTop}
\section{Loading Problems From External Files}\label{sec:load}
You can store all your problem definitions (see
-\ifmakedtx{\autoref{sec:defproblem}}{\htmlref{Defining New
-Problems}{sec:defproblem}}) in an external file.
+\sectionref{sec:defproblem}) in an external file.
These problems can all be appended to the default data set by
including the file via \ics{input} or they can be appended
to other data sets using one of the commands described below.
Once you have loaded all the required problems, you can
iterate through the data sets using the commands described
-in \ifmakedtx{\autoref{sec:foreach}}{\htmlref{Iterating
-Through Datasets}{sec:foreach}}. Note that the commands below
+in \sectionref{sec:foreach}. Note that the commands below
will create a new data set, if the named data set doesn't
exist.
-\DescribeMacro{\loadallproblems}
-\begin{definition}
-\csdef{loadallproblems}\oarg{data set}\marg{filename}
+\begin{definition}[\DescribeMacro{\loadallproblems}]
+\cs{loadallproblems}\oarg{data set}\marg{filename}
\end{definition}
This will load all problems defined in \meta{filename} and
append them to the specified data set, in the order in which
@@ -462,11 +416,10 @@ they are defined in the file. If \meta{data set} is
omitted, the default data set will be used. If \meta{data set}
doesn't exist, it will be created.
-\DescribeMacro{\loadselectedproblems}
-\begin{definition}
-\csdef{loadselectedproblems}\oarg{data set}\marg{labels}\marg{filename}
+\begin{definition}[\DescribeMacro{\loadselectedproblems}]
+\cs{loadselectedproblems}\oarg{data set}\marg{labels}\marg{filename}
\end{definition}
-This is like \cs{loadproblems}, but only those problems whose
+This is like \cs{loadallproblems}, but only those problems whose
label is listed in the comma-separated list \meta{labels} are
loaded. For example, if I have some problems defined in the
file \texttt{derivatives.tex}, then
@@ -477,9 +430,15 @@ will only load the problems whose labels are \texttt{diffsin}
and \texttt{diffcos}, respectively. All the other problems in
the file will remain undefined.
-\DescribeMacro{\loadrandomproblems}
-\begin{definition}
-\csdef{loadrandomproblems}\oarg{data set}\marg{n}\marg{filename}
+\begin{definition}[\DescribeMacro{\loadexceptproblems}]
+\cs{loadexceptproblems}\oarg{data set}\marg{exception list}\marg{filename}
+\end{definition}
+This is the reverse of \cs{loadselectedproblems}. This loads all
+problems except those whose labels are listed in \meta{exception
+list}.
+
+\begin{definition}[\DescribeMacro{\loadrandomproblems}]
+\cs{loadrandomproblems}\oarg{data set}\marg{n}\marg{filename}
\end{definition}
This randomly loads \meta{n} problems from \meta{filename} and
adds them to the given data set. If \meta{data set} is omitted,
@@ -488,45 +447,65 @@ added to the data set in a random order, not in the order in
which they were defined. There must be at least \meta{n} problems
defined in \meta{filename}.
+\begin{definition}[\DescribeMacro{\loadrandomexcept}]
+\cs{loadrandomexcept}\oarg{data
+set}\marg{n}\marg{filename}\marg{exception list}
+\end{definition}
+This is similar to \cs{loadrandomproblems} except that it won't load
+those problems whose labels are listed in \meta{exception list}.
+
+Note that the random number generator has been modified in version
+3.01 in order to fix a bug. If you want to ensure that your random
+numbers are compatible with earlier versions, you can switch to the
+old generator using
+\begin{definition}[\DescribeMacro{\PSNuseoldrandom}]
+\cs{PSNuseoldrandom}
+\end{definition}
+
\begin{important}
It is generally not a good idea to place anything in
-\meta{filename} that is not inside the body of \ienv{defproblem}
+\meta{filename} that is not inside the body of \env{defproblem}
or in the arguments to \ics{newproblem} or \ics{newproblem*}.
All the commands in this section input the external file within
-a local scope, so commands definitions would need to be made
+a local scope, so command definitions would need to be made
global to have any effect. In addition, \cs{loadrandomproblems}
has to load each file twice, which means that anything outside
a problem definition will be parsed twice.
\end{important}
-\ifmakedtx{}{\toTop}
-
\section{Iterating Through Datasets}\label{sec:foreach}
-Once you have defined all your problems for a given data set,
-you can use an individual problem with \ics{useproblem}
-(see \ifmakedtx{\autoref{sec:useproblem}}{\htmlref{Using a
-Problem}{sec:useproblem}}) but it is more likely that you will
-want to iterate through all the problems so that you don't need
-to remember the labels of all the problems you have defined.
+Once you have defined all your problems for a given data set, you
+can use an individual problem with \ics{useproblem} (see
+\sectionref{sec:useproblem}) but it is more likely that you will
+want to iterate through all the problems so that you don't need to
+remember the labels of all the problems you have defined.
-\DescribeMacro{\foreachproblem}
-\begin{definition}
-\csdef{foreachproblem}\oarg{data set}\marg{body}
+\begin{definition}[\DescribeMacro{\foreachproblem}]
+\cs{foreachproblem}\oarg{data set}\marg{body}
\end{definition}
This does \meta{body} for each problem in the given data set.
If \meta{data set} is omitted, the default data set is used.
Within \meta{body} you can use
-\DescribeMacro{\thisproblem}\cs{thisproblem} to use the
-current problem and \DescribeMacro{\thisproblemlabel}\cs{thisproblemlabel}
+\begin{definition}[\DescribeMacro{\thisproblem}]
+\cs{thisproblem}
+\end{definition}
+to use the current problem and
+\begin{definition}[\DescribeMacro{\thisproblemlabel}]
+\cs{thisproblemlabel}
+\end{definition}
to access the current label. If the problem requires arguments,
-you will be prompted for them, so if you want to use this
+and no default arguments were supplied in the problem definition or
+the package option \pkgopt{usedefaultargs} was not used, then
+you will be prompted for arguments, so if you want to use this
approach you will need to use \LaTeX\ in interactive mode. If
you do provide arguments, they will be stored in the event that
you need to iterate through the data set again. The
arguments will be included in \cs{thisproblem}, so you only
need to use \cs{thisproblem} without having to specify
-\ics{useproblem}. For example, to iterate through all problems
+\ics{useproblem}.
+
+For example, to iterate through all problems
in the default data set:
\begin{verbatim}
\begin{enumerate}
@@ -534,9 +513,17 @@ in the default data set:
\end{enumerate}
\end{verbatim}
-\DescribeMacro{\foreachdataset}
-\begin{definition}
-\csdef{foreachdataset}\marg{cmd}\marg{body}
+\begin{definition}[\DescribeMacro{\foreachsolution}]
+\cs{foreachsolution}\oarg{data set}\marg{body}
+\end{definition}
+This is equivalent to \cs{foreachsolution}, but only iterates
+through problems that contain the \env{onlysolution} environment.
+Note that you still need to use \ics{showanswers} or the
+\pkgopt{answers} package option for the contents of the
+\env{onlysolution} environment to appear.
+
+\begin{definition}[\DescribeMacro{\foreachdataset}]
+\cs{foreachdataset}\marg{cmd}\marg{body}
\end{definition}
This does \meta{body} for each of the defined data sets. Within
\meta{body}, \meta{cmd} will be set to the name of the current
@@ -550,8 +537,8 @@ data set. For example, to display all problems in all data sets:
Suppose I have two external files called
\texttt{derivatives.tex} and \texttt{probspaces.tex} which
-define problems using both \ienv{onlyproblem} and
-\ienv{onlysolution} for example:
+define problems using both \env{onlyproblem} and
+\env{onlysolution} for example:
\begin{verbatim}
\begin{defproblem}{cosxsqsinx}%
\begin{onlyproblem}%
@@ -569,7 +556,7 @@ iterate through the require data set to produce the problems.
Later, I can use \ics{showanswers} and iterate over all problems defined in both data
sets to produce the chapter containing all the answers. When
displaying the questions, I have taken advantage of the fact that
-I can cross-reference items within an \ienv{enumerate} environment,
+I can cross-reference items within an \env{enumerate} environment,
and redefined \ics{theenumi} to label the questions according to
the chapter. The cross-reference label is constructed from
the problem label and is referenced in the answer section to
@@ -616,16 +603,19 @@ ensure that the answers have the same label as the questions.
\end{document}
\end{verbatim}
-\ifmakedtx{}{\toTop}
-
\section{Random Number Generator}\label{sec:random}
This package provides a pseudo-random number generator that is used
-by \ics{loadrandomproblems}.
+by \ics{loadrandomproblems}. As noted earlier the random number
+generator has been modified in version 3.01 in order to fix a bug.
+If you want to ensure that your random numbers are compatible with
+earlier versions, you can switch to the old generator using
+\begin{definition}[\DescribeMacro{\PSNuseoldrandom}]
+\cs{PSNuseoldrandom}
+\end{definition}
-\DescribeMacro{\PSNrandseed}
-\begin{definition}
-\csdef{PSNrandseed}\marg{n}
+\begin{definition}[\DescribeMacro{\PSNrandseed}]
+\cs{PSNrandseed}\marg{n}
\end{definition}
This sets the seed to \meta{n} which must be a non-zero integer.
For example, to generate a different set of random numbers
@@ -641,9 +631,8 @@ or to generate a different set of random numbers every year you
\PSNrandseed{\year}
\end{verbatim}
-\DescribeMacro{\PSNgetrandseed}
-\begin{definition}
-\csdef{PSNgetrandseed}\marg{register}
+\begin{definition}[\DescribeMacro{\PSNgetrandseed}]
+\cs{PSNgetrandseed}\marg{register}
\end{definition}
This stores the current seed in the count register specified by
\meta{register}.
@@ -653,9 +642,8 @@ For example:
\PSNgetrandseed{\myseed}
\end{verbatim}
-\DescribeMacro{\PSNrandom}
-\begin{definition}
-\csdef{PSNrandom}\marg{register}\marg{n}
+\begin{definition}[\DescribeMacro{\PSNrandom}]
+\cs{PSNrandom}\marg{register}\marg{n}
\end{definition}
Generates a random integer from 1 to \meta{n} and stores in
the count register specified by \meta{register}. For example,
@@ -666,9 +654,8 @@ in the register \cs{myreg}:
\PSNrandom{\myreg}{10}
\end{verbatim}
-\DescribeMacro{\random}
-\begin{definition}
-\csdef{random}\marg{counter}\marg{min}\marg{max}
+\begin{definition}[\DescribeMacro{\random}]
+\cs{random}\marg{counter}\marg{min}\marg{max}
\end{definition}
Generates a random integer from \meta{min} to \meta{max} and
stores in the given counter. For example, the following generates
@@ -679,9 +666,8 @@ the counter \texttt{myrand}.
\random{myrand}{3}{8}
\end{verbatim}
-\DescribeMacro{\doforrandN}
-\begin{definition}
-\csdef{doforrandN}\marg{n}\marg{cmd}\marg{list}\marg{text}
+\begin{definition}[\DescribeMacro{\doforrandN}]
+\cs{doforrandN}\marg{n}\marg{cmd}\marg{list}\marg{text}
\end{definition}
Randomly selects \meta{n} values from the comma-separated list
given by \meta{list} and iterates through this subset. On
@@ -695,8 +681,6 @@ are files containing at least one problem):
\loadrandomproblems{1}{\thisfile}}
\end{verbatim}
-\ifmakedtx{}{\toTop}
-
\section{Compatibility With Versions Prior to 3.0}
Version 3.0 of the \sty{probsoln} package completely changed the
@@ -750,32 +734,27 @@ would need to be modified so that it becomes:
\end{enumerate}
\end{verbatim}
-\DescribeMacro{\selectrandomly}
-\begin{definition}
-\csdef{selectrandomly}\marg{filename}\marg{n}
+\begin{definition}[\DescribeMacro{\selectrandomly}]
+\cs{selectrandomly}\marg{filename}\marg{n}
\end{definition}
This is now equivalent to:
\begin{ttfamily}\obeylines
\{\cs{loadrandomproblems}\oarg{filename}\marg{n}\marg{filename}\}\%
-\cs{foreachproblem}\oarg{filename}\marg{\cs{PSNitem}\cs{thisproblem}\cs{endPSNitem}}
+\cs{foreachproblem}\oarg{filename}\{\cs{PSNitem}\cs{thisproblem}\cs{endPSNitem}\}
\end{ttfamily}
-\DescribeMacro{\selectallproblems}
-\begin{definition}
-\csdef{selectallproblems}\marg{filename}
+\begin{definition}[\DescribeMacro{\selectallproblems}]
+\cs{selectallproblems}\marg{filename}
\end{definition}
This is now equivalent to:
\begin{ttfamily}\obeylines
\{\cs{loadallproblems}\oarg{filename}\marg{filename}\}\%
-\cs{foreachproblem}\oarg{filename}\marg{\cs{PSNitem}\cs{thisproblem}\cs{endPSNitem}}
+\cs{foreachproblem}\oarg{filename}\{\cs{PSNitem}\cs{thisproblem}\cs{endPSNitem}\}
\end{ttfamily}
Note that in both the above cases, a new data set is created
with the same name as the file name.
-\ifmakedtx{}{\toTop}
-
\StopEventually{\clearpage\phantomsection\addcontentsline{toc}{section}{Index}\PrintIndex}
-\ifmakedtx{}{\printindex\toTop}
\end{document}