From 00e6529c140ad1858c21526e6f8044aabb399270 Mon Sep 17 00:00:00 2001
From: Karl Berry
Date: Wed, 24 Aug 2011 00:09:20 +0000
Subject: probsoln 3.01 (22aug11)
git-svn-id: svn://tug.org/texlive/trunk@23668 c570f23f-e606-0410-a88d-b1316a301751
---
Master/texmf-dist/doc/latex/probsoln/CHANGES | 20 +
Master/texmf-dist/doc/latex/probsoln/INSTALL | 61 +
Master/texmf-dist/doc/latex/probsoln/README | 9 +-
.../doc/latex/probsoln/probsoln-manual.css | 217 ++
.../doc/latex/probsoln/probsoln-manual.html | 3110 ++++++++++++++------
.../doc/latex/probsoln/probsoln-manual.tex | 573 ++--
Master/texmf-dist/doc/latex/probsoln/probsoln.pdf | Bin 267801 -> 513880 bytes
.../doc/latex/probsoln/samples/1stprncp.tex | 61 -
.../texmf-dist/doc/latex/probsoln/samples/args.tex | 45 -
.../texmf-dist/doc/latex/probsoln/samples/easy.tex | 85 -
.../doc/latex/probsoln/samples/easy2.tex | 135 -
.../doc/latex/probsoln/samples/implicit.tex | 41 -
.../doc/latex/probsoln/samples/mchoice.tex | 34 -
.../doc/latex/probsoln/samples/newdata.tex | 26 -
.../doc/latex/probsoln/samples/nosoln.tex | 7 -
.../doc/latex/probsoln/samples/probspaces.tex | 31 -
.../doc/latex/probsoln/samples/probspaces2.tex | 41 -
.../doc/latex/probsoln/samples/sample.pdf | Bin 0 -> 127508 bytes
.../doc/latex/probsoln/samples/sample.tex | 94 +-
.../doc/latex/probsoln/samples/sample2.pdf | Bin 0 -> 84355 bytes
.../doc/latex/probsoln/samples/sample2.tex | 56 +-
.../doc/latex/probsoln/samples/sample3.pdf | Bin 0 -> 31913 bytes
.../doc/latex/probsoln/samples/sample3.tex | 56 +-
.../doc/latex/probsoln/samples/sample4.pdf | Bin 0 -> 91475 bytes
.../doc/latex/probsoln/samples/sample4.tex | 62 +-
.../doc/latex/probsoln/samples/sample5.pdf | Bin 0 -> 74009 bytes
.../doc/latex/probsoln/samples/sample5.tex | 57 +-
.../doc/latex/probsoln/samples/sample6.tex | 62 +
.../doc/latex/probsoln/samples/sample7.tex | 71 +
.../doc/latex/probsoln/samples/tabmchoice.tex | 16 -
.../texmf-dist/source/latex/probsoln/probsoln.dtx | 1939 +++++++-----
.../texmf-dist/source/latex/probsoln/probsoln.ins | 60 +-
Master/texmf-dist/tex/latex/probsoln/probsoln.sty | 447 ++-
33 files changed, 4751 insertions(+), 2665 deletions(-)
create mode 100644 Master/texmf-dist/doc/latex/probsoln/INSTALL
create mode 100644 Master/texmf-dist/doc/latex/probsoln/probsoln-manual.css
delete mode 100644 Master/texmf-dist/doc/latex/probsoln/samples/1stprncp.tex
delete mode 100644 Master/texmf-dist/doc/latex/probsoln/samples/args.tex
delete mode 100644 Master/texmf-dist/doc/latex/probsoln/samples/easy.tex
delete mode 100644 Master/texmf-dist/doc/latex/probsoln/samples/easy2.tex
delete mode 100644 Master/texmf-dist/doc/latex/probsoln/samples/implicit.tex
delete mode 100644 Master/texmf-dist/doc/latex/probsoln/samples/mchoice.tex
delete mode 100644 Master/texmf-dist/doc/latex/probsoln/samples/newdata.tex
delete mode 100644 Master/texmf-dist/doc/latex/probsoln/samples/nosoln.tex
delete mode 100644 Master/texmf-dist/doc/latex/probsoln/samples/probspaces.tex
delete mode 100644 Master/texmf-dist/doc/latex/probsoln/samples/probspaces2.tex
create mode 100644 Master/texmf-dist/doc/latex/probsoln/samples/sample.pdf
create mode 100644 Master/texmf-dist/doc/latex/probsoln/samples/sample2.pdf
create mode 100644 Master/texmf-dist/doc/latex/probsoln/samples/sample3.pdf
create mode 100644 Master/texmf-dist/doc/latex/probsoln/samples/sample4.pdf
create mode 100644 Master/texmf-dist/doc/latex/probsoln/samples/sample5.pdf
create mode 100644 Master/texmf-dist/doc/latex/probsoln/samples/sample6.tex
create mode 100644 Master/texmf-dist/doc/latex/probsoln/samples/sample7.tex
delete mode 100644 Master/texmf-dist/doc/latex/probsoln/samples/tabmchoice.tex
(limited to 'Master')
diff --git a/Master/texmf-dist/doc/latex/probsoln/CHANGES b/Master/texmf-dist/doc/latex/probsoln/CHANGES
index d360323d06f..831d13648ec 100644
--- a/Master/texmf-dist/doc/latex/probsoln/CHANGES
+++ b/Master/texmf-dist/doc/latex/probsoln/CHANGES
@@ -1,5 +1,25 @@
probsoln package versions:
+version 3.01:
+
+ * Problems may now contain floats in their definition
+
+ * Problems with arguments may now specify a default argument
+ to be used with \foreachproblem and new package option
+ "usedefaultargs"
+
+ * Added \foreachsolution
+
+ * Fixed bug in random number generator when n = 7. (Use
+ \PSNuseoldrandom to ensure compatibility with older versions.)
+
+ * \loadrandomproblems generates a warning instead of an error
+ when more problems are requested than the maximum number
+
+ * Added \loadexceptproblems and \loadrandomexcept
+
+ * substr package no longer required
+
Version 3.0: Rewrote package to use data sets to make it easy
to reuse problems so that the solutions can be placed in
a different section of the document to the questions.
diff --git a/Master/texmf-dist/doc/latex/probsoln/INSTALL b/Master/texmf-dist/doc/latex/probsoln/INSTALL
new file mode 100644
index 00000000000..e6d2957df13
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/probsoln/INSTALL
@@ -0,0 +1,61 @@
+INSTALLATION
+
+If you have downloaded the probsoln package using the TeX Directory
+Structure (TDS), that is you have downloaded an archive containing
+doc, tex and source directories, you need to follow the
+"Installing from TDS" instructions below.
+
+If you have downloaded the following files:
+
+probsoln.dtx
+probsoln.ins
+
+You need to follow the "Installing from DTX and INS" instructions
+below.
+
+For further information on installing LaTeX packages see:
+
+http://www.tex.ac.uk/cgi-bin/texfaq2html?label=installthings
+
+INSTALLING FROM TDS
+===================
+
+Files in tex and doc directories should go in the
+corresponding TEXMF directories (for example, /usr/share/texmf-local/
+or C:\localtexmf\).
+
+*Remember to refresh TeX's database*
+
+
+INSTALLING FROM DTX AND INS
+===========================
+
+Run LaTeX on probsoln.ins to generate the probsoln.sty and the
+sample files:
+
+latex probsoln.ins
+
+To create the package documentation (probsoln.pdf):
+
+pdflatex probsoln.dtx
+makeindex -s gind.ist probsoln.idx
+pdflatex probsoln.dtx
+pdflatex probsoln.dtx
+
+If TEXMF denotes the base directory of your local TeX installation (e.g.
+/usr/share/texmf-local/ or C:\localtexmf\) then create the following
+directories (if they don't already exist):
+
+TEXMF/doc/latex/probsoln
+TEXMF/doc/latex/probsoln/samples
+TEXMF/tex/latex/probsoln
+
+Move the sample files (*.tex) to TEXMF/doc/latex/probsoln/sample/
+
+Move the documentation (*.pdf) to TEXMF/doc/latex/probsoln/
+
+Move probsoln.sty to TEXMF/tex/latex/probsoln/
+
+
+*Remember to refresh TeX's database*
+
diff --git a/Master/texmf-dist/doc/latex/probsoln/README b/Master/texmf-dist/doc/latex/probsoln/README
index a6da627ffdd..7eb0964cf5b 100644
--- a/Master/texmf-dist/doc/latex/probsoln/README
+++ b/Master/texmf-dist/doc/latex/probsoln/README
@@ -1,6 +1,6 @@
-LaTeX Package : probsoln v 3.0
+LaTeX Package : probsoln v3.01
-Last Modified : 26 Aug 2008
+Last Modified : 2011-08-22
Author : Nicola L.C. Talbot
@@ -19,6 +19,11 @@ the problems can be defined along with the problem, making
it easy to generate the solution sheet from the same source
code.
+Required packages:
+
+ifthen
+amsmath
+
To extract the code do:
latex probsoln.ins
diff --git a/Master/texmf-dist/doc/latex/probsoln/probsoln-manual.css b/Master/texmf-dist/doc/latex/probsoln/probsoln-manual.css
new file mode 100644
index 00000000000..0581f0a1a53
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/probsoln/probsoln-manual.css
@@ -0,0 +1,217 @@
+
+/* start css.sty */
+.ec-lmr-17{font-size:170%;}
+.ec-lmr-12{font-size:120%;}
+.ec-lmtt-12{font-size:120%; font-family: monospace;}
+.ec-lmtt-12{ font-family: monospace;}
+.ec-lmtt-12{ font-family: monospace;}
+.ec-lmtt-12{ font-family: monospace;}
+.ec-lmtt-12{ font-family: monospace;}
+.ec-lmtt-12{ font-family: monospace;}
+.ec-lmtt-12{ font-family: monospace;}
+.ec-lmtt-12{ font-family: monospace;}
+.ec-lmtt-12{ font-family: monospace;}
+.ec-lmtt-12{ font-family: monospace;}
+.ec-lmtt-12{ font-family: monospace;}
+.ec-lmtt-12{ font-family: monospace;}
+.ec-lmtt-10{ font-family: monospace;}
+.ec-lmtt-10{ font-family: monospace;}
+.ec-lmtt-10{ font-family: monospace;}
+.ec-lmtt-10{ font-family: monospace;}
+.ec-lmtt-10{ font-family: monospace;}
+.ec-lmtt-10{ font-family: monospace;}
+.ec-lmtt-10{ font-family: monospace;}
+.ec-lmtt-10{ font-family: monospace;}
+.ec-lmtt-10{ font-family: monospace;}
+.ec-lmtt-10{ font-family: monospace;}
+.ec-lmtt-10{ font-family: monospace;}
+.ec-lmtt-10{ font-family: monospace;}
+.ec-lmss-10{ font-family: sans-serif;}
+.ec-lmss-10{ font-family: sans-serif;}
+.ec-lmss-10{ font-family: sans-serif;}
+.ec-lmss-10{ font-family: sans-serif;}
+.ec-lmss-10{ font-family: sans-serif;}
+.ec-lmss-10{ font-family: sans-serif;}
+.ec-lmss-10{ font-family: sans-serif;}
+.ec-lmss-10{ font-family: sans-serif;}
+.ec-lmss-10{ font-family: sans-serif;}
+.ec-lmss-10{ font-family: sans-serif;}
+.ec-lmss-10{ font-family: sans-serif;}
+.ec-lmss-10{ font-family: sans-serif;}
+.ec-lmbx-10{ font-weight: bold;}
+.ec-lmbx-10{ font-weight: bold;}
+.ec-lmbx-10{ font-weight: bold;}
+.ec-lmbx-10{ font-weight: bold;}
+.ec-lmbx-10{ font-weight: bold;}
+.ec-lmbx-10{ font-weight: bold;}
+.ec-lmbx-10{ font-weight: bold;}
+.ec-lmbx-10{ font-weight: bold;}
+.ec-lmbx-10{ font-weight: bold;}
+.ec-lmbx-10{ font-weight: bold;}
+.ec-lmbx-10{ font-weight: bold;}
+.ec-lmbx-10{ font-weight: bold;}
+.ec-lmssbx-10{ font-family: sans-serif; font-weight: bold;}
+.ec-lmssbx-10{ font-family: sans-serif; font-weight: bold;}
+.ec-lmssbx-10{ font-family: sans-serif; font-weight: bold;}
+.ec-lmssbx-10{ font-family: sans-serif; font-weight: bold;}
+.ec-lmssbx-10{ font-family: sans-serif; font-weight: bold;}
+.ec-lmssbx-10{ font-family: sans-serif; font-weight: bold;}
+.ec-lmssbx-10{ font-family: sans-serif; font-weight: bold;}
+.ec-lmssbx-10{ font-family: sans-serif; font-weight: bold;}
+.ec-lmssbx-10{ font-family: sans-serif; font-weight: bold;}
+.ec-lmssbx-10{ font-family: sans-serif; font-weight: bold;}
+.ec-lmssbx-10{ font-family: sans-serif; font-weight: bold;}
+.ec-lmssbx-10{ font-family: sans-serif; font-weight: bold;}
+.ec-lmtt-9{font-size:90%; font-family: monospace;}
+.ec-lmtt-9{ font-family: monospace;}
+.ec-lmtt-9{ font-family: monospace;}
+.ec-lmtt-9{ font-family: monospace;}
+.ec-lmtt-9{ font-family: monospace;}
+.ec-lmtt-9{ font-family: monospace;}
+.ec-lmtt-9{ font-family: monospace;}
+.ec-lmtt-9{ font-family: monospace;}
+.ec-lmtt-9{ font-family: monospace;}
+.ec-lmtt-9{ font-family: monospace;}
+.ec-lmtt-9{ font-family: monospace;}
+.ec-lmtt-9{ font-family: monospace;}
+.rm-lmr-8x-x-95{font-size:76%;}
+.lmmi-8x-x-95{font-size:76%;}
+.ec-lmri-10{ font-style:italic;}
+.ec-lmri-10{ font-style:italic;}
+.ec-lmri-10{ font-style:italic;}
+.ec-lmri-10{ font-style:italic;}
+.ec-lmri-10{ font-style:italic;}
+.ec-lmri-10{ font-style:italic;}
+.ec-lmri-10{ font-style:italic;}
+.ec-lmri-10{ font-style:italic;}
+.ec-lmri-10{ font-style:italic;}
+.ec-lmri-10{ font-style:italic;}
+.ec-lmri-10{ font-style:italic;}
+.ec-lmri-10{ font-style:italic;}
+.ec-lmr-9{font-size:90%;}
+.ec-lmr-8{font-size:80%;}
+p.noindent { text-indent: 0em }
+td p.noindent { text-indent: 0em; margin-top:0em; }
+p.nopar { text-indent: 0em; }
+p.indent{ text-indent: 1.5em }
+@media print {div.crosslinks {visibility:hidden;}}
+a img { border-top: 0; border-left: 0; border-right: 0; }
+center { margin-top:1em; margin-bottom:1em; }
+td center { margin-top:0em; margin-bottom:0em; }
+.Canvas { position:relative; }
+img.math{vertical-align:middle;}
+li p.indent { text-indent: 0em }
+li p:first-child{ margin-top:0em; }
+li p:last-child, li div:last-child { margin-bottom:0.5em; }
+li p~ul:last-child, li p~ol:last-child{ margin-bottom:0.5em; }
+.enumerate1 {list-style-type:decimal;}
+.enumerate2 {list-style-type:lower-alpha;}
+.enumerate3 {list-style-type:lower-roman;}
+.enumerate4 {list-style-type:upper-alpha;}
+div.newtheorem { margin-bottom: 2em; margin-top: 2em;}
+.obeylines-h,.obeylines-v {white-space: nowrap; }
+div.obeylines-v p { margin-top:0; margin-bottom:0; }
+.overline{ text-decoration:overline; }
+.overline img{ border-top: 1px solid black; }
+td.displaylines {text-align:center; white-space:nowrap;}
+.centerline {text-align:center;}
+.rightline {text-align:right;}
+div.verbatim {font-family: monospace; white-space: nowrap; text-align:left; clear:both; }
+.fbox {padding-left:3.0pt; padding-right:3.0pt; text-indent:0pt; border:solid black 0.4pt; }
+div.fbox {display:table}
+div.center div.fbox {text-align:center; clear:both; padding-left:3.0pt; padding-right:3.0pt; text-indent:0pt; border:solid black 0.4pt; }
+div.minipage{width:100%;}
+div.center, div.center div.center {text-align: center; margin-left:1em; margin-right:1em;}
+div.center div {text-align: left;}
+div.flushright, div.flushright div.flushright {text-align: right;}
+div.flushright div {text-align: left;}
+div.flushleft {text-align: left;}
+.underline{ text-decoration:underline; }
+.underline img{ border-bottom: 1px solid black; margin-bottom:1pt; }
+.framebox-c, .framebox-l, .framebox-r { padding-left:3.0pt; padding-right:3.0pt; text-indent:0pt; border:solid black 0.4pt; }
+.framebox-c {text-align:center;}
+.framebox-l {text-align:left;}
+.framebox-r {text-align:right;}
+span.thank-mark{ vertical-align: super }
+span.footnote-mark sup.textsuperscript, span.footnote-mark a sup.textsuperscript{ font-size:80%; }
+div.footnotes{border-top:solid 1px black; border-bottom:solid 1px black; padding-bottom:1ex; padding-top:0.5ex; margin-right:15%; margin-top:2ex; font-style:italic; font-size:85%;}
+div.footnotes p{margin-top:0; margin-bottom:0; text-indent:0;}
+div.tabular, div.center div.tabular {text-align: center; margin-top:0.5em; margin-bottom:0.5em; }
+table.tabular td p{margin-top:0em;}
+table.tabular {margin-left: auto; margin-right: auto;}
+td p:first-child{ margin-top:0em; }
+td p:last-child{ margin-bottom:0em; }
+div.td00{ margin-left:0pt; margin-right:0pt; }
+div.td01{ margin-left:0pt; margin-right:5pt; }
+div.td10{ margin-left:5pt; margin-right:0pt; }
+div.td11{ margin-left:5pt; margin-right:5pt; }
+table[rules] {border-left:solid black 0.4pt; border-right:solid black 0.4pt; }
+td.td00{ padding-left:0pt; padding-right:0pt; }
+td.td01{ padding-left:0pt; padding-right:5pt; }
+td.td10{ padding-left:5pt; padding-right:0pt; }
+td.td11{ padding-left:5pt; padding-right:5pt; }
+table[rules] {border-left:solid black 0.4pt; border-right:solid black 0.4pt; }
+.hline hr, .cline hr{ height : 1px; margin:0px; }
+.tabbing-right {text-align:right;}
+span.TEX {letter-spacing: -0.125em; }
+span.TEX span.E{ position:relative;top:0.5ex;left:-0.0417em;}
+a span.TEX span.E {text-decoration: none; }
+span.LATEX span.A{ position:relative; top:-0.5ex; left:-0.4em; font-size:85%;}
+span.LATEX span.TEX{ position:relative; left: -0.4em; }
+div.float, div.figure {margin-left: auto; margin-right: auto;}
+div.float img {text-align:center;}
+div.figure img {text-align:center;}
+.marginpar {width:20%; float:right; text-align:left; margin-left:auto; margin-top:0.5em; font-size:85%; text-decoration:underline;}
+.marginpar p{margin-top:0.4em; margin-bottom:0.4em;}
+table.equation {width:100%;}
+.equation td{text-align:center; }
+td.equation { margin-top:1em; margin-bottom:1em; }
+td.equation-label { width:5%; text-align:center; }
+td.eqnarray4 { width:5%; white-space: normal; }
+td.eqnarray2 { width:5%; }
+table.eqnarray-star, table.eqnarray {width:100%;}
+div.eqnarray{text-align:center;}
+div.array {text-align:center;}
+div.pmatrix {text-align:center;}
+table.pmatrix {width:100%;}
+span.pmatrix img{vertical-align:middle;}
+div.pmatrix {text-align:center;}
+table.pmatrix {width:100%;}
+span.bar-css {text-decoration:overline;}
+img.cdots{vertical-align:middle;}
+.partToc a, .partToc, .likepartToc a, .likepartToc {line-height: 200%; font-weight:bold; font-size:110%;}
+.index-item, .index-subitem, .index-subsubitem {display:block}
+div.caption {text-indent:-2em; margin-left:3em; margin-right:1em; text-align:left;}
+div.caption span.id{font-weight: bold; white-space: nowrap; }
+h1.partHead{text-align: center}
+p.bibitem { text-indent: -2em; margin-left: 2em; margin-top:0.6em; margin-bottom:0.6em; }
+p.bibitem-p { text-indent: 0em; margin-left: 2em; margin-top:0.6em; margin-bottom:0.6em; }
+.paragraphHead, .likeparagraphHead { margin-top:2em; font-weight: bold;}
+.subparagraphHead, .likesubparagraphHead { font-weight: bold;}
+.quote {margin-bottom:0.25em; margin-top:0.25em; margin-left:1em; margin-right:1em; text-align:justify;}
+.verse{white-space:nowrap; margin-left:2em}
+div.maketitle {text-align:center;}
+h2.titleHead{text-align:center;}
+div.maketitle{ margin-bottom: 2em; }
+div.author, div.date {text-align:center;}
+div.thanks{text-align:left; margin-left:10%; font-size:85%; font-style:italic; }
+.quotation {margin-bottom:0.25em; margin-top:0.25em; margin-left:1em; }
+.abstract p {margin-left:5%; margin-right:5%;}
+div.abstract {width:100%;}
+table.multicols { width:100%; margin-left:1em; margin-top:1em; margin-bottom:1em; }
+.equation td{text-align:center; }
+.equation-star td{text-align:center; }
+table.equation-star { width:100%; }
+table.equation { width:100%; }
+table.align, table.alignat, table.xalignat, table.xxalignat, table.flalign {width:100%; margin-left:5%; white-space: nowrap;}
+table.align-star, table.alignat-star, table.xalignat-star, table.flalign-star {margin-left:auto; margin-right:auto; white-space: nowrap;}
+td.align-label { width:5%; text-align:center; }
+td.align-odd { text-align:right; padding-right:0.3em;}
+td.align-even { text-align:left; padding-right:0.6em;}
+table.multline, table.multline-star {width:100%;}
+td.gather {text-align:center; }
+table.gather {width:100%;}
+div.gather-star {text-align:center;}
+div.important { background-color:red; }
+/* end css.sty */
+
diff --git a/Master/texmf-dist/doc/latex/probsoln/probsoln-manual.html b/Master/texmf-dist/doc/latex/probsoln/probsoln-manual.html
index 74e787ec6b0..6f33dd7f12c 100644
--- a/Master/texmf-dist/doc/latex/probsoln/probsoln-manual.html
+++ b/Master/texmf-dist/doc/latex/probsoln/probsoln-manual.html
@@ -1,993 +1,2159 @@
-
-
-
-
-
-probsoln v3.0: creating problem sheets optionally with solutions
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
probsoln v3.0: creating problem sheets optionally with solutions
-Nicola L.C. Talbot
-
-
-School of Computing Sciences
-
-University of East Anglia
-
-Norwich. Norfolk
-
-NR4 7TJ. United Kingdom.
-
http://theoval.cmp.uea.ac.uk/~nlct/
-26th August 2008
-
-
-
-
-
-
-
-
-
-
-The 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.
-
-
-Top
-
-
-
-
-
-2 Package Options
-
-The following options may be passed to this package:
-
-- answers
-- Show the answers
-
-- noanswers
-- Don't show the answers (default)
-
-- draft
-- Display the label and dataset name when a problem is used
-
-- final
-- Don't display label and dataset name when a problem is used
-
-
-
-
-Top
-
-
-
-
-
-3 Showing and Hiding Solutions
-
-
-
-In addition to the answers and noanswers package
-options, it is also possible to show or suppress the solutions
-using \showanswers and
-\hideanswers, respectively.
-The boolean variable showanswers determines whether the
-answers should be displayed. You can use this value with the
-ifthen package to specify different text depending on
-whether the solutions should be displayed. For example:
-
-Assignment 1\ifthenelse{\boolean{showanswers}}{ (Solution Sheet)}{}
-
-Alternatively you can use \ifshowanswers...\else...
-\fi:
-
-Assignment 1\ifshowanswers\space (Solution Sheet)\fi
-
-
-
-For longer passages, you can use the environments onlyproblem
-and onlysolution. For example:
-
+
+
+
+
+probsoln v3.01: creating problem sheets optionally with solutions
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
probsoln v3.01: creating problem sheets optionally
+with solutions
+
+
2011-08-22
+
+ Contents
+
+
+
+ 1 Introduction
+The 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.
+
+
+Top
2 Package Options
+The following options may be passed to this package:
+
-
+answers
- Show the answers
+
-
+noanswers
- Don’t show the answers (default)
+
-
+draft
- Display the label and dataset name when a problem is used
+
-
+final
- Don’t display label and dataset name when a problem is used
+
-
+usedefaultargs
- Make \thisproblem use the default arguments supplied in the
+ problem definition.
+
-
+nousedefaultargs
- Make \thisproblem prompt for problem arguments (default).
+
+
+Top
3 Showing and Hiding Solutions
+In addition to the answers and noanswers package options, it is also possible to show or
+suppress the solutions using
+
\showanswers \showanswers
+
+and
+
\hideanswers \hideanswers
+
+respectively.
+
The boolean variable showanswers determines whether the answers should be
+displayed. You can use this value with the ifthen package to specify different text
+depending on whether the solutions should be displayed. For example:
+
+
+
+
+
+Assignment 1\ifthenelse{\boolean{showanswers}}{ (Solution Sheet)}{}
+
+ Alternatively you can use \ifshowanswers…\else…\fi:
+
+
+
+
+
+Assignment 1\ifshowanswers\space (Solution Sheet)\fi
+
+
+
For longer passages, you can use the environments onlyproblem onlyproblem and
+onlysolution onlysolution. For example:
+
+
+
+
+
\begin{onlyproblem}%
-What is the derivative of $f(x) = x^2$?
-\end{onlyproblem}%
-\begin{onlysolution}%
-$f'(x) = 2x$
-\end{onlysolution}
-
-The above will only display the question if
showanswers
-is false and will only display the solution if
showanswers
-is true. If you want the question to appear in the answer
-sheet as well as the solution, then don't put the question in
-the
onlyproblem environment:
-
-What is the derivative of $f(x) = x^2$?
-\begin{onlysolution}%
-Solution: $f'(x) = 2x$
-\end{onlysolution}
-
-
NOTE: You can't use verbatim text in the body of the
-
onlyproblem or
onlysolution environments.
-If you need verbatim-like text, then try packages such as
-
alltt. Remember that you also can't use verbatim
-text in command arguments.
-
-
-Top
-
-
-
-
-
-4 General Formatting Commands
-
-
-
-The commands and environments described in this section are
-provided to assist formatting problems and their solutions.
-
-
-
\begin{solution}
text\end{solution}
-
-
This is equivalent to
-
\par\noindent\textbf{\solutionname}:
text
-where
\solutionname defaults
-to "Solution". Note that you must place the
solution
-environment inside the
onlysolution environment or
-between
\ifshowanswers...
\fi to ensure that it
-is suppressed when the solutions are not wanted. (See
-
Showing and
-Hiding Solutions.)
-
-
-Note that the probsoln package will only define the
-solution environment if it is not already defined.
-
-
-
-
-
\begin{textenum}
...
\end{textenum}
-
-
The
textenum environment is like the
enumerate
-environment but is in-line. It uses the same counter that the
-
enumerate environment would use at that level so the
-question can be compact but the answer can use
enumerate
-instead. For example:
-
+
What is the derivative of $f(x) = x^2$?
+
\end{onlyproblem}%
+
\begin{onlysolution}%
+
$f’(x) = 2x$
+
\end{onlysolution}
+
+ The above will only display the question if showanswers is false and will only display
+the solution if showanswers is true. If you want the question to appear in the answer
+sheet as well as the solution, then don’t put the question in the onlyproblem
+environment:
+
+
+
+
+
+What is the derivative of $f(x) = x^2$?
+
\begin{onlysolution}%
+
Solution: $f’(x) = 2x$
+
\end{onlysolution}
+
+
+
You can’t use verbatim text in the body of the
onlyproblem or
onlysolution
+environments. If you need verbatim-like text, then try packages such as
alltt. Remember
+that you also can’t use verbatim text in command arguments.
+
+
If you use onlysolution within the defproblem environment, the problem will be
+tagged as having a solution and will be added to the list used by \foreachsolution.
+
+
+Top
4 General Formatting Commands
+The commands and environments described in this section are provided to assist
+formatting problems and their solutions.
+
solution \begin{solution}⟨text⟩\end{solution}
+
+By default, this is equivalent to
+
\par\noindent\textbf{\solutionname}: ⟨text⟩
+
+where \solutionname \solutionname defaults to “Solution”. Note that you must
+place the solution environment inside the onlysolution environment or between
+\ifshowanswers…\fi to ensure that it is suppressed when the solutions are not wanted.
+(See §3 Showing and Hiding Solutions.)
+
Note that the probsoln package will only define the solution environment if it is not
+already defined.
+
textenum \begin{textenum}…\end{textenum}
+
+The textenum environment is like the enumerate environment but is in-line. It uses
+the same counter that the enumerate environment would use at that level so
+the question can be compact but the answer can use enumerate instead. For
+example:
+
+
+
+
+
\begin{onlyproblem}%
-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}
-\end{onlysolution}
-
-In this example, the items in the question are brief, so an
-
enumerate environment would result in a lot of
-unnecessary white space,
-but the answers require more space, so an
enumerate
-environment is more appropriate. Since the
textenum
-environment uses the same counters as the
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
-
TeX
-Catalogue for
-further details.
-
-
-
-
-
\correctitem
-
\incorrectitem
-
-
You can use the commands
\correctitem and
\incorrectitem
-in place of
\item. If the solutions are suppressed, these
-commands behave in the same way as
\item, otherwise they
-format the item label using one of the commands:
-
-
-
\correctitemformat{label}
-
\incorrectitemformat{label}
-
-
For example:
-
-Under which of the following functions does $S=\{a_1,a_2\}$
-become a probability space?
-\begin{enumerate}
-\incorrectitem $P(a_1)=\frac{1}{3}$, $P(a_2)=\frac{1}{2}$
-\correctitem $P(a_1)=\frac{3}{4}$, $P(a_2)=\frac{1}{4}$
-\correctitem $P(a_1)=1$, $P(a_2)=0$
-\incorrectitem $P(a_1)=\frac{5}{4}$, $P(a_2)=-\frac{1}{4}$
-\end{enumerate}
-
-
-
-Top
-
-
-
-
-
-5 Defining a Problem
-
-
-
-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
-probsoln package has a default data set labelled
-"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 onlyproblem,
-onlysolution or the showanswers boolean variable
-in conjunction with \showanswers and \hideanswers,
-you can print the solutions in a different location to the
-questions (for example in an appendix).
-
-
-
-
-
\begin{defproblem}
[n]{label}definition\end{defproblem}
-
-
This defines the problem whose label is given by
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
ngerman and
babel
-packages make certain punctuation active. Check the relevant
-package documentation for details.)
-
-
-If defproblem occurs in the document or is included via
-\input or \include, then the problem will be added to
-the default data set. If defproblem occurs in an external
-file that is loaded using one of the commands defined in
-Loading Problems From
-External Files then the problem will be added to
-the specified data set.
-
-
-The contents of the defproblem environment should be the
-text that defines the problem. This may include any of the
-commands defined in
-Showing and Hiding
-Solutions and General Formatting
-Commands.
-
-
-The problem may optionally take n arguments (where
-n is from 0 to 9). The arguments can be referenced
-in the definition via #1,...,#9.
-If n is omitted then the problem doesn't take any
-arguments.
-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}
-\end{onlysolution}
-\end{defproblem}
-
-
-
-
-
-
\newproblem[n]{label}{problem}{solution}
-
-
This is a shortcut command for:
-
-\begin{defproblem}[n]{label}%
-problem%
-\begin{onlysolution}%
-\begin{solution}%
-solution%
-\end{solution}%
-\end{onlysolution}%
-\end{defproblem}
-
+
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}
+
\end{onlysolution}
+
+ In this example, the items in the question are brief, so an enumerate environment
+would result in a lot of unnecessary white space, but the answers require more space, so
+an enumerate environment is more appropriate. Since the textenum environment uses
+the same counters as the 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 TeX Catalogue for further
+details.
+
\correctitem \incorrectitem
+
\correctitem
\incorrectitem
+
+You can use the commands \correctitem and \incorrectitem in place of
+\item. If the solutions are suppressed, these commands behave in the same way
+as \item, otherwise they format the item label using one of the commands:
+\correctitemformat \incorrectitemformat
+
\correctitemformat{⟨label⟩}
\incorrectitemformat{⟨label⟩}
+
For example:
-
+
+
+
+
+
+Under which of the following functions does $S=\{a_1,a_2\}$
+
become a probability space?
+
\begin{enumerate}
+
\incorrectitem $P(a_1)=\frac{1}{3}$, $P(a_2)=\frac{1}{2}$
+
\correctitem $P(a_1)=\frac{3}{4}$, $P(a_2)=\frac{1}{4}$
+
\correctitem $P(a_1)=1$, $P(a_2)=0$
+
\incorrectitem $P(a_1)=\frac{5}{4}$, $P(a_2)=-\frac{1}{4}$
+
\end{enumerate}
+
+ The default definition of \correctitemformat puts a frame around the label.
+
+
+Top
5 Defining a Problem
+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 probsoln package has a default data
+set labelled “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 onlyproblem, onlysolution or the showanswers
+boolean variable in conjunction with \showanswers and \hideanswers, you can
+print the solutions in a different location to the questions (for example in an
+appendix).
+
defproblem \begin{defproblem}[⟨n⟩][⟨default args⟩]{⟨label⟩}⟨definition⟩\end{defproblem}
+
+This defines the problem whose label is given by ⟨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 ngerman and babel
+packages make certain punctuation active. Check the relevant package documentation
+for details.)
+
If defproblem occurs in the document or is included via \input or \include, then
+the problem will be added to the default data set. If defproblem occurs in an external
+file that is loaded using one of the commands defined in §7 Loading Problems
+From External Files then the problem will be added to the specified data
+set.
+
The contents of the defproblem environment should be the text that defines the
+problem. This may include any of the commands defined in §3 Showing and Hiding
+Solutions and §4 General Formatting Commands.
+
The problem may optionally take ⟨n⟩ arguments (where ⟨n⟩ is from 0 to 9). The
+
+
+
+arguments can be referenced in the definition via #1,…,#9. If ⟨n⟩ is omitted then the
+problem doesn’t take any arguments. 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}
+
\end{onlysolution}
+
\end{defproblem}
+
+
+
The second optional argument ⟨default args⟩ supplies default problem arguments
+that will automatically be used within \thisproblem when used in \foreachproblem
+in conjunction with the package option usedefaultargs. (See §8 Iterating Through
+Datasets.) For example:
+
+
+
+
+
+\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}
+
+
+
\newproblem \newproblem[⟨n⟩][⟨default args⟩]{⟨label⟩}{⟨problem⟩}{⟨solution⟩}
+
+
+This is a shortcut command for:
+ \begin{defproblem}[⟨n⟩][⟨default args⟩]{⟨label⟩}%
+
⟨problem⟩%
+
\begin{onlysolution}%
+
\begin{solution}%
+
⟨solution⟩%
+
\end{solution}%
+
\end{onlysolution}%
+
\end{defproblem}
+
For example:
+
+
+
+
+
\newproblem[1]{diffsin}{%
-\(f(x) = \sin(#1x)\)
-}{%
-\(f'(x) = #1\cos(#1x)\)
-}
-
-is equivalent to
-
+
\(f(x) = \sin(#1x)\)
+
}%
+
{%
+
\(f’(x) = #1\cos(#1x)\)
+
}
+
+ is equivalent to
+
+
+
+
+
\begin{defproblem}[1]{diffcos}%
-\(f(x) = \cos(#1x)\)
-\begin{onlysolution}%
-\begin{solution}%
-\(f'(x) = -#1\sin(#1x)\)
-\end{solution}%
-\end{onlysolution}%
-\end{defproblem}
-
-(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
-
fp package.)
-
-
-
-
-
\newproblem*[n]{label}{definition}
-
-
This is a shortcut for:
-
-\begin{defproblem}[n]{label}%
-definition%
-\end{defproblem}
-
-
-
-NOTE: Verbatim text must not be used in the contents of defproblem
-or in any of the arguments to \newproblem or
-\newproblem*. If you need verbatim-like text consider using
-\texttt or the alltt package.
-
-
-Top
-
-
-
-
-
-6 Using a Problem
-
-
-
-Once you have defined a problem using defproblem or
-\newproblem (see
-Defining a
-Problem), you can later display the problem
-using:
-
-
-
\useproblem[data set]{label}{arg1}...
-
{argN}
-
-
where
data set is the name of the data set that contains
-the problem (the default data set is used if omitted),
-
label is the label identifying the required problem and
-
arg1, ...,
-
argN
-are the arguments to pass to the problem, if the problem was
-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 diffcos
-was defined to have one argument, so it can be used as follows:
-
+
\(f(x) = \cos(#1x)\)
+
\begin{onlysolution}%
+
\begin{solution}%
+
\(f’(x) = -#1\sin(#1x)\)
+
\end{solution}%
+
\end{onlysolution}%
+
\end{defproblem}
+
+ (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 fp or pgfmath packages.)
+
Alternatively, if you want to supply default arguments to use when iterating through
+problems with \foreachproblem:
+
+
+
+
+
+\newproblem[1][{3}]{diffsin}{%
+
\(f(x) = \sin(#1x)\)
+
}%
+
{%
+
\(f’(x) = #1\cos(#1x)\)
+
}
+
+
+
\newproblem* \newproblem*[⟨n⟩][⟨default args⟩]{⟨label⟩}{⟨definition⟩}
+
+
+This is a shortcut for:
+ \begin{defproblem}[⟨n⟩][⟨default args⟩]{⟨label⟩}%
+
⟨definition⟩%
+
\end{defproblem}
+
Verbatim text must not be used in the contents of
defproblem or in any of the
+arguments to
\newproblem or
\newproblem*. If you need verbatim-like text consider
+using
\texttt or the
alltt package.
+
+
+
+Top
6 Using a Problem
+Once you have defined a problem using defproblem or \newproblem (see §5 Defining a
+Problem), you can later display the problem using:
+
\useproblem \useproblem[⟨data set⟩]{⟨label⟩}{⟨arg1⟩}…{⟨argN⟩}
+
+where ⟨data set⟩ is the name of the data set that contains the problem (the default data
+set is used if omitted), ⟨label⟩ is the label identifying the required problem and ⟨arg1⟩, …,
+⟨argN⟩ are the arguments to pass to the problem, if the problem was 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 diffcos was defined to have one
+argument, so it can be used as follows:
+
+
+
+
+
\useproblem{diffcos}{3}
-
-This will be equivalent to:
-
-\(f(x) = \cos(3x)\)
-\begin{onlysolution}%
-\begin{solution}%
-\(f'(x) = -3\sin(3x)\)
-\end{solution}%
-\end{onlysolution}%
-
-
-
-Top
-
-
-
-
-
-7 Loading Problems From External Files
-
-
-
-You can store all your problem definitions (see
-Defining New
-Problems) in an external file.
-These problems can all be appended to the default data set by
-including the file via \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 Iterating
-Through Datasets. Note that the commands below
-will create a new data set, if the named data set doesn't
+
+ This will be equivalent to:
+
+
+
+
+
+\(f(x) = \cos(3x)\)
+
\begin{onlysolution}%
+
\begin{solution}%
+
\(f’(x) = -3\sin(3x)\)
+
\end{solution}%
+
\end{onlysolution}%
+
+
+
+
+Top
7 Loading Problems From External Files
+You can store all your problem definitions (see §5 Defining a Problem) in an external
+file. These problems can all be appended to the default data set by including the file via
+\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 §8 Iterating Through Datasets.
+Note that the commands below will create a new data set, if the named data set doesn’t
exist.
-
-
-
-
-
\loadallproblems[data set]{filename}
-
-
This will load all problems defined in filename and
-append them to the specified data set, in the order in which
-they are defined in the file. If data set is
-omitted, the default data set will be used. If data set
-doesn't exist, it will be created.
-
-
-
-
-
\loadselectedproblems[data set]{labels}{filename}
-
-
This is like \loadproblems, but only those problems whose
-label is listed in the comma-separated list labels are
-loaded. For example, if I have some problems defined in the
-file derivatives.tex, then
-
+
\loadallproblems \loadallproblems[⟨data set⟩]{⟨filename⟩}
+
+This will load all problems defined in ⟨filename⟩ and append them to the specified
+data set, in the order in which they are defined in the file. If ⟨data set⟩ is
+omitted, the default data set will be used. If ⟨data set⟩ doesn’t exist, it will be
+created.
+
\loadselectedproblems \loadselectedproblems[⟨data set⟩]{⟨labels⟩}{⟨filename⟩}
+
+
+This is like \loadallproblems, but only those problems whose label is listed in the
+comma-separated list ⟨labels⟩ are loaded. For example, if I have some problems defined
+in the file derivatives.tex, then
+
+
+
+
+
\loadselectedproblems{diffsin,diffcos}{derivatives}
-
-will only load the problems whose labels are
diffsin
-and
diffcos, respectively. All the other problems in
-the file will remain undefined.
-
-
-
-
-
\loadrandomproblems[data set]{n}{filename}
-
-
This randomly loads
n problems from
filename and
-adds them to the given data set. If
data set is omitted,
-the default data set is assumed. Note that the problems will be
-added to the data set in a random order, not in the order in
-which they were defined. There must be at least
n problems
-defined in
filename.
-
-
-NOTE: It is generally not a good idea to place anything in
-filename that is not inside the body of defproblem
-or in the arguments to \newproblem or \newproblem*.
-All the commands in this section input the external file within
-a local scope, so commands definitions would need to be made
-global to have any effect. In addition, \loadrandomproblems
-has to load each file twice, which means that anything outside
-a problem definition will be parsed twice.
-
-
-
-
-Top
-
-
-
-
-
-8 Iterating Through Datasets
-
-
-
-Once you have defined all your problems for a given data set,
-you can use an individual problem with \useproblem
-(see Using a
-Problem) 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.
-
-
-
-
-
\foreachproblem[data set]{body}
-
-
This does
body for each problem in the given data set.
-If
data set is omitted, the default data set is used.
-Within
body you can use
-
\thisproblem to use the
-current problem and
\thisproblemlabel
-to access the current label. If the problem requires arguments,
-you will be prompted for them, 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
\thisproblem, so you only
-need to use
\thisproblem without having to specify
-
\useproblem. For example, to iterate through all problems
-in the default data set:
-
+
+ will only load the problems whose labels are diffsin and diffcos, respectively. All
+the other problems in the file will remain undefined.
+
\loadexceptproblems \loadexceptproblems[⟨data set⟩]{⟨exception list⟩}{⟨filename⟩}
+
+
+This is the reverse of \loadselectedproblems. This loads all problems except those
+whose labels are listed in ⟨exception list⟩.
+
\loadrandomproblems \loadrandomproblems[⟨data set⟩]{⟨n⟩}{⟨filename⟩}
+
+
+This randomly loads ⟨n⟩ problems from ⟨filename⟩ and adds them to the given data
+set. If ⟨data set⟩ is omitted, the default data set is assumed. Note that the
+problems will be added to the data set in a random order, not in the order
+in which they were defined. There must be at least ⟨n⟩ problems defined in
+⟨filename⟩.
+
\loadrandomexcept \loadrandomexcept[⟨data set⟩]{⟨n⟩}{⟨filename⟩}{⟨exception
+
list⟩}
+
+This is similar to \loadrandomproblems except that it won’t load those problems
+whose labels are listed in ⟨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
+
\PSNuseoldrandom \PSNuseoldrandom
+
+
It is generally not a good idea to place anything in
⟨filename⟩ that is not inside the
+body of
defproblem or in the arguments to
\newproblem or
\newproblem*. All
+the commands in this section input the external file within a local scope, so
+command definitions would need to be made global to have any effect. In addition,
+
\loadrandomproblems has to load each file twice, which means that anything outside a
+problem definition will be parsed twice.
+
+
+
+Top
8 Iterating Through Datasets
+Once you have defined all your problems for a given data set, you can use an individual
+problem with \useproblem (see §6 Using a Problem) 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.
+
+
+
+
\foreachproblem \foreachproblem[⟨data set⟩]{⟨body⟩}
+
+This does ⟨body⟩ for each problem in the given data set. If ⟨data set⟩ is omitted, the
+default data set is used. Within ⟨body⟩ you can use
+
\thisproblem \thisproblem
+
+to use the current problem and
+
\thisproblemlabel \thisproblemlabel
+
+to access the current label. If the problem requires arguments, and no default
+arguments were supplied in the problem definition or the package option 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 \thisproblem, so you only need to use
+\thisproblem without having to specify \useproblem.
+
For example, to iterate through all problems in the default data set:
+
+
+
+
+
\begin{enumerate}
-\foreachproblem{\item\thisproblem}
-\end{enumerate}
-
-
-
-
-
-
\foreachdataset{cmd}{body}
-
-
This does
body for each of the defined data sets. Within
-
body,
cmd will be set to the name of the current
-data set. For example, to display all problems in all data sets:
-
+
\foreachproblem{\item\thisproblem}
+
\end{enumerate}
+
+
+
\foreachsolution \foreachsolution[⟨data set⟩]{⟨body⟩}
+
+This is equivalent to \foreachsolution, but only iterates through problems that
+contain the onlysolution environment. Note that you still need to use \showanswers or
+the answers package option for the contents of the onlysolution environment to
+appear.
+
\foreachdataset \foreachdataset{⟨cmd⟩}{⟨body⟩}
+
+This does ⟨body⟩ for each of the defined data sets. Within ⟨body⟩, ⟨cmd⟩ will be set to
+the name of the current data set. For example, to display all problems in all data
+sets:
+
+
+
+
+
\begin{enumerate}
-\foreachdataset{\thisdataset}{%
-\foreachproblem[\thisdataset]{\item\thisproblem}}
-\end{enumerate}
-
-
-
-Suppose I have two external files called
-derivatives.tex and probspaces.tex which
-define problems using both onlyproblem and
-onlysolution for example:
-
+
\foreachdataset{\thisdataset}{%
+
\foreachproblem[\thisdataset]{\item\thisproblem}}
+
\end{enumerate}
+
+
+
Suppose I have two external files called derivatives.tex and probspaces.tex
+which define problems using both onlyproblem and onlysolution for example:
+
+
+
+
+
\begin{defproblem}{cosxsqsinx}%
-\begin{onlyproblem}%
-$y = \cos(x^2)\sin x$.%
-\end{onlyproblem}%
-\begin{onlysolution}%
-\[\frac{dy}{dx} = -\sin(x^2)2x\sin x + \cos(x^2)\cos x\]
-\end{onlysolution}%
-\end{defproblem}
-
-I can write a document that creates two data sets, one for
-the derivative problems and one for the problems about
-probability spaces. I can then use
\hideanswers and
-iterate through the require data set to produce the problems.
-Later, I can use
\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
enumerate environment,
-and redefined
\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
-ensure that the answers have the same label as the questions.
-
+
\begin{onlyproblem}%
+
$y = \cos(x^2)\sin x$.%
+
\end{onlyproblem}%
+
\begin{onlysolution}%
+
\[\frac{dy}{dx} = -\sin(x^2)2x\sin x + \cos(x^2)\cos x\]
+
\end{onlysolution}%
+
\end{defproblem}
+
+ I can write a document that creates two data sets, one for the derivative problems and
+one for the problems about probability spaces. I can then use \hideanswers and iterate
+through the require data set to produce the problems. Later, I can use \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 enumerate environment,
+and redefined \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 ensure that the answers have the same label as the
+questions.
+
+
+
+
+
\documentclass{report}
-\usepackage{probsoln}
-\begin{document}
-\hideanswers
-\chapter{Differentiation}
-% randomly select 25 problems from derivatives.tex and add to
-% the data set called 'deriv'
-\loadrandomproblems[deriv]{25}{derivatives}
-
-% Display the problems
-\renewcommand{\theenumi}{\thechapter.\arabic{enumi}}
-\begin{enumerate}
-\foreachproblem[deriv]{\item\label{prob:\thisproblemlabel}\thisproblem}
-\end{enumerate}
-% You may need to change \theenumi back here
-
-\chapter{Probability Spaces}
-% randomly select 25 problems from probspaces.tex and add to
-% the data set called 'spaces'
-\loadrandomproblems[spaces]{25}{probspaces}
-
-% Display the problems
-\renewcommand{\theenumi}{\thechapter.\arabic{enumi}}
-\begin{enumerate}
-\foreachproblem[spaces]{\item\label{prob:\thisproblemlabel}\thisproblem}
-\end{enumerate}
-% You may need to change \theenumi back here
-
-\appendix
-
-\chapter{Solutions}
-\showanswers
-\begin{itemize}
-\foreachdataset{\thisdataset}{%
-\foreachproblem[\thisdataset]{\item[\ref{prob:\thisproblemlabel}]\thisproblem}
-}
-\end{itemize}
-
-\end{document}
-
-
-
-
-
-Top
-
-
-
-
-
-9 Random Number Generator
-
-
-
-This package provides a pseudo-random number generator that is used
-by \loadrandomproblems.
-
-
-
-
-
\PSNrandseed{n}
-
-
This sets the seed to
n which must be a non-zero integer.
-For example, to generate a different set of random numbers
-every time you LaTeX your document,
1 put the following in your
-preamble:
-
+
\usepackage{probsoln}
+
\begin{document}
+
\hideanswers
+
\chapter{Differentiation}
+
randomly select 25 problems from derivatives.tex and add to
+
the data set called ’deriv’
+
\loadrandomproblems[deriv]{25}{derivatives}
+
Display the problems
+
\renewcommand{\theenumi}{\thechapter.\arabic{enumi}}
+
\begin{enumerate}
+
\foreachproblem[deriv]{\item\label{prob:\thisproblemlabel}\thisproblem}
+
\end{enumerate}
+
You may need to change \theenumi back here
+
\chapter{Probability Spaces}
+
randomly select 25 problems from probspaces.tex and add to
+
the data set called ’spaces’
+
\loadrandomproblems[spaces]{25}{probspaces}
+
Display the problems
+
\renewcommand{\theenumi}{\thechapter.\arabic{enumi}}
+
\begin{enumerate}
+
\foreachproblem[spaces]{\item\label{prob:\thisproblemlabel}\thisproblem}
+
\end{enumerate}
+
You may need to change \theenumi back here
+
\appendix
+
\chapter{Solutions}
+
\showanswers
+
\begin{itemize}
+
\foreachdataset{\thisdataset}{%
+
\foreachproblem[\thisdataset]{\item[\ref{prob:\thisproblemlabel}]\thisproblem}
+
}
+
\end{itemize}
+
\end{document}
+
+
+
+
+Top
9 Random Number Generator
+This package provides a pseudo-random number generator that is used by
+\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
+
\PSNuseoldrandom \PSNuseoldrandom
+
+
\PSNrandseed \PSNrandseed{⟨n⟩}
+
+This sets the seed to ⟨n⟩ which must be a non-zero integer. For example, to
+generate a different set of random numbers every time you LATEX your
+document,
+put the following in your preamble:
+
+
+
+
+
\PSNrandseed{\time}
-
-or to generate a different set of random numbers every year you
-LaTeX your document:
-
+
+ or to generate a different set of random numbers every year you LATEX your
+document:
+
+
+
+
+
\PSNrandseed{\year}
-
-
-
-
-
-
\PSNgetrandseed{register}
-
-
This stores the current seed in the count register specified by
-
register.
-For example:
-
+
+
+
\PSNgetrandseed \PSNgetrandseed{⟨register⟩}
+
+This stores the current seed in the count register specified by ⟨register⟩. For
+example:
+
+
+
+
+
\newcount\myseed
-\PSNgetrandseed{\myseed}
-
-
-
-
-
-
\PSNrandom{register}{n}
-
-
Generates a random integer from 1 to
n and stores in
-the count register specified by
register. For example,
-the following generates an integer from 1 to 10 and stores it
-in the register
\myreg:
-
+
\PSNgetrandseed{\myseed}
+
+
+
\PSNrandom \PSNrandom{⟨register⟩}{⟨n⟩}
+
+Generates a random integer from 1 to ⟨n⟩ and stores in the count register specified by
+⟨register⟩. For example, the following generates an integer from 1 to 10 and stores it in
+the register \myreg:
+
+
+
+
+
\newcount\myreg
-\PSNrandom{\myreg}{10}
-
-
-
-
-
-
\random{counter}{min}{max}
-
-
Generates a random integer from
min to
max and
-stores in the given counter. For example, the following generates
-a random number between 3 and 8 (inclusive) and stores it in
-the counter
myrand.
-
+
\PSNrandom{\myreg}{10}
+
+
+
\random \random{⟨counter⟩}{⟨min⟩}{⟨max⟩}
+
+Generates a random integer from ⟨min⟩ to ⟨max⟩ and stores in the given counter. For
+example, the following generates a random number between 3 and 8 (inclusive) and
+stores it in the counter myrand.
+
+
+
+
+
\newcounter{myrand}
-\random{myrand}{3}{8}
-
-
-
-
-
-
\doforrandN{n}{cmd}{list}{text}
-
-
Randomly selects
n values from the comma-separated list
-given by
list and iterates through this subset. On
-each iteration it sets
cmd to the current value and
-does
text. For example, the following will load a
-randomly selected problem from two of the listed files (where
-
file1.tex,
file2.tex and
file3.tex
-are files containing at least one problem):
-
+
\random{myrand}{3}{8}
+
+
+
\doforrandN \doforrandN{⟨n⟩}{⟨cmd⟩}{⟨list⟩}{⟨text⟩}
+
+Randomly selects ⟨n⟩ values from the comma-separated list given by ⟨list⟩ and iterates
+through this subset. On each iteration it sets ⟨cmd⟩ to the current value and does
+⟨text⟩. For example, the following will load a randomly selected problem from two of the
+listed files (where file1.tex, file2.tex and file3.tex are files containing at least
+one problem):
+
+
+
+
+
\doforrandN{2}{\thisfile}{file1,file2,file3}{%
-\loadrandomproblems{1}{\thisfile}}
-
-
-
-
-
-Top
-
-
-
-
-
-
-Version 3.0 of the probsoln package completely changed the
-structure of the package, but the commands described in this
-section have been provided to maintain compatibility with
-earlier versions. The only problems that are likely to occur are
-those where commands are contained within groups. This will
-effect any commands that are contained in external files that are
-outside of the arguments to \newproblem and \newproblem*.
-However, since the external files had to be parsed twice in
-order to load the problems, this shouldn't be an issue as adding
-anything other than problem definitions in those files would
-be problematic anyway.
-
-
-The other likely difference is where the random generator is
-used in a group. This includes commands such as
-\selectrandomly. For example, if your document contained
-something like:
-
+
\loadrandomproblems{1}{\thisfile}}
+
+
+
+
+Top
10 Compatibility With Versions Prior to 3.0
+Version 3.0 of the probsoln package completely changed the structure of the package,
+but the commands described in this section have been provided to maintain
+compatibility with earlier versions. The only problems that are likely to occur
+are those where commands are contained within groups. This will effect any
+commands that are contained in external files that are outside of the arguments to
+\newproblem and \newproblem*. However, since the external files had to be
+parsed twice in order to load the problems, this shouldn’t be an issue as adding
+anything other than problem definitions in those files would be problematic
+anyway.
+
The other likely difference is where the random generator is used in a group. This
+includes commands such as \selectrandomly. For example, if your document
+contained something like:
+
+
+
+
+
\begin{enumerate}
-\selectrandomly{file1}{8}
-
-\item Solve the following:
-\begin{enumerate}
-\selectrandomly{file2}{4}
-\end{enumerate}
-
-\selectrandomly{file3}{2}
-\end{enumerate}
-
-Then using versions prior to v3.0 will produce a different
-set of random numbers since the second
\selectrandomly
-is in a different level of grouping. If you want to ensure
-that the document produces exactly the same random set with
-the new version as with the old version, you will need to
-get and set the random number seed. For example, the above
-would need to be modified so that it becomes:
-
+
\selectrandomly{file1}{8}
+
\item Solve the following:
+
\begin{enumerate}
+
\selectrandomly{file2}{4}
+
\end{enumerate}
+
\selectrandomly{file3}{2}
+
\end{enumerate}
+
+ Then using versions prior to v3.0 will produce a different set of random numbers since
+the second \selectrandomly is in a different level of grouping. If you want to
+ensure that the document produces exactly the same random set with the
+new version as with the old version, you will need to get and set the random
+number seed. For example, the above would need to be modified so that it
+becomes:
+
+
+
+
+
\begin{enumerate}
-\selectrandomly{file1}{8}
+
\selectrandomly{file1}{8}
+
\item Solve the following:
+
\newcount\oldseed
+
\PSNgetrandseed{\oldseed}
+
\begin{enumerate}
+
\selectrandomly{file2}{4}
+
\end{enumerate}
+
\PSNrandseed{\oldseed}
+
\selectrandomly{file3}{2}
+
\end{enumerate}
+
+
+
\selectrandomly \selectrandomly{⟨filename⟩}{⟨n⟩}
+
+This is now equivalent to:
+ {\loadrandomproblems[⟨filename⟩]{⟨n⟩}{⟨filename⟩}}%
+
\foreachproblem[⟨filename⟩]{\PSNitem\thisproblem\endPSNitem}
+
\selectallproblems \selectallproblems{⟨filename⟩}
+
+This is now equivalent to:
+ {\loadallproblems[⟨filename⟩]{⟨filename⟩}}%
+
\foreachproblem[⟨filename⟩]{\PSNitem\thisproblem\endPSNitem}
+
Note that in both the above cases, a new data set is created with the same name as
+the file name.
+
+
+
+
+
+Top
Index
+ A
+
+ alltt package 1, 2
+
B
+babel package 3
+
C
+\correctitem 4
+\correctitemformat 5
+
D
+defproblem (environment) 6, 7, 8, 9, 10, 11, 12
+\doforrandN 13
+
E
+enumerate (environment) 14, 15, 16
+environments:
+ defproblem 17, 18, 19, 20, 21, 22, 23
+ enumerate 24, 25, 26
+ onlyproblem 27, 28, 29, 30, 31
+ onlysolution 32, 33, 34, 35, 36, 37
+ solution 38, 39, 40
+ textenum 41
+
F
+\foreachdataset 42
+\foreachproblem 43, 44, 45
+\foreachsolution 46, 47
+fp package 48
+
H
+\hideanswers 49, 50, 51
+
I
+\ifshowanswers 52, 53
+
+
+
+ifthen package 54
+\include 55
+\incorrectitem 56
+\incorrectitemformat 57
+\input 58, 59
+\item 60
+
L
+\loadallproblems 61
+\loadexceptproblems 62
+\loadrandomexcept 63
+\loadrandomproblems 64, 65
+\loadselectedproblems 66
+
N
+\newproblem 67, 68, 69, 70
+\newproblem* 71, 72, 73
+ngerman package 74
+
O
+onlyproblem (environment) 75, 76, 77, 78, 79
+onlysolution (environment) 80, 81, 82, 83, 84, 85
+
P
+package options:
+ answers 86, 87, 88
+ draft 89
+ final 90
+ noanswers 91, 92
+ nousedefaultargs 93
+ usedefaultargs 94, 95, 96
+pgfmath package 97
+probsoln package 98
+\PSNgetrandseed 99
+\PSNrandom 100
+\PSNrandseed 101
+\PSNuseoldrandom 102, 103
+
R
+\random 104
+
S
+\selectallproblems 105
+\selectrandomly 106, 107
+
+
+
+\showanswers 108, 109, 110, 111
+showanswers boolean variable 112, 113, 114, 115
+solution (environment) 116, 117, 118
+\solutionname 119
+
T
+textenum (environment) 120
+\theenumi 121
+\thisproblem 122, 123, 124, 125
+\thisproblemlabel 126
+
U
+\useproblem 127, 128, 129
+
+
+
+
+
+
+
-\item Solve the following:
-\newcount\oldseed
-\PSNgetrandseed{\oldseed}
-\begin{enumerate}
-\selectrandomly{file2}{4}
-\end{enumerate}
-\PSNrandseed{\oldseed}
-
-\selectrandomly{file3}{2}
-\end{enumerate}
-
-
-
-
-
-
\selectrandomly{filename}{n}
-
-
This is now equivalent to:
-
-{\loadrandomproblems[filename]{n}{filename}}%
-\foreachproblem[filename]{\PSNitem\thisproblem\endPSNitem}
-
-
-
-
-
-
\selectallproblems{filename}
-
-
This is now equivalent to:
-
-{\loadallproblems[filename]{filename}}%
-\foreachproblem[filename]{\PSNitem\thisproblem\endPSNitem}
-
-
-
-Note that in both the above cases, a new data set is created
-with the same name as the file name.
-
-
-
-
-Top
-
-
-
-
-
-
-
-- alltt
-
- 3
- | 5
-
- babel
-
- 5
-
- \correctitem
-
- 4
-
- \correctitemformat
-
- 4
-
- defproblem environment
-
- 5
- | 5
- | 6
- | 7
-
- \doforrandN
-
- 9
-
- enumerate environment
-
- 4
- | 4
- | 8
-
- \foreachdataset
-
- 8
-
- \foreachproblem
-
- 8
-
- fp
-
- 5
-
- \hideanswers
-
- 5
- | 8
-
- \ifshowanswers
-
- 3
- | 4
-
- ifthen
-
- 3
-
- \incorrectitem
-
- 4
-
- \incorrectitemformat
-
- 4
-
- \input
-
- 7
-
- \item
-
- 4
-
- \loadallproblems
-
- 7
-
- \loadrandomproblems
-
- 7
- | 9
-
- \loadselectedproblems
-
- 7
-
- \newproblem
-
- 5
- | 7
- | 10
-
- \newproblem*
-
- 5
- | 7
- | 10
-
- ngerman
-
- 5
-
- onlyproblem environment
-
- 3
- | 3
- | 5
- | 8
-
- onlysolution environment
-
- 3
- | 3
- | 4
- | 5
- | 8
-
- package options
-
-- answers
-
- 2
- | 3
-
- draft
-
- 2
-
- final
-
- 2
-
- noanswers
-
- 2
- | 3
-
-- \PSNgetrandseed
-
- 9
-
- \PSNrandom
-
- 9
-
- \PSNrandseed
-
- 9
-
- \random
-
- 9
-
- \selectallproblems
-
- 10
-
- \selectrandomly
-
- 10
- | 10
-
- \showanswers
-
- 5
- | 8
-
- showanswers boolean variable
-
- 3
- | 3
- | 3
- | 5
-
- \textttsolution environment
-
- 4
-
- textenum environment
-
- 4
- | 4
-
- \theenumi
-
- 8
-
- \useproblem
-
- 6
- | 8
- | 8
-
-
-
-Top
-
Footnotes
-
-- ... document,1
-- assuming you
-leave at least a minute between runs.
-
-
-
-
-
-
-
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}
diff --git a/Master/texmf-dist/doc/latex/probsoln/probsoln.pdf b/Master/texmf-dist/doc/latex/probsoln/probsoln.pdf
index 4d5494880fd..86b7d6baf6a 100644
Binary files a/Master/texmf-dist/doc/latex/probsoln/probsoln.pdf and b/Master/texmf-dist/doc/latex/probsoln/probsoln.pdf differ
diff --git a/Master/texmf-dist/doc/latex/probsoln/samples/1stprncp.tex b/Master/texmf-dist/doc/latex/probsoln/samples/1stprncp.tex
deleted file mode 100644
index 514abf57763..00000000000
--- a/Master/texmf-dist/doc/latex/probsoln/samples/1stprncp.tex
+++ /dev/null
@@ -1,61 +0,0 @@
- % These all involve differentiating from 1st principles
-
-\newproblem{dfp:xcube}{%
-Differentiate $f(x) = x^3$ with respect to $x$ by first principles.}{%
-\begin{eqnarray*}
-\frac{dy}{dx} & = & \lim_{\Delta x\rightarrow 0}\frac{f(x+\Delta x) - f(x)}{\Delta x}\\
- & = & \lim_{\Delta x\rightarrow 0}\frac{(x+\Delta x)^3-x^3}{\Delta x}\\
- & = & \lim_{\Delta x\rightarrow 0}\frac{(x+\Delta x)(x^2+2x\Delta x+(\Delta x)^2)-x^3}{\Delta x}\\
- & = & \lim_{\Delta x\rightarrow 0}\frac{x^3+3x^2\Delta x+3x(\Delta x)^2+(\Delta x)^3-x^3}{\Delta x}\\
- & = & \lim_{\Delta x\rightarrow 0}\frac{3x^2\Delta x+3x(\Delta x)^2+(\Delta x)^3}{\Delta x}\\
- & = & \lim_{\Delta x\rightarrow 0}3x^2+3x\Delta x + (\Delta x)^2\\
- & = & 3x^2
-\end{eqnarray*}}
-
-\newproblem{dfp:Ioverxsq}{%
-Differentiate $\displaystyle f(x) = \frac{1}{x^2}$ with respect to $x$ by first principles.}{%
-\begin{eqnarray*}
-\frac{df}{dx} & = & \lim_{\Delta x\rightarrow 0}\frac{\frac{1}{(x+\Delta x)^2}-\frac{1}{x^2}}{\Delta x}\\
- & = & \lim_{\Delta x\rightarrow 0}\frac{\frac{x^2-(x+\Delta x)^2}{x^2(x+\Delta x)^2}}{\Delta x}\\
- & = & \lim_{\Delta x\rightarrow 0}\frac{x^2-(x^2+2x\Delta x+(\Delta x)^2)}{x^2\Delta x(x+\Delta x)^2}\\
- & = & \lim_{\Delta x\rightarrow 0}\frac{-2x\Delta x-(\Delta x)^2}{x^2\Delta x(x+\Delta x)^2}\\
- & = & \lim_{\Delta x\rightarrow 0}\frac{-2x-\Delta x}{x^2(x+\Delta x)^2}\\
- & = & \frac{-2x}{x^2x^2}\\
- & = & -\frac{2}{x^3}
-\end{eqnarray*}}
-
-\newproblem{dfp:sqrtx}{%
-Differentiate from first principles $f(x) = \surd x$}{%
-\begin{eqnarray*}
-\frac{df}{dx} & = & \lim_{\Delta x\rightarrow 0}\frac{\sqrt{x+\Delta x}-\surd x}{\Delta x}\\
- & = & \lim_{\Delta x\rightarrow 0}\frac{(\sqrt{x+\Delta x}-\surd x)(\sqrt{x+\delta x}+\surd x)}{\Delta x(\sqrt{x+\Delta x}+\surd x)}\\
- & = & \lim_{\Delta x\rightarrow 0}\frac{x+\Delta x - x}{\Delta x(\sqrt{x+\Delta x}+\surd x)}\\
- & = & \lim_{\Delta x\rightarrow 0}\frac{\Delta x}{\Delta x(\sqrt{x+\Delta x}+\Delta x)}\\
- & = & \lim_{\Delta x\rightarrow 0}\frac{1}{\sqrt{x+\Delta x}+\surd x}\\
- & = & \frac{1}{2\surd x}
-\end{eqnarray*}}
-
-\newproblem{dfp:cons}{%
-Differentiate from first principles $f(x) = c$ where $c$ is a constant.}{%
-\begin{eqnarray*}
-\frac{df}{dx} & = & \lim_{\Delta x\rightarrow 0}\frac{c-c}{\Delta x}\\
- & = & \lim_{\Delta x\rightarrow 0}0\\
- & = & 0
-\end{eqnarray*}}
-
-\newproblem{dfp:cosx}{%
-Given
-\begin{eqnarray*}
-\lim_{x \rightarrow 0} \frac{\cos x - 1}{x} & = & 0\\
-\lim_{x \rightarrow 0} \frac{\sin x}{x} & = & 1
-\end{eqnarray*}
-differentiate from first principles $f(x) = \cos x$.}{%
-\begin{eqnarray*}
-\frac{df}{dx} & = & \lim_{\Delta x \rightarrow 0}\frac{f(x + \Delta x) - f(x)}{\Delta x}\\
- & = & \lim_{\Delta x \rightarrow 0} \frac{\cos(x + \Delta x) - \cos(x)}{\Delta x}\\
- & = & \lim_{\Delta x \rightarrow 0} \frac{\cos x\cos\Delta x - \sin x\sin\Delta x - \cos x}{\Delta x}\\
- & = & \lim_{\Delta x \rightarrow 0} \frac{\cos x(\cos\Delta x - 1) - \sin x\sin\Delta x}{\Delta x}\\
- & = & \cos x\lim_{\Delta x \rightarrow 0}\frac{\cos\Delta x - 1}{\Delta x}
- - \sin x\lim_{\Delta x \rightarrow 0}\frac{\sin\Delta x}{\Delta x}\\
- & = & -1 \qquad\mbox{(using given results)}
-\end{eqnarray*}}
diff --git a/Master/texmf-dist/doc/latex/probsoln/samples/args.tex b/Master/texmf-dist/doc/latex/probsoln/samples/args.tex
deleted file mode 100644
index 77278d86530..00000000000
--- a/Master/texmf-dist/doc/latex/probsoln/samples/args.tex
+++ /dev/null
@@ -1,45 +0,0 @@
- % These problems require arguments
-
- % Arguments: #1->a_2, #2->a_1 and #3->a_0
- % (Arguments must be integers)
-\newcount\ctr
-\newproblem[3]{diff:quad}{%
-\(f(x) =
-\ifnum#1=0
-\else
-\ifnum#1=1\else#1\fi x^2
-\fi
-\ifnum#2=0
-\else
-\ifnum#2>0 \ifnum#1=0 \else + \fi \fi
-\ifnum#2=1\else#2\fi x
-\fi
-\ifnum#3=0
-\else
-\ifnum#3>0 \ifnum#2=0 \ifnum#1=0 \else + \fi \else + \fi\fi
-#3
-\fi\)
-}{%
-\(f'(x) =
-\ifnum#1=0
-\else
-\ctr=2
-\multiply\ctr by #1
-\the\ctr x
-\fi
-\ifnum#2=0
-\else
-\ifnum#2>0 \ifnum#1=0 \else + \fi \fi
-#2
-\fi
- % print 0 if both #1 and #2 are 0
-\ifnum#1=0 \ifnum#2=0 0 \fi\fi
-\)
-}
-
-\newproblem[1]{diff:sin}{%
-\(f(x) = \sin(#1x)\)
-}{%
-\(f'(x) = #1\cos(#1x)\)
-}
-
diff --git a/Master/texmf-dist/doc/latex/probsoln/samples/easy.tex b/Master/texmf-dist/doc/latex/probsoln/samples/easy.tex
deleted file mode 100644
index 0833f7e9527..00000000000
--- a/Master/texmf-dist/doc/latex/probsoln/samples/easy.tex
+++ /dev/null
@@ -1,85 +0,0 @@
- % These are all easy differentiation problems
-
-\newproblem{diffeasy:gpowh}{%
-\(f(x) = g(x)^{h(x)}.\)}{%
-\begin{eqnarray*}
-f(x) & = & e^{\ln g(x)^{h(x)}}\\
- & = & e^{h(x)\ln g(x)}\\
-f'(x) & = & e^{h(x)\ln g(x)}(h'(x)\ln g(x) + h(x)\frac{g'(x)}{g(x)})\\
- & = & g(x)^{h(x)}(h'(x)\ln g(x) + \frac{h(x)g'(x)}{g(x)})
-\end{eqnarray*}}
-
-\newproblem{diffeasy:arcsin}{%
-\(y = \arcsin(x)\)}{%
-\[\sin(y) = x\]
-diff. w.r.t. $x$:
-\begin{eqnarray*}
-\cos y \frac{dy}{dx} & = & 1\\
-\frac{dy}{dx} & = & \frac{1}{\cos y}\\
- & = & \frac{1}{\sqrt{1 - \sin^2y}}\\
- & = & \frac{1}{\sqrt{1-x^2}}.
-\end{eqnarray*}}
-
-\newproblem{diffeasy:arccos}{%
-$y = \arccos x$.}{%
-\(\cos y = x\)
-diff. w.r.t. $x$:
-\begin{eqnarray*}
--\sin y \frac{dy}{dx} & = & 1\\
-\frac{dy}{dx} & = & \frac{-1}{\sin y}\\
- & = & \frac{-1}{\sqrt{1-\cos^2y}}\\
- & = & \frac{-1}{\sqrt{1-x^2}}
-\end{eqnarray*}}
-
-\newproblem{diffeasy:tan}{%
-\(y = \tan x\)}{%
-\begin{eqnarray*}
-y & = & \tan x\\
- & = & \frac{\sin x}{\cos x}\\
-\frac{dy}{dx} & = & \frac{\cos x}{\cos x} + \sin x\times\frac{-1}{\cos^2x}\times -\sin x\\
- & = & 1 + \tan^2x\\
- & = & \sec^2x.
-\end{eqnarray*}}
-
-\newproblem{diffeasy:arctan}{%
-\(y = \arctan x = \tan^{-1}x\)}{%
-\[\tan y = x\]
-diff w.r.t. $x$:
-\begin{eqnarray*}
-\sec^2y\frac{dy}{dx} & = & 1\\
-\frac{dy}{dx} & = & \frac{1}{\sec^2y}\\
- & = & \frac{1}{1+\tan^2y}\\
- & = & \frac{1}{1+x^2}
-\end{eqnarray*}}
-
-\newproblem{diffeasy:cot}{%
-\(y = (\tan x)^{-1} = \cot x\)}{%
-\begin{eqnarray*}
-\frac{dy}{dx} & = & -(\tan x)^{-2}\sec^2x\\
- & = & -\frac{\cos^2x}{\sin^2x}\cdot\frac{1}{\cos^2x}\\
- & = & \frac{-1}{\sin^2x}\\
- & = & -\csc^2x.
-\end{eqnarray*}}
-
-\newproblem{diffeasy:cosxsqsinx}{%
-$y = \cos(x^2)\sin x$.}{%
-\[\frac{dy}{dx} = -\sin(x^2)2x\sin x + \cos(x^2)\cos x\]}
-
-\newproblem{diffeasy:xlnx}{%
-$y = (x+1)\ln(x+1)$.}{%
-\begin{eqnarray*}
-\frac{dy}{dx} & = & \ln(x+1) + \frac{x+1}{x+1}\\
- & = & 1 + \ln(x+1).
-\end{eqnarray*}}
-
-\newproblem{diffeasy:glng}{%
-$f(x) = g(x)\ln(g(x))$.}{%
-\begin{eqnarray*}
-f'(x) & = & g'(x)\ln(g(x)) + \frac{g(x)}{g(x)}g'(x)\\
- & = & g'(x)(1+\ln(g(x))).
-\end{eqnarray*}}
-
-\newproblem{diffeasy:sinx/x}{%
-$y = \frac{\sin x}{x}$.}{%
-\[\frac{dy}{dx} = \frac{\cos x}{x} - \frac{\sin x}{x^2}\]}
-
diff --git a/Master/texmf-dist/doc/latex/probsoln/samples/easy2.tex b/Master/texmf-dist/doc/latex/probsoln/samples/easy2.tex
deleted file mode 100644
index 9958efcb41c..00000000000
--- a/Master/texmf-dist/doc/latex/probsoln/samples/easy2.tex
+++ /dev/null
@@ -1,135 +0,0 @@
- % These are all easy differentiation problems
-
-\begin{defproblem}{diffeasy:gpowh}%
-\begin{onlyproblem}%
-\(f(x) = g(x)^{h(x)}.\)%
-\end{onlyproblem}%
-\begin{onlysolution}%
-\begin{eqnarray*}
-f(x) & = & e^{\ln g(x)^{h(x)}}\\
- & = & e^{h(x)\ln g(x)}\\
-f'(x) & = & e^{h(x)\ln g(x)}(h'(x)\ln g(x) + h(x)\frac{g'(x)}{g(x)})\\
- & = & g(x)^{h(x)}(h'(x)\ln g(x) + \frac{h(x)g'(x)}{g(x)})
-\end{eqnarray*}%
-\end{onlysolution}%
-\end{defproblem}
-
-\begin{defproblem}{diffeasy:arcsin}%
-\begin{onlyproblem}%
-\(y = \arcsin(x)\)%
-\end{onlyproblem}%
-\begin{onlysolution}%
-\[\sin(y) = x\]
-diff. w.r.t. $x$:
-\begin{eqnarray*}
-\cos y \frac{dy}{dx} & = & 1\\
-\frac{dy}{dx} & = & \frac{1}{\cos y}\\
- & = & \frac{1}{\sqrt{1 - \sin^2y}}\\
- & = & \frac{1}{\sqrt{1-x^2}}.
-\end{eqnarray*}
-\end{onlysolution}%
-\end{defproblem}
-
-\begin{defproblem}{diffeasy:arccos}%
-\begin{onlyproblem}%
-$y = \arccos x$.%
-\end{onlyproblem}%
-\begin{onlysolution}%
-\(\cos y = x\)
-diff. w.r.t. $x$:
-\begin{eqnarray*}
--\sin y \frac{dy}{dx} & = & 1\\
-\frac{dy}{dx} & = & \frac{-1}{\sin y}\\
- & = & \frac{-1}{\sqrt{1-\cos^2y}}\\
- & = & \frac{-1}{\sqrt{1-x^2}}
-\end{eqnarray*}
-\end{onlysolution}%
-\end{defproblem}
-
-\begin{defproblem}{diffeasy:tan}%
-\begin{onlyproblem}%
-\(y = \tan x\)%
-\end{onlyproblem}
-\begin{onlysolution}%
-\begin{eqnarray*}
-y & = & \tan x\\
- & = & \frac{\sin x}{\cos x}\\
-\frac{dy}{dx} & = & \frac{\cos x}{\cos x} + \sin x\times\frac{-1}{\cos^2x}\times -\sin x\\
- & = & 1 + \tan^2x\\
- & = & \sec^2x.
-\end{eqnarray*}
-\end{onlysolution}%
-\end{defproblem}
-
-\begin{defproblem}{diffeasy:arctan}%
-\begin{onlyproblem}%
-\(y = \arctan x = \tan^{-1}x\)%
-\end{onlyproblem}%
-\begin{onlysolution}%
-\[\tan y = x\]
-diff w.r.t. $x$:
-\begin{eqnarray*}
-\sec^2y\frac{dy}{dx} & = & 1\\
-\frac{dy}{dx} & = & \frac{1}{\sec^2y}\\
- & = & \frac{1}{1+\tan^2y}\\
- & = & \frac{1}{1+x^2}
-\end{eqnarray*}
-\end{onlysolution}%
-\end{defproblem}
-
-\begin{defproblem}{diffeasy:cot}%
-\begin{onlyproblem}%
-\(y = (\tan x)^{-1} = \cot x\)%
-\end{onlyproblem}
-\begin{onlysolution}%
-\begin{eqnarray*}
-\frac{dy}{dx} & = & -(\tan x)^{-2}\sec^2x\\
- & = & -\frac{\cos^2x}{\sin^2x}\cdot\frac{1}{\cos^2x}\\
- & = & \frac{-1}{\sin^2x}\\
- & = & -\csc^2x.
-\end{eqnarray*}
-\end{onlysolution}%
-\end{defproblem}
-
-\begin{defproblem}{diffeasy:cosxsqsinx}%
-\begin{onlyproblem}%
-$y = \cos(x^2)\sin x$.%
-\end{onlyproblem}%
-\begin{onlysolution}%
-\[\frac{dy}{dx} = -\sin(x^2)2x\sin x + \cos(x^2)\cos x\]
-\end{onlysolution}%
-\end{defproblem}
-
-\begin{defproblem}{diffeasy:xlnx}%
-\begin{onlyproblem}%
-$y = (x+1)\ln(x+1)$.
-\end{onlyproblem}%
-\begin{onlysolution}%
-\begin{eqnarray*}
-\frac{dy}{dx} & = & \ln(x+1) + \frac{x+1}{x+1}\\
- & = & 1 + \ln(x+1).
-\end{eqnarray*}
-\end{onlysolution}
-\end{defproblem}
-
-\begin{defproblem}{diffeasy:glng}%
-\begin{onlyproblem}%
-$f(x) = g(x)\ln(g(x))$.
-\end{onlyproblem}
-\begin{onlysolution}%
-\begin{eqnarray*}
-f'(x) & = & g'(x)\ln(g(x)) + \frac{g(x)}{g(x)}g'(x)\\
- & = & g'(x)(1+\ln(g(x))).
-\end{eqnarray*}
-\end{onlysolution}%
-\end{defproblem}
-
-\begin{defproblem}{diffeasy:sinx/x}
-\begin{onlyproblem}%
-$y = \frac{\sin x}{x}$.
-\end{onlyproblem}
-\begin{onlysolution}%
-\[\frac{dy}{dx} = \frac{\cos x}{x} - \frac{\sin x}{x^2}\]
-\end{onlysolution}%
-\end{defproblem}
-
diff --git a/Master/texmf-dist/doc/latex/probsoln/samples/implicit.tex b/Master/texmf-dist/doc/latex/probsoln/samples/implicit.tex
deleted file mode 100644
index 7f37fe0041f..00000000000
--- a/Master/texmf-dist/doc/latex/probsoln/samples/implicit.tex
+++ /dev/null
@@ -1,41 +0,0 @@
- % These are all implicit differentiation problems
-
-\newproblem{imd:circ}{%
-Find the gradient of the unit circle ($x^2 + y^2 = 1$).}{%
-Differentiating with respect to $x$ gives:
-\begin{eqnarray*}
-2x + 2y\frac{dy}{dx} & = & 0\\
-\frac{dy}{dx} & = & \frac{-2x}{2y}\\
- & = & \frac{-x}{\sqrt{1-x^2}}.
-\end{eqnarray*}}
-
-\newproblem{imd:ysq:xcuov2mx}{%
-Find $\frac{dy}{dx}$, given
-\begin{displaymath}
-y^2 = \frac{x^3}{2-x}
-\end{displaymath}}{%
-Differentiating both sides w.r.t.\ $x$:
-\begin{eqnarray*}
-2y\frac{dy}{dx} & = & \frac{(2-x)3x^2 - x^3(-1)}{(2-x)^2}\\
- & = & \frac{3x^2(2-x) + x^3}{(2-x)^2}\\
- & = & \frac{6x^2 - 3x^3 + x^3}{(2-x)^2}\\
- & = & \frac{6x^2-2x^3}{(2-x)^2}\\
- & = & 2x^2\frac{3-x}{(2-x)^2}
-\end{eqnarray*}
-Therefore
-\begin{displaymath}
-y\frac{dy}{dx} = x^2\frac{3-x}{(2-x)^2}
-\end{displaymath}}
-
-\newproblem{imd:exy:IIxay}{%
-Differentiate w.r.t.\ $x$:
-\begin{displaymath}
-e^{xy} = 2x + y
-\end{displaymath}}{%
-Differentiating both sides w.r.t.\ $x$:
-\begin{eqnarray*}
-e^{xy}(1y + x\frac{dy}{dx}) & = & 2 + \frac{dy}{dx}\\
-xe^{xy}\frac{dy}{dx} - \frac{dy}{dx} & = & 2 - ye^{xy} \\
-\frac{dy}{dx}(xe^{xy}-1) & = & 2 - ye^{xy}\\
-\frac{dy}{dx} & = & \frac{2-ye^{xy}}{xe^{xy}-1}
-\end{eqnarray*}}
diff --git a/Master/texmf-dist/doc/latex/probsoln/samples/mchoice.tex b/Master/texmf-dist/doc/latex/probsoln/samples/mchoice.tex
deleted file mode 100644
index 7add557a680..00000000000
--- a/Master/texmf-dist/doc/latex/probsoln/samples/mchoice.tex
+++ /dev/null
@@ -1,34 +0,0 @@
-\newproblem{mc:prod}{%
-Which of the following is the derivative of $x\sin(x)$?
-(Circle the correct answer.)
-\ifthenelse{\boolean{showanswers}}{}%
-{\begin{description}
-\item[A] $\sin(x)$
-\item[B] $x\cos(x)$
-\item[C] $\sin(x) + x\cos(x)$
-\end{description}
-}}{%
-\begin{description}
-\item[A] $\sin(x)$
-\item[B] $x\cos(x)$
-\item[\textcircled{C}] $\sin(x) + x\cos(x)$ (product rule).
-\end{description}
-}
-
-\newproblem{mc:quot}{%
-Which of the following is the derivative of $\frac{\sin(x)}{x}$?
-(Circle the correct answer.)
-\ifthenelse{\boolean{showanswers}}{}%
-{\begin{description}
-\item[A] $\sin(x)$
-\item[B] $\cos(x)$
-\item[C] $\frac{\cos(x)x-\sin(x)}{x^2}$
-\end{description}
-}}{%
-\begin{description}
-\item[A] $\sin(x)$
-\item[B] $\cos(x)$
-\item[\textcircled{C}] $\frac{\cos(x)x-\sin(x)}{x^2}$
-(quotient rule)
-\end{description}
-}
diff --git a/Master/texmf-dist/doc/latex/probsoln/samples/newdata.tex b/Master/texmf-dist/doc/latex/probsoln/samples/newdata.tex
deleted file mode 100644
index 82179a34ef0..00000000000
--- a/Master/texmf-dist/doc/latex/probsoln/samples/newdata.tex
+++ /dev/null
@@ -1,26 +0,0 @@
-\begin{defproblem}{sample}
-\begin{onlyproblem}
-Differentiate $y=\sin x$
-\end{onlyproblem}
-\begin{onlysolution}
-$y'=\cos x$
-\end{onlysolution}
-\end{defproblem}
-
-\begin{defproblem}[1]{sample2}
-\begin{onlyproblem}
-Differentiate $y = \sin(#1x)$
-\end{onlyproblem}
-\begin{onlysolution}
-$y'=#1\cos #1x$
-\end{onlysolution}
-\end{defproblem}
-
-\begin{defproblem}{sample3}
-\begin{onlyproblem}
-Differentiate $y = x^2$.
-\end{onlyproblem}
-\begin{onlysolution}
-$y' = 2x$
-\end{onlysolution}
-\end{defproblem}
diff --git a/Master/texmf-dist/doc/latex/probsoln/samples/nosoln.tex b/Master/texmf-dist/doc/latex/probsoln/samples/nosoln.tex
deleted file mode 100644
index 96ea6438aaa..00000000000
--- a/Master/texmf-dist/doc/latex/probsoln/samples/nosoln.tex
+++ /dev/null
@@ -1,7 +0,0 @@
- % these problems don't have solutions
-
-\newproblem*{oop}{Describe what is meant by object-oriented
-programming.}
-
-\newproblem*{inheritance}{Describe what is meant by the term
-\emph{inheritance} in object-oriented programming. Use examples.}
diff --git a/Master/texmf-dist/doc/latex/probsoln/samples/probspaces.tex b/Master/texmf-dist/doc/latex/probsoln/samples/probspaces.tex
deleted file mode 100644
index 48f7c3c53d8..00000000000
--- a/Master/texmf-dist/doc/latex/probsoln/samples/probspaces.tex
+++ /dev/null
@@ -1,31 +0,0 @@
- % Finite probability spaces
-\newproblem{weightedcoin}{%
-A coin is weighted so that heads is four times as likely
-as tails. Find the probability that:
-\begin{textenum}
-\item tails appears,
-\item heads appears
-\end{textenum}}{%
-Let $p=P(T)$, then $P(H)=4p$. We require $P(H)+P(T)=1$,
-so $4p+p=1$, hence $p=\frac{1}{5}$. Therefore:
-\begin{textenum}
-\item $P(T)=\frac{1}{5}$,
-\item $P(H)=\frac{4}{5}$
-\end{textenum}}
-
-\newproblem*{validprobspaces}{%
-Under which of the following functions does
-$S=\{a_1,a_2\}$ become a probability space?
-\par
-\begin{textenum}
-\begin{tabular}{ll}
-\incorrectitem $P(a_1)=\frac{1}{3}$, $P(a_2)=\frac{1}{2}$
-&
-\correctitem $P(a_1)=\frac{3}{4}$, $P(a_2)=\frac{1}{4}$
-\\
-\correctitem $P(a_1)=1$, $P(a_2)=0$
-&
-\incorrectitem $P(a_1)=\frac{5}{4}$, $P(a_2)=-\frac{1}{4}$
-\end{tabular}
-\end{textenum}
-}
diff --git a/Master/texmf-dist/doc/latex/probsoln/samples/probspaces2.tex b/Master/texmf-dist/doc/latex/probsoln/samples/probspaces2.tex
deleted file mode 100644
index 26839b65293..00000000000
--- a/Master/texmf-dist/doc/latex/probsoln/samples/probspaces2.tex
+++ /dev/null
@@ -1,41 +0,0 @@
- % Finite probability spaces
-\begin{defproblem}{weightedcoin}
-\begin{onlyproblem}%
-A coin is weighted so that heads is four times as likely
-as tails. Find the probability that:
-\begin{textenum}
-\item tails appears,
-\item heads appears
-\end{textenum}
-\end{onlyproblem}
-\begin{onlysolution}%
-Let $p=P(T)$, then $P(H)=4p$. We require $P(H)+P(T)=1$,
-so $4p+p=1$, hence $p=\frac{1}{5}$. Therefore:
-\begin{textenum}
-\item $P(T)=\frac{1}{5}$,
-\item $P(H)=\frac{4}{5}$
-\end{textenum}
-\end{onlysolution}
-\end{defproblem}
-
-\begin{defproblem}{validprobspaces}
-\begin{onlyproblem}%
-Under which of the following functions does
-$S=\{a_1,a_2\}$ become a probability space?
-\par
-\begin{textenum}
-\begin{tabular}{ll}
-\item $P(a_1)=\frac{1}{3}$, $P(a_2)=\frac{1}{2}$
-&
-\item\label{validprobspacescorrect1} $P(a_1)=\frac{3}{4}$, $P(a_2)=\frac{1}{4}$
-\\
-\item\label{validprobspacescorrect2} $P(a_1)=1$, $P(a_2)=0$
-&
-\item $P(a_1)=\frac{5}{4}$, $P(a_2)=-\frac{1}{4}$
-\end{tabular}
-\end{textenum}
-\end{onlyproblem}%
-\begin{onlysolution}%
-\ref{validprobspacescorrect1} and \ref{validprobspacescorrect2}%
-\end{onlysolution}
-\end{defproblem}
diff --git a/Master/texmf-dist/doc/latex/probsoln/samples/sample.pdf b/Master/texmf-dist/doc/latex/probsoln/samples/sample.pdf
new file mode 100644
index 00000000000..bd16cbf85ad
Binary files /dev/null and b/Master/texmf-dist/doc/latex/probsoln/samples/sample.pdf differ
diff --git a/Master/texmf-dist/doc/latex/probsoln/samples/sample.tex b/Master/texmf-dist/doc/latex/probsoln/samples/sample.tex
index e80c8dff020..6627c165ae4 100644
--- a/Master/texmf-dist/doc/latex/probsoln/samples/sample.tex
+++ b/Master/texmf-dist/doc/latex/probsoln/samples/sample.tex
@@ -1,3 +1,52 @@
+%%
+%% This is file `sample.tex',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% probsoln.dtx (with options: `sample.tex,package')
+%%
+%% probsoln.dtx
+%% Copyright 2011 Nicola Talbot
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license of (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is Nicola Talbot.
+%%
+%% This work consists of the files probsoln.dtx and probsoln.ins and the derived files probsoln.sty, sample.tex, sample2.tex, sample3.tex, sample4.tex, sample5.tex, sample6.tex, sample7.tex, prob-1stprncp.tex, prob-args.tex, prob-easy.tex, prob-easy2.tex, prob-implicit.tex, prob-mchoice.tex, prob-mixed.tex, prob-newdata.tex, prob-nosoln.tex, prob-probspaces.tex, prob-probspaces2.tex, prob-tabmchoice.tex.
+%%
+%% \CharacterTable
+%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+%% Digits \0\1\2\3\4\5\6\7\8\9
+%% Exclamation \! Double quote \" Hash (number) \#
+%% Dollar \$ Percent \% Ampersand \&
+%% Acute accent \' Left paren \( Right paren \)
+%% Asterisk \* Plus \+ Comma \,
+%% Minus \- Point \. Solidus \/
+%% Colon \: Semicolon \; Less than \<
+%% Equals \= Greater than \> Question mark \?
+%% Commercial at \@ Left bracket \[ Backslash \\
+%% Right bracket \] Circumflex \^ Underscore \_
+%% Grave accent \` Left brace \{ Vertical bar \|
+%% Right brace \} Tilde \~}
+%% randomly select 25 problems from derivatives.tex and add to
+%% the data set called 'deriv'
+%% Display the problems
+%% You may need to change \theenumi back here
+%% randomly select 25 problems from probspaces.tex and add to
+%% the data set called 'spaces'
+%% Display the problems
+%% You may need to change \theenumi back here
+ % This file is public domain
\documentclass[a4paper]{article}
\usepackage{probsoln}
@@ -5,9 +54,32 @@
\showanswers
% The following will generate a different set of
- % problems in subsequent years
+ % problems each year
%\PSNrandseed{\year}
-\PSNrandseed{2007}
+
+ % Load 1 problem randomly selected from the given file
+ % and store in database 'firstprinciples':
+\loadrandomproblems[firstprinciples]{1}{prob-1stprncp}
+
+ % Load 5 problems randomly selected from the given file
+ % and store in database 'easy':
+\loadrandomproblems[easy]{5}{prob-easy}
+
+ % Load 2 problems randomly selected from the given file
+ % and store in database 'implicit':
+\loadrandomproblems[implicit]{2}{prob-implicit}
+
+ % Load 2 problems randomly selected from the given file
+ % and store in database 'probspaces':
+\loadrandomproblems[probspaces]{2}{prob-probspaces}
+
+ % Load 1 problem randomly selected from the given file
+ % and store in database 'mchoice':
+\loadrandomproblems[mchoice]{1}{prob-mchoice}
+
+ % Load 1 problem randomly selected from the given file
+ % and store in database 'nosoln':
+\loadrandomproblems[nosoln]{1}{prob-nosoln}
\begin{document}
\title{Sample Problem Sheet}
@@ -16,27 +88,27 @@
\begin{enumerate}
% Differentiation from first principles
-\selectrandomly{1stprncp}{1}
+ \foreachproblem[firstprinciples]{\item \thisproblem}
\item Differentiate the following functions:
-\newcount\oldseed
-\PSNgetrandseed\oldseed
\begin{enumerate}
-\selectrandomly{easy}{5}
+ \foreachproblem[easy]{\item \thisproblem}
\end{enumerate}
-\PSNrandseed\oldseed
% Implicit differentiation
-\selectrandomly{implicit}{2}
+\foreachproblem[implicit]{\item \thisproblem}
% Finite probability spaces
-\selectrandomly{probspaces}{2}
+\foreachproblem[probspaces]{\item \thisproblem}
% Multiple choice question
-\selectrandomly{mchoice}{1}
+\foreachproblem[mchoice]{\item \thisproblem}
% select one essay style question that doesn't come with a solution
-\selectrandomly{nosoln}{1}
+\foreachproblem[nosoln]{\item \thisproblem}
\end{enumerate}
\end{document}
+\endinput
+%%
+%% End of file `sample.tex'.
diff --git a/Master/texmf-dist/doc/latex/probsoln/samples/sample2.pdf b/Master/texmf-dist/doc/latex/probsoln/samples/sample2.pdf
new file mode 100644
index 00000000000..dc760dd57ad
Binary files /dev/null and b/Master/texmf-dist/doc/latex/probsoln/samples/sample2.pdf differ
diff --git a/Master/texmf-dist/doc/latex/probsoln/samples/sample2.tex b/Master/texmf-dist/doc/latex/probsoln/samples/sample2.tex
index e82656c9f3a..8054e753e8d 100644
--- a/Master/texmf-dist/doc/latex/probsoln/samples/sample2.tex
+++ b/Master/texmf-dist/doc/latex/probsoln/samples/sample2.tex
@@ -1,3 +1,52 @@
+%%
+%% This is file `sample2.tex',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% probsoln.dtx (with options: `sample2.tex,package')
+%%
+%% probsoln.dtx
+%% Copyright 2011 Nicola Talbot
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license of (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is Nicola Talbot.
+%%
+%% This work consists of the files probsoln.dtx and probsoln.ins and the derived files probsoln.sty, sample.tex, sample2.tex, sample3.tex, sample4.tex, sample5.tex, sample6.tex, sample7.tex, prob-1stprncp.tex, prob-args.tex, prob-easy.tex, prob-easy2.tex, prob-implicit.tex, prob-mchoice.tex, prob-mixed.tex, prob-newdata.tex, prob-nosoln.tex, prob-probspaces.tex, prob-probspaces2.tex, prob-tabmchoice.tex.
+%%
+%% \CharacterTable
+%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+%% Digits \0\1\2\3\4\5\6\7\8\9
+%% Exclamation \! Double quote \" Hash (number) \#
+%% Dollar \$ Percent \% Ampersand \&
+%% Acute accent \' Left paren \( Right paren \)
+%% Asterisk \* Plus \+ Comma \,
+%% Minus \- Point \. Solidus \/
+%% Colon \: Semicolon \; Less than \<
+%% Equals \= Greater than \> Question mark \?
+%% Commercial at \@ Left bracket \[ Backslash \\
+%% Right bracket \] Circumflex \^ Underscore \_
+%% Grave accent \` Left brace \{ Vertical bar \|
+%% Right brace \} Tilde \~}
+%% randomly select 25 problems from derivatives.tex and add to
+%% the data set called 'deriv'
+%% Display the problems
+%% You may need to change \theenumi back here
+%% randomly select 25 problems from probspaces.tex and add to
+%% the data set called 'spaces'
+%% Display the problems
+%% You may need to change \theenumi back here
+ % This file is public domain
\documentclass[a4paper]{article}
\usepackage{probsoln}
@@ -25,10 +74,10 @@
\random{numproblems}{1}{3}
% selects 1,2 or 3 problems from 1 of the given files:
-\doforrandN{1}{\file}{1stprncp,implicit}{\selectrandomly{\file}{\value{numproblems}}}
+\doforrandN{1}{\file}{prob-1stprncp,prob-implicit}{\selectrandomly{\file}{\value{numproblems}}}
\item Differentiate the following functions:
-\input{args}% load database
+\input{prob-args}% load database
\begin{enumerate}
\newcounter{A}
\newcounter{B}
@@ -45,3 +94,6 @@
\end{enumerate}
\end{enumerate}
\end{document}
+\endinput
+%%
+%% End of file `sample2.tex'.
diff --git a/Master/texmf-dist/doc/latex/probsoln/samples/sample3.pdf b/Master/texmf-dist/doc/latex/probsoln/samples/sample3.pdf
new file mode 100644
index 00000000000..91812c4451a
Binary files /dev/null and b/Master/texmf-dist/doc/latex/probsoln/samples/sample3.pdf differ
diff --git a/Master/texmf-dist/doc/latex/probsoln/samples/sample3.tex b/Master/texmf-dist/doc/latex/probsoln/samples/sample3.tex
index 35252593b33..f5020372ce4 100644
--- a/Master/texmf-dist/doc/latex/probsoln/samples/sample3.tex
+++ b/Master/texmf-dist/doc/latex/probsoln/samples/sample3.tex
@@ -1,3 +1,52 @@
+%%
+%% This is file `sample3.tex',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% probsoln.dtx (with options: `sample3.tex,package')
+%%
+%% probsoln.dtx
+%% Copyright 2011 Nicola Talbot
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license of (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is Nicola Talbot.
+%%
+%% This work consists of the files probsoln.dtx and probsoln.ins and the derived files probsoln.sty, sample.tex, sample2.tex, sample3.tex, sample4.tex, sample5.tex, sample6.tex, sample7.tex, prob-1stprncp.tex, prob-args.tex, prob-easy.tex, prob-easy2.tex, prob-implicit.tex, prob-mchoice.tex, prob-mixed.tex, prob-newdata.tex, prob-nosoln.tex, prob-probspaces.tex, prob-probspaces2.tex, prob-tabmchoice.tex.
+%%
+%% \CharacterTable
+%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+%% Digits \0\1\2\3\4\5\6\7\8\9
+%% Exclamation \! Double quote \" Hash (number) \#
+%% Dollar \$ Percent \% Ampersand \&
+%% Acute accent \' Left paren \( Right paren \)
+%% Asterisk \* Plus \+ Comma \,
+%% Minus \- Point \. Solidus \/
+%% Colon \: Semicolon \; Less than \<
+%% Equals \= Greater than \> Question mark \?
+%% Commercial at \@ Left bracket \[ Backslash \\
+%% Right bracket \] Circumflex \^ Underscore \_
+%% Grave accent \` Left brace \{ Vertical bar \|
+%% Right brace \} Tilde \~}
+%% randomly select 25 problems from derivatives.tex and add to
+%% the data set called 'deriv'
+%% Display the problems
+%% You may need to change \theenumi back here
+%% randomly select 25 problems from probspaces.tex and add to
+%% the data set called 'spaces'
+%% Display the problems
+%% You may need to change \theenumi back here
+ % This file is public domain
\documentclass[a4paper]{article}
\usepackage{longtable}
@@ -17,8 +66,11 @@
\begin{document}
\begin{longtable}{lrrrl}
-\bfseries Question & \bfseries A & \bfseries B &
+\bfseries Question & \bfseries A & \bfseries B &
\bfseries C & \ifshowanswers \bfseries Reason\fi\\
-\selectrandomly{tabmchoice}{2}
+\selectrandomly{prob-tabmchoice}{2}
\end{longtable}
\end{document}
+\endinput
+%%
+%% End of file `sample3.tex'.
diff --git a/Master/texmf-dist/doc/latex/probsoln/samples/sample4.pdf b/Master/texmf-dist/doc/latex/probsoln/samples/sample4.pdf
new file mode 100644
index 00000000000..c454080cde7
Binary files /dev/null and b/Master/texmf-dist/doc/latex/probsoln/samples/sample4.pdf differ
diff --git a/Master/texmf-dist/doc/latex/probsoln/samples/sample4.tex b/Master/texmf-dist/doc/latex/probsoln/samples/sample4.tex
index f82eef21182..46456dc0590 100644
--- a/Master/texmf-dist/doc/latex/probsoln/samples/sample4.tex
+++ b/Master/texmf-dist/doc/latex/probsoln/samples/sample4.tex
@@ -1,16 +1,72 @@
+%%
+%% This is file `sample4.tex',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% probsoln.dtx (with options: `sample4.tex,package')
+%%
+%% probsoln.dtx
+%% Copyright 2011 Nicola Talbot
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license of (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is Nicola Talbot.
+%%
+%% This work consists of the files probsoln.dtx and probsoln.ins and the derived files probsoln.sty, sample.tex, sample2.tex, sample3.tex, sample4.tex, sample5.tex, sample6.tex, sample7.tex, prob-1stprncp.tex, prob-args.tex, prob-easy.tex, prob-easy2.tex, prob-implicit.tex, prob-mchoice.tex, prob-mixed.tex, prob-newdata.tex, prob-nosoln.tex, prob-probspaces.tex, prob-probspaces2.tex, prob-tabmchoice.tex.
+%%
+%% \CharacterTable
+%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+%% Digits \0\1\2\3\4\5\6\7\8\9
+%% Exclamation \! Double quote \" Hash (number) \#
+%% Dollar \$ Percent \% Ampersand \&
+%% Acute accent \' Left paren \( Right paren \)
+%% Asterisk \* Plus \+ Comma \,
+%% Minus \- Point \. Solidus \/
+%% Colon \: Semicolon \; Less than \<
+%% Equals \= Greater than \> Question mark \?
+%% Commercial at \@ Left bracket \[ Backslash \\
+%% Right bracket \] Circumflex \^ Underscore \_
+%% Grave accent \` Left brace \{ Vertical bar \|
+%% Right brace \} Tilde \~}
+%% randomly select 25 problems from derivatives.tex and add to
+%% the data set called 'deriv'
+%% Display the problems
+%% You may need to change \theenumi back here
+%% randomly select 25 problems from probspaces.tex and add to
+%% the data set called 'spaces'
+%% Display the problems
+%% You may need to change \theenumi back here
+ % This file is public domain
\documentclass[a4paper]{article}
\usepackage{probsoln}
- % Sample file illustrating use of \selectallproblems
+ % Sample file illustrating use of \loadallproblems
% All problems defined in specified file will be used
% in order of definition
-\showanswers
+ \loadallproblems{prob-easy}
+ %\loadselectedproblems{diffeasy:gpowh,diffeasy:arccos}{prob-easy}
+ %\loadexceptproblems{diffeasy:gpowh,diffeasy:arccos}{prob-easy}
+
+ \showanswers
\begin{document}
Differentiate the following functions:
\begin{enumerate}
-\selectallproblems{easy}
+ \foreachproblem{\item \thisproblem}
\end{enumerate}
\end{document}
+\endinput
+%%
+%% End of file `sample4.tex'.
diff --git a/Master/texmf-dist/doc/latex/probsoln/samples/sample5.pdf b/Master/texmf-dist/doc/latex/probsoln/samples/sample5.pdf
new file mode 100644
index 00000000000..0b18bf6d483
Binary files /dev/null and b/Master/texmf-dist/doc/latex/probsoln/samples/sample5.pdf differ
diff --git a/Master/texmf-dist/doc/latex/probsoln/samples/sample5.tex b/Master/texmf-dist/doc/latex/probsoln/samples/sample5.tex
index 531170b1d6d..5ad29c56fb0 100644
--- a/Master/texmf-dist/doc/latex/probsoln/samples/sample5.tex
+++ b/Master/texmf-dist/doc/latex/probsoln/samples/sample5.tex
@@ -1,13 +1,61 @@
+%%
+%% This is file `sample5.tex',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% probsoln.dtx (with options: `sample5.tex,package')
+%%
+%% probsoln.dtx
+%% Copyright 2011 Nicola Talbot
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license of (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is Nicola Talbot.
+%%
+%% This work consists of the files probsoln.dtx and probsoln.ins and the derived files probsoln.sty, sample.tex, sample2.tex, sample3.tex, sample4.tex, sample5.tex, sample6.tex, sample7.tex, prob-1stprncp.tex, prob-args.tex, prob-easy.tex, prob-easy2.tex, prob-implicit.tex, prob-mchoice.tex, prob-mixed.tex, prob-newdata.tex, prob-nosoln.tex, prob-probspaces.tex, prob-probspaces2.tex, prob-tabmchoice.tex.
+%%
+%% \CharacterTable
+%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+%% Digits \0\1\2\3\4\5\6\7\8\9
+%% Exclamation \! Double quote \" Hash (number) \#
+%% Dollar \$ Percent \% Ampersand \&
+%% Acute accent \' Left paren \( Right paren \)
+%% Asterisk \* Plus \+ Comma \,
+%% Minus \- Point \. Solidus \/
+%% Colon \: Semicolon \; Less than \<
+%% Equals \= Greater than \> Question mark \?
+%% Commercial at \@ Left bracket \[ Backslash \\
+%% Right bracket \] Circumflex \^ Underscore \_
+%% Grave accent \` Left brace \{ Vertical bar \|
+%% Right brace \} Tilde \~}
+%% randomly select 25 problems from derivatives.tex and add to
+%% the data set called 'deriv'
+%% Display the problems
+%% You may need to change \theenumi back here
+%% randomly select 25 problems from probspaces.tex and add to
+%% the data set called 'spaces'
+%% Display the problems
+%% You may need to change \theenumi back here
+ % This file is public domain
\documentclass[a4paper]{report}
\usepackage{probsoln}
\begin{document}
-
\hideanswers
\chapter{Easy Problems}
-\loadrandomproblems[easyproblems]{5}{easy2}
+\loadrandomproblems[easyproblems]{5}{prob-easy2}
\renewcommand{\theenumi}{\thechapter.\arabic{enumi}}
\begin{enumerate}
@@ -15,7 +63,7 @@
\end{enumerate}
\chapter{Probability Spaces}
-\loadrandomproblems[probspaces]{2}{probspaces2}
+\loadrandomproblems[probspaces]{2}{prob-probspaces2}
\renewcommand{\theenumi}{\thechapter.\arabic{enumi}}
\begin{enumerate}
@@ -32,3 +80,6 @@
\end{enumerate}
\end{document}
+\endinput
+%%
+%% End of file `sample5.tex'.
diff --git a/Master/texmf-dist/doc/latex/probsoln/samples/sample6.tex b/Master/texmf-dist/doc/latex/probsoln/samples/sample6.tex
new file mode 100644
index 00000000000..6719c02088f
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/probsoln/samples/sample6.tex
@@ -0,0 +1,62 @@
+%%
+%% This is file `sample6.tex',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% probsoln.dtx (with options: `sample6.tex,package')
+%%
+%% probsoln.dtx
+%% Copyright 2011 Nicola Talbot
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license of (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is Nicola Talbot.
+%%
+%% This work consists of the files probsoln.dtx and probsoln.ins and the derived files probsoln.sty, sample.tex, sample2.tex, sample3.tex, sample4.tex, sample5.tex, sample6.tex, sample7.tex, prob-1stprncp.tex, prob-args.tex, prob-easy.tex, prob-easy2.tex, prob-implicit.tex, prob-mchoice.tex, prob-mixed.tex, prob-newdata.tex, prob-nosoln.tex, prob-probspaces.tex, prob-probspaces2.tex, prob-tabmchoice.tex.
+%%
+%% \CharacterTable
+%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+%% Digits \0\1\2\3\4\5\6\7\8\9
+%% Exclamation \! Double quote \" Hash (number) \#
+%% Dollar \$ Percent \% Ampersand \&
+%% Acute accent \' Left paren \( Right paren \)
+%% Asterisk \* Plus \+ Comma \,
+%% Minus \- Point \. Solidus \/
+%% Colon \: Semicolon \; Less than \<
+%% Equals \= Greater than \> Question mark \?
+%% Commercial at \@ Left bracket \[ Backslash \\
+%% Right bracket \] Circumflex \^ Underscore \_
+%% Grave accent \` Left brace \{ Vertical bar \|
+%% Right brace \} Tilde \~}
+%% randomly select 25 problems from derivatives.tex and add to
+%% the data set called 'deriv'
+%% Display the problems
+%% You may need to change \theenumi back here
+%% randomly select 25 problems from probspaces.tex and add to
+%% the data set called 'spaces'
+%% Display the problems
+%% You may need to change \theenumi back here
+\documentclass{article}
+
+\usepackage[usedefaultargs]{probsoln}
+
+\loadallproblems{prob-args}
+
+\begin{document}
+\begin{enumerate}
+\foreachproblem{\item \thisproblem}
+\end{enumerate}
+\end{document}
+\endinput
+%%
+%% End of file `sample6.tex'.
diff --git a/Master/texmf-dist/doc/latex/probsoln/samples/sample7.tex b/Master/texmf-dist/doc/latex/probsoln/samples/sample7.tex
new file mode 100644
index 00000000000..8bf5b5ecc67
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/probsoln/samples/sample7.tex
@@ -0,0 +1,71 @@
+%%
+%% This is file `sample7.tex',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% probsoln.dtx (with options: `sample7.tex,package')
+%%
+%% probsoln.dtx
+%% Copyright 2011 Nicola Talbot
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license of (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is Nicola Talbot.
+%%
+%% This work consists of the files probsoln.dtx and probsoln.ins and the derived files probsoln.sty, sample.tex, sample2.tex, sample3.tex, sample4.tex, sample5.tex, sample6.tex, sample7.tex, prob-1stprncp.tex, prob-args.tex, prob-easy.tex, prob-easy2.tex, prob-implicit.tex, prob-mchoice.tex, prob-mixed.tex, prob-newdata.tex, prob-nosoln.tex, prob-probspaces.tex, prob-probspaces2.tex, prob-tabmchoice.tex.
+%%
+%% \CharacterTable
+%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+%% Digits \0\1\2\3\4\5\6\7\8\9
+%% Exclamation \! Double quote \" Hash (number) \#
+%% Dollar \$ Percent \% Ampersand \&
+%% Acute accent \' Left paren \( Right paren \)
+%% Asterisk \* Plus \+ Comma \,
+%% Minus \- Point \. Solidus \/
+%% Colon \: Semicolon \; Less than \<
+%% Equals \= Greater than \> Question mark \?
+%% Commercial at \@ Left bracket \[ Backslash \\
+%% Right bracket \] Circumflex \^ Underscore \_
+%% Grave accent \` Left brace \{ Vertical bar \|
+%% Right brace \} Tilde \~}
+%% randomly select 25 problems from derivatives.tex and add to
+%% the data set called 'deriv'
+%% Display the problems
+%% You may need to change \theenumi back here
+%% randomly select 25 problems from probspaces.tex and add to
+%% the data set called 'spaces'
+%% Display the problems
+%% You may need to change \theenumi back here
+\documentclass{article}
+
+\usepackage{tikz}
+\usepackage{probsoln}
+
+\loadallproblems{prob-mixed}
+
+\begin{document}
+\section{Exercises}
+\begin{enumerate}
+ \foreachproblem{\item\label{q-\thisproblemlabel} \thisproblem}
+\end{enumerate}
+
+\section{Solutions}
+\showanswers
+
+\begin{enumerate}
+ \foreachsolution{\item[\ref{q-\thisproblemlabel}] \thisproblem}
+\end{enumerate}
+\end{document}
+\endinput
+%%
+%% End of file `sample7.tex'.
diff --git a/Master/texmf-dist/doc/latex/probsoln/samples/tabmchoice.tex b/Master/texmf-dist/doc/latex/probsoln/samples/tabmchoice.tex
deleted file mode 100644
index 39cd1f10e41..00000000000
--- a/Master/texmf-dist/doc/latex/probsoln/samples/tabmchoice.tex
+++ /dev/null
@@ -1,16 +0,0 @@
- % These problems are designed to be placed in a
- % tabular environment
- %
-\newproblem{tab:1}{%
-What is $(3+2)\times5$? &
-25 \ifshowanswers\selected\else\notselected\fi &
-13 \notselected &
-10 \notselected &
-}{Brackets come first}%
-
-\newproblem{tab:2}{%
-What is $-1+2\times3$? &
-3 \notselected &
--7 \notselected &
-5 \ifshowanswers\selected\else\notselected\fi &
-}{Multiplication comes first}%
diff --git a/Master/texmf-dist/source/latex/probsoln/probsoln.dtx b/Master/texmf-dist/source/latex/probsoln/probsoln.dtx
index a92e37f6598..1baeb9789e3 100644
--- a/Master/texmf-dist/source/latex/probsoln/probsoln.dtx
+++ b/Master/texmf-dist/source/latex/probsoln/probsoln.dtx
@@ -1,16 +1,15 @@
%\iffalse
% probsoln.dtx generated using makedtx version 0.94b (c) Nicola Talbot
% Command line args:
-% -macrocode ".*\.tex"
-% -setambles ".*\.tex=>\nopreamble\nopostamble"
-% -comment ".*\.tex"
-% -src "(.+\.sty)\Z=>\1"
-% -src "(.+\.tex)\Z=>\1"
+% -macrocode ".+\.tex"
+% -comment ".+\.tex"
+% -src "(.+)\.(sty)\Z=>\1.\2"
+% -src "(sample.*)\.(tex)\Z=>\1.\2"
+% -src "(prob-.*)\.(tex)\Z=>\1.\2"
% -doc "probsoln-manual.tex"
% -author "Nicola Talbot"
-% -dir "source"
% probsoln
-% Created on 2008/8/27 14:19
+% Created on 2011/8/22 22:10
%\fi
%\iffalse
%<*package>
@@ -33,86 +32,42 @@
%\fi
% \iffalse
% Doc-Source file to use with LaTeX2e
-% Copyright (C) 2008 Nicola Talbot, all rights reserved.
+% Copyright (C) 2011 Nicola Talbot, all rights reserved.
% \fi
% \iffalse
%<*driver>
-\documentclass[a4paper]{ltxdoc}
+\documentclass[a4paper]{nlctdoc}
+
+\usepackage[utf8]{inputenc}
+\usepackage[T1]{fontenc}
+\usepackage{lmodern}
+\usepackage{color}
+
+\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{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
-}
-
-\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}
-
+\CheckSum{1144}
-\newcommand*{\ics}[1]{\cs{#1}\SpecialMainIndex{#1}}
+\newcommand*{\dq}[1]{``#1''}
-\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}}
-
-
-\begin{document}\DocInput{probsoln.dtx}
+\begin{document}
+\DocInput{probsoln.dtx}
\end{document}
%
%\fi
%\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\\
@@ -120,27 +75,25 @@
%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.
+%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:
@@ -149,17 +102,29 @@
%\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}
%
%\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)}{}
@@ -193,83 +158,85 @@
%\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}
%
+%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
-%\autoref{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
-%\href{http://www.tex.ac.uk/tex-archive/help/Catalogue/bytopic.html\#enumeration}{TeX Catalogue} 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
@@ -277,8 +244,8 @@
%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}
@@ -291,47 +258,50 @@
%\incorrectitem $P(a_1)=\frac{5}{4}$, $P(a_2)=-\frac{1}{4}$
%\end{enumerate}
%\end{verbatim}
+%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
-%\autoref{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
-%\autoref{sec:showanswers} and \autoref{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
@@ -343,20 +313,35 @@
%\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\}\%
@@ -368,59 +353,73 @@
%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}
%
%\section{Using a Problem}\label{sec:useproblem}
%
-%Once you have defined a problem using \ienv{defproblem} or
-%\cs{newproblem} (see
-%\autoref{sec:defproblem}), you can later display the problem
-%using:
-%\DescribeMacro{\useproblem}
-%\begin{definition}
-%\csdef{useproblem}\oarg{data set}\marg{label}\marg{arg$_1$}\ldots\marg{arg$_N$}\end{definition}
+%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$_1$}, \ldots, \meta{arg$N$} are the arguments to pass to the problem, if the problem was
-%defined to have arguments (where $N$ is the number of arguments specified when the problem was defined).
+%\meta{arg$_1$}, \ldots, \meta{arg$_N$}
+%are the arguments to pass to the problem, if the problem was
+%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}
%was defined to have one argument, so it can be used as follows:
@@ -440,19 +439,18 @@
%\section{Loading Problems From External Files}\label{sec:load}
%
%You can store all your problem definitions (see
-%\autoref{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 \autoref{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
@@ -460,11 +458,10 @@
%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
@@ -475,9 +472,15 @@
%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,
@@ -486,43 +489,65 @@
%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}
%
-%
%\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 \autoref{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}
@@ -530,9 +555,17 @@
%\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
@@ -546,8 +579,8 @@
%
%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}%
@@ -565,7 +598,7 @@
%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
@@ -612,15 +645,19 @@
%\end{document}
%\end{verbatim}
%
-%
%\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
@@ -636,9 +673,8 @@
%\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}.
@@ -648,9 +684,8 @@
%\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,
@@ -661,9 +696,8 @@
%\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
@@ -674,9 +708,8 @@
%\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
@@ -690,7 +723,6 @@
%\loadrandomproblems{1}{\thisfile}}
%\end{verbatim}
%
-%
%\section{Compatibility With Versions Prior to 3.0}
%
%Version 3.0 of the \sty{probsoln} package completely changed the
@@ -744,30 +776,27 @@
%\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.
%
-%
% \StopEventually{\clearpage\phantomsection\addcontentsline{toc}{section}{Index}\PrintIndex}
%
%
@@ -785,12 +814,12 @@
% \end{macrocode}
% Identify this package and version:
% \begin{macrocode}
-\ProvidesPackage{probsoln}[2008/08/25 v3.0 (NLCT)]
+\ProvidesPackage{probsoln}[2011/08/22 v3.01 (NLCT)]
% \end{macrocode}
% Required packages:
+%\changes{2011/08/22}{3.01}{substr package no longer required}
% \begin{macrocode}
\RequirePackage{ifthen}
-\RequirePackage{substr}
\RequirePackage{amsmath}
% \end{macrocode}
% \subsection{Package Options}
@@ -823,6 +852,24 @@
% \begin{macrocode}
\DeclareOption{noanswers}{\showanswersfalse}
% \end{macrocode}
+% Determine whether or not to use default arguments for problems.
+%\begin{macro}{\ifusedefaultprobargs}
+% \begin{macrocode}
+\newif\ifusedefaultprobargs
+% \end{macrocode}
+%\end{macro}
+%\begin{option}{usedefaultargs}
+% \begin{macrocode}
+\DeclareOption{usedefaultargs}{\usedefaultprobargstrue}
+% \end{macrocode}
+%\end{option}
+%\begin{option}{usedefaultargs}
+% \begin{macrocode}
+\DeclareOption{nousedefaultargs}{\usedefaultprobargsfalse}
+\usedefaultprobargsfalse
+% \end{macrocode}
+%\end{option}
+%
%\begin{macro}{\prob@showdraftlabel}
%\begin{definition}
%\cs{prob@showdraftlabel}\marg{db name}\marg{label}
@@ -879,6 +926,10 @@
\newcommand*{\prob@databases}{default}
% \end{macrocode}
%\end{macro}
+% Each defined database has a list of undisplayed solutions.
+% \begin{macrocode}
+\newcommand*{\prob@db@default@solutions}{}
+% \end{macrocode}
%
%\begin{macro}{\prob@newdb}
%\begin{definition}
@@ -890,6 +941,7 @@
\@ifundefined{prob@db@#1}{%
\expandafter\gdef\csname prob@db@#1\endcsname{}%
\xdef\prob@databases{\prob@databases,#1}%
+ \expandafter\gdef\csname prob@db@#1@solutions\endcsname{}%
}{%
\PackageError{probsoln}{Data set `#1' is already defined}{}}}
% \end{macrocode}
@@ -992,8 +1044,10 @@
%
%\subsection{Defining New Problems}
%\begin{macro}{\prob@newproblem}
+%\changes{2011/08/22}{3.01}{added extra argument to supply defaults}
%\begin{definition}
-%\cs{prob@newproblem}\marg{n}\marg{db name}\marg{label}\marg{definition}
+%\cs{prob@newproblem}\marg{n}\marg{db
+%name}\marg{label}\marg{definition}\marg{default args}
%\end{definition}
% Define a new problem identified by \meta{label} for data base
% \meta{db name} with the given definition. The problem has \meta{n}
@@ -1004,42 +1058,48 @@
% number of arguments is stored in
% \cs{prob@argN@}\meta{db name}"@"\meta{label}
% \begin{macrocode}
-\newcommand{\prob@newproblem}[4]{%
+\newcommand{\prob@newproblem}[5]{%
% \end{macrocode}
% If the given data base is not defined, create it:
% \begin{macrocode}
-\@ifundefined{prob@db@#2}{\prob@newdb{#2}}{}%
+ \@ifundefined{prob@db@#2}{\prob@newdb{#2}}{}%
% \end{macrocode}
% Check whether this entry has already been defined:
% \begin{macrocode}
-\@ifundefined{prob@data@#2@#3}{%
+ \@ifundefined{prob@data@#2@#3}%
+ {%
% \end{macrocode}
% Define the new problem and make it global:
% \begin{macrocode}
-\let\@tmp=\undefined
-\newcommand\@tmp[#1]{#4}%
-\expandafter\global\expandafter\let
- \csname prob@data@#2@#3\endcsname=\@tmp
-\expandafter\xdef\csname prob@argN@#2@#3\endcsname{\number#1}%
-\let\@tmp=\undefined
+ \let\@tmp=\undefined
+ \newcommand\@tmp[#1]{#4}%
+ \expandafter\global\expandafter\let
+ \csname prob@data@#2@#3\endcsname=\@tmp
+ \expandafter\xdef\csname prob@argN@#2@#3\endcsname{\number#1}%
+ \let\@tmp=\undefined
% \end{macrocode}
% Add the label to the data base:
% \begin{macrocode}
-\expandafter\ifx\csname prob@db@#2\endcsname\@empty
- \expandafter\xdef\csname prob@db@#2\endcsname{#3}%
-\else
- \expandafter\xdef\csname prob@db@#2\endcsname{%
- \csname prob@db@#2\endcsname,#3}%
-\fi
+ \expandafter\ifx\csname prob@db@#2\endcsname\@empty
+ \expandafter\xdef\csname prob@db@#2\endcsname{#3}%
+ \else
+ \expandafter\xdef\csname prob@db@#2\endcsname{%
+ \csname prob@db@#2\endcsname,#3}%
+ \fi
% \end{macrocode}
-% If the problem requires arguments, prompt the user if necessary:
+% If default arguments supplied, set them
% \begin{macrocode}
-\ifnum#1>0\relax
- \@prob@do@getargs{#1}{#2}{#3}%
-\fi
- }{%
- \PackageError{probsoln}{Problem `#3' is already defined for
- data base `#2'}{Problem labels must be unique for each data base}}%
+ \ifx\@empty#5\@empty
+ \else
+ \edef\thisprob@currentdb{#2}%
+ \edef\thisprob@currentlabel{#3}%
+ \expandafter\@setdefaultprobargs\expandafter{#5}%
+ \fi
+ }%
+ {%
+ \PackageError{probsoln}{Problem `#3' is already defined for
+ data base `#2'}{Problem labels must be unique for each data base}%
+ }%
}
% \end{macrocode}
%\end{macro}
@@ -1059,11 +1119,20 @@
% \begin{macrocode}
\newcommand{\@prob@getargs}[3]{%
\message{Problem `#3' (in data base `#2') requires #1 argument(s).^^J
-Please specify (e.g. {5}{3}):}%
+Please specify (e.g. \csname @prob@getargs@eg@\romannumeral#1\endcsname):}%
\read-1to\@tmp
\expandafter\global\expandafter\let
\csname prob@args@#2@#3\endcsname=\@tmp
}
+\def\@prob@getargs@eg@i{{12}}
+\def\@prob@getargs@eg@ii{{5}{3}}
+\def\@prob@getargs@eg@iii{{4}{5}{2}}
+\def\@prob@getargs@eg@iv{{5}{3}{10}{8}}
+\def\@prob@getargs@eg@v{{5}{3}{10}{8}{4}}
+\def\@prob@getargs@eg@vi{{5}{3}{10}{8}{4}{24}}
+\def\@prob@getargs@eg@vii{{5}{3}{10}{8}{4}{24}{32}}
+\def\@prob@getargs@eg@viii{{5}{3}{10}{8}{4}{24}{32}{9}}
+\def\@prob@getargs@eg@ix{{5}{3}{10}{8}{4}{24}{32}{9}{2}}
% \end{macrocode}
%\end{macro}
%\begin{macro}{\@prob@do@getargs}
@@ -1072,6 +1141,36 @@ Please specify (e.g. {5}{3}):}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\setprobargs}
+%\begin{definition}
+%\cs{setprobargs}\oarg{db name}\marg{label}\marg{args}
+%\end{definition}
+% Sets the arguments for the given problem. Each of the arguments
+% within \meta{args} should be grouped, e.g.
+% "\setprobargs{label}{{5}{3}}". Inner braces are still required if
+% there is only one argument, e.g. "\setprobargs{label}{{25}}"
+% \begin{macrocode}
+\newcommand*{\setprobargs}[3][default]{%
+ \expandafter\gdef\csname prob@args@#1@#2\endcsname{#3}%
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\@setdefaultprobargs}
+% Like \cs{setprobargs} but only sets the arguments if
+% \ics{usedefaultprobargstrue}. The database is given
+% by \cs{thisprob@currentdb} (the current database) and
+% the problem label is given by \cs{thisprob@currentlabel}.
+% This command should only be used within \env{defproblem}.
+% \begin{macrocode}
+\newcommand*{\@setdefaultprobargs}[1]{%
+ \ifusedefaultprobargs
+ \setprobargs[\thisprob@currentdb]{\thisprob@currentlabel}{#1}%
+ \fi
+}
+% \end{macrocode}
+%\end{macro}
+%
%\begin{macro}{\long@collect@body}
% Need long versions of \cs{collect@body}. These macros are
% adapted from the macros defined by \sty{amsmath}.
@@ -1088,14 +1187,25 @@ Please specify (e.g. {5}{3}):}%
% \end{macrocode}
%\end{macro}
%\begin{macro}{\long@addto@envbody}
+%\changes{2011/08/22}{3.01}{modified to allow for floats in the body of the
+%environment}
% \begin{macrocode}
-\long\def\long@addto@envbody#1{\global\@envbody\@xp{\the\@envbody#1}}
+\long\def\long@addto@envbody#1{%
+ \toks@{#1}%
+ \edef\@psn@tmp{\the\@envbody\the\toks@}%
+ \global\@envbody\@xp{\@psn@tmp}%
+}
% \end{macrocode}
%\end{macro}
%\begin{macro}{\long@collect@@body}
% \begin{macrocode}
\long\def\long@collect@@body#1\end#2{%
- \edef\begin@stack{\long@push@begins#1\begin\end \@xp\@gobble\begin@stack}%
+% \end{macrocode}
+%\changes{2011/08/22}{3.01}{changed \cs{edef} to \cs{protected@edef}}
+% \begin{macrocode}
+ \protected@edef\begin@stack{%
+ \long@push@begins#1\begin\end \@xp\@gobble\begin@stack
+ }%
\ifx\@empty\begin@stack
\endgroup
\@checkend{#2}%
@@ -1116,19 +1226,25 @@ Please specify (e.g. {5}{3}):}%
%\end{macro}
%
%\begin{environment}{defproblem}
+%\changes{2011/08/22}{3.01}{added second optional argument}
%\begin{definition}
-%"\begin{defproblem}"\oarg{n}\marg{label}
+%"\begin{defproblem}"\oarg{n}\oarg{default args}\marg{label}
%\end{definition}
% Define a new problem identified by \meta{label} with
% \meta{n} arguments to add to the current data base. Note that
% since the contents of the environment are passed to a command,
% the contents can't contain any verbatim text.
% \begin{macrocode}
-\newenvironment{defproblem}[2][0]{%
- \def\@prob@currentargN{#1}%
+\newenvironment{defproblem}[1][0]{%
+ \edef\@prob@currentargN{\number0#1}%
+ \@defproblem@beginenv
+}{}
+
+\newcommand*{\@defproblem@beginenv}[2][]{%
+ \def\@prob@currentdefaultargs{#1}%
\def\@prob@currentlabel{#2}%
\long@collect@body\prob@do@defproblem
-}{}
+}
% \end{macrocode}
%\end{environment}
%\begin{macro}{\prob@do@newproblem}
@@ -1141,8 +1257,8 @@ Please specify (e.g. {5}{3}):}%
% is given by \cs{prob@currentdb}.
% \begin{macrocode}
\newcommand{\prob@do@newproblem}[1]{%
-\prob@newproblem\@prob@currentargN\prob@currentdb
- \@prob@currentlabel{#1}}
+ \prob@newproblem\@prob@currentargN\prob@currentdb
+ \@prob@currentlabel{#1}{\@prob@currentdefaultargs}}
% \end{macrocode}
%\end{macro}
%
@@ -1166,9 +1282,66 @@ Please specify (e.g. {5}{3}):}%
%\begin{macro}{\do@onlysolution}
% \begin{macrocode}
\newcommand{\do@onlysolution}[1]{%
-\ifshowanswers
- #1%
-\fi}
+ \ifshowanswers
+ #1%
+ \fi
+% \end{macrocode}
+% Add to the list of solutions
+% \begin{macrocode}
+ \@ifundefined{@prob@currentlabel}
+ {}%
+ {%
+ \expandafter
+ \psn@add@unique@label
+ \csname prob@db@\prob@currentdb @solutions\endcsname{%
+ \@prob@currentlabel
+ }%
+ }%
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\psn@add@unique@label}
+%\changes{2011/08/22}{3.01}{new}
+%\begin{definition}
+%\cs{psn@add@unique@label}\marg{list cs}\marg{label}
+%\end{definition}
+% Globally adds label to list if not already in list.
+% \begin{macrocode}
+\newcommand*{\psn@add@unique@label}[2]{%
+ \ifx#1\@empty
+ \xdef#1{#2}%
+ \else
+ \edef\@tmp@label{#2}%
+ \expandafter\DTLifinlist\expandafter{\@tmp@label}{#1}%
+ {}% ignore
+ {\xdef#1{#1,\@tmp@label}}%
+ \fi
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\DTLifinlist}
+% This is defined in \sty{datatool}, but there's no sense loading
+% the entire package just for this, so define if not already
+% defined.
+%\changes{2011/08/22}{3.01}{new}
+% \begin{macrocode}
+\providecommand{\DTLifinlist}[4]{%
+ \def\@dtl@doifinlist##1,#1,##2\end@dtl@doifinlist{%
+ \def\@before{##1}%
+ \def\@after{##2}%
+ }%
+ \expandafter\@dtl@doifinlist\expandafter,#2,#1,\@nil
+ \end@dtl@doifinlist
+ \ifx\@after\@nnil
+% not found
+ #4%
+ \else
+% found
+ #3%
+ \fi
+}
% \end{macrocode}
%\end{macro}
%
@@ -1201,17 +1374,23 @@ Please specify (e.g. {5}{3}):}%
% \meta{db name} where \meta{arg1}\ldots\meta{argN} are the
% arguments to pass to the problem, if the problem was defined
% to take arguments.
+%\changes{2011/08/22}{3.01}{changed \cs{@next} to \cs{@useprob@next}}
% \begin{macrocode}
\newcommand{\useproblem}[2][default]{%
-\prob@showdraftlabel{#1}{#2}%
-\let\@next=\relax
-\@ifundefined{prob@data@#1@#2}{%
- \PackageError{probsoln}{Problem `#2' is not defined in data set
- `#1'}{}%
-}{%
- \def\@next{\csname prob@data@#1@#2\endcsname}%
-}%
-\@next}
+ \def\@prob@currentlabel{#2}%
+ \def\prob@currentdb{#1}%
+ \prob@showdraftlabel{#1}{#2}%
+ \let\@useprob@next=\relax
+ \@ifundefined{prob@data@#1@#2}%
+ {%
+ \PackageError{probsoln}%
+ {Problem `#2' is not defined in data set `#1'}{}%
+ }%
+ {%
+ \def\@useprob@next{\csname prob@data@#1@#2\endcsname}%
+ }%
+ \@useprob@next
+}
% \end{macrocode}
%\end{macro}
%\subsection{Loading Problems From Another File}
@@ -1236,10 +1415,15 @@ Please specify (e.g. {5}{3}):}%
% Only define problem if the label is listed in
% \cs{prob@selectedlabels}. (The current label is
% given by \cs{@prob@currentlabel}.)
+%\changes{2011/08/22}{3.01}{replaced \cs{IFSubStringInString} with
+%\cs{DTLifinlist}}
% \begin{macrocode}
\newcommand{\prob@do@selectedproblem}[1]{%
-\IfSubStringInString{,\@prob@currentlabel,}{,\prob@selectedlabels,}{%
-\prob@do@newproblem{#1}}{}%
+ \expandafter\DTLifinlist\expandafter{\@prob@currentlabel}{\prob@selectedlabels}%
+ {%
+ \prob@do@newproblem{#1}%
+ }%
+ {}%
}
% \end{macrocode}
%\end{macro}
@@ -1263,6 +1447,41 @@ Please specify (e.g. {5}{3}):}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\prob@do@exceptedproblem}
+% Only define problem if the label isn't listed in
+% \cs{prob@selectedlabels}. (The current label is
+% given by \cs{@prob@currentlabel}.)
+% \begin{macrocode}
+\newcommand{\prob@do@exceptedproblem}[1]{%
+ \expandafter\DTLifinlist\expandafter{\@prob@currentlabel}{\prob@selectedlabels}%
+ {}%
+ {%
+ \prob@do@newproblem{#1}%
+ }%
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\loadexceptproblems}
+%\begin{definition}
+%\cs{loadexceptproblems}\oarg{db name}\marg{list}\marg{filename}
+%\end{definition}
+% Loads only those problems whose labels are not listed in
+% \meta{list}.
+%\changes{2011/08/22}{3.01}{new}
+% \begin{macrocode}
+\newcommand{\loadexceptproblems}[3][default]{%
+\bgroup
+ \let\par\relax
+ \edef\prob@currentdb{#1}%
+ \edef\prob@selectedlabels{#2}%
+ \let\prob@do@defproblem=\prob@do@exceptedproblem
+ \input{#3}%
+\egroup
+}
+% \end{macrocode}
+%\end{macro}
+%
%\begin{macro}{\prob@add@currentlabel}
% Adds the current label to \cs{prob@selectedlabels} (ignores
% argument.)
@@ -1289,10 +1508,32 @@ Please specify (e.g. {5}{3}):}%
%\cs{loadrandomproblems}\oarg{db name}\marg{n}\marg{filename}
%\end{definition}
% Loads \meta{n} randomly selected problems from \meta{filename}.
+% \begin{macrocode}
+\newcommand{\loadrandomproblems}[3][default]{%
+ \@loadrandomproblems{#1}{#2}{#3}{}%
+}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\loadrandomexcept}
+%\begin{definition}
+%\cs{loadrandomexcept}\oarg{db
+%name}\marg{n}\marg{filename}\marg{exception list}
+%\end{definition}
+% Loads \meta{n} randomly selected problems from \meta{filename},
+% excluding labels listed in \meta{exception list}.
+% \begin{macrocode}
+\newcommand{\loadrandomexcept}[4][default]{%
+ \@loadrandomproblems{#1}{#2}{#3}{#4}%
+}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\@loadrandomproblems}
+% Internal workings of \cs{loadrandomproblems} and
+% \cs{loadrandomexcept}.
% Needs to input \meta{filename} twice: the first time just gathers
% all the labels, the second time only loads the selected problems.
% \begin{macrocode}
-\newcommand{\loadrandomproblems}[3][default]{%
+\newcommand{\@loadrandomproblems}[4]{%
\bgroup
\let\par\relax
\def\prob@db@reserved{}%
@@ -1309,17 +1550,23 @@ Please specify (e.g. {5}{3}):}%
% \begin{macrocode}
\@probselN=0\relax
\@for\@thislabel:=\prob@selectedlabels\do{%
- \advance\@probselN by 1\relax
- \expandafter
- \edef\csname @prob@tmp@\romannumeral\@probselN\endcsname{%
- \@thislabel}%
+ \expandafter\DTLifinlist\expandafter
+ {\@thislabel}{#4}{}%
+ {%
+ \advance\@probselN by 1\relax
+ \expandafter
+ \edef\csname @prob@tmp@\romannumeral\@probselN\endcsname{%
+ \@thislabel}%
+ }%
}%
\shuffle{@prob@tmp@}{\@probselN}%
\ifnum\@probselN<#2\relax
- \PackageError{probsoln}{%
- Can't select \number#2\space\space problem(s):^^J
- '#3' only contains \number\@probselN\space problem(s)}{%
- Only \number\@probselN\space problem(s) will be selected}%
+% \end{macrocode}
+%\changes{2011/08/22}{3.01}{changed error to warning}
+% \begin{macrocode}
+ \PackageWarning{probsoln}{You have requested
+ \number#2\space\space problem(s) but `#3' only contains
+ \number\@probselN\space problems. All problems will be selected}%
\else
\@probselN=#2\relax
\fi
@@ -1400,6 +1647,46 @@ Please specify (e.g. {5}{3}):}%
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\foreachsolution}
+%\begin{definition}
+%\cs{foreachsolution}\oarg{db name}\marg{body}
+%\end{definition}
+% Does \meta{body} for each problem defined in the data base
+% \meta{db name} that has a solution contained within
+% \env{onlysolution}. Within \meta{body}, the command \cs{thisproblem}
+% can be used to do the current problem and the command
+% \cs{thisproblemlabel} can be used to access the current label.
+% \begin{macrocode}
+\newcommand{\foreachsolution}[2][default]{%
+\@ifundefined{prob@db@#1}{%
+ \PackageError{probsoln}{Data base `#1' is not defined}{}%
+}{%
+ \expandafter\let\expandafter\@tmp\csname prob@db@#1@solutions\endcsname
+ \@for\thisproblemlabel:=\@tmp\do{%
+ \ifx\thisproblemlabel\@empty
+ \else
+ \expandafter\ifnum
+ \csname prob@argN@#1@\thisproblemlabel\endcsname>0\relax
+ \@ifundefined{prob@args@#1@\thisproblemlabel}{%
+ \expandafter\@prob@getargs
+ \csname prob@argN@#1@\thisproblemlabel\endcsname
+ {#1}{\thisproblemlabel}}{}%
+ \expandafter\let\expandafter\thisproblemargs
+ \csname prob@args@#1@\thisproblemlabel\endcsname
+ \else
+ \let\thisproblemargs\@empty
+ \fi
+ \expandafter\toks@\expandafter{\thisproblemargs}%
+ \edef\thisproblem{\noexpand\useproblem[#1]{\thisproblemlabel}%
+ \the\toks@}%
+ #2%
+ \fi
+ }%
+}%
+}
+% \end{macrocode}
+%\end{macro}
+%
%\begin{macro}{\foreachdataset}
%\begin{definition}
%\cs{foreachdataset}\marg{cmd}\marg{body}
@@ -1424,13 +1711,13 @@ Please specify (e.g. {5}{3}):}%
% Set the random generator seed
% \begin{macrocode}
\newcommand*{\PSNrandseed}[1]{%
-\ifnum#1=0\relax
- \PackageWarning{probsoln}{Can't have 0 as random seed, changing to 1}%
- \global\r@ndcur=1\relax
-\else
- \global\r@ndcur=#1\relax
-\fi
-\PackageInfo{probsoln}{Random Seed = \number\r@ndcur}%
+ \ifnum#1=0\relax
+ \PackageWarning{probsoln}{Can't have 0 as random seed, changing to 1}%
+ \global\r@ndcur=1\relax
+ \else
+ \global\r@ndcur=#1\relax
+ \fi
+ \PackageInfo{probsoln}{Random Seed = \number\r@ndcur}%
}
% \end{macrocode}
%\end{macro}
@@ -1443,19 +1730,45 @@ Please specify (e.g. {5}{3}):}%
% Generate a random integer.
% \begin{macrocode}
\newcommand*{\PSNrand}{%
-\@ps@randtmp=\r@ndcur
-\multiply\@ps@randtmp by 16807\relax
-\r@ndcur=\@ps@randtmp
-\global\divide\r@ndcur by 120001\relax
-\global\multiply\r@ndcur by 120001\relax
-\advance\@ps@randtmp by -\r@ndcur
-\global\r@ndcur = \@ps@randtmp
-\ifnum\r@ndcur=0\relax
- \global\r@ndcur=1\relax
-\fi
+ \@ps@randtmp=\r@ndcur
+ \multiply\@ps@randtmp by 16811\relax
+ \r@ndcur=\@ps@randtmp
+ \global\divide\r@ndcur by 39989\relax
+ \global\multiply\r@ndcur by 39989\relax
+ \advance\@ps@randtmp by -\r@ndcur
+ \global\r@ndcur = \@ps@randtmp
+ \ifnum\r@ndcur=0\relax
+ \global\r@ndcur=1\relax
+ \fi
+}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\PSN@old@rand}
+% Random generator used in v3.0 and earlier
+% \begin{macrocode}
+\newcommand*{\PSN@old@rand}{%
+ \@ps@randtmp=\r@ndcur
+ \multiply\@ps@randtmp by 16807\relax
+ \r@ndcur=\@ps@randtmp
+ \global\divide\r@ndcur by 120001\relax
+ \global\multiply\r@ndcur by 120001\relax
+ \advance\@ps@randtmp by -\r@ndcur
+ \global\r@ndcur = \@ps@randtmp
+ \ifnum\r@ndcur=0\relax
+ \global\r@ndcur=1\relax
+ \fi
+}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\PSNuseoldrandom}
+% Use the old random number generator
+% \begin{macrocode}
+\newcommand*{\PSNuseoldrandom}{%
+ \let\PSNrand\PSN@old@rand
}
% \end{macrocode}
%\end{macro}
+%
%\begin{macro}{\PSNrandom}
%\begin{definition}
%\cs{PSNrandom}\marg{count}\marg{n}
@@ -1467,16 +1780,16 @@ Please specify (e.g. {5}{3}):}%
% \end{macrocode}
% generate new random number.
% \begin{macrocode}
-\PSNrand
-#1=\r@ndcur
-\@ps@randtmp=\r@ndcur
+ \PSNrand
+ #1=\r@ndcur
+ \@ps@randtmp=\r@ndcur
% \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
+ \divide\@ps@randtmp by #2\relax
+ \multiply\@ps@randtmp by #2\relax
+ \advance#1 by -\@ps@randtmp
+ \advance#1 by 1\relax
}
% \end{macrocode}
%\end{macro}
@@ -1510,20 +1823,21 @@ Please specify (e.g. {5}{3}):}%
% \begin{macrocode}
\newcount\@shfctr \newcount\@shfA \newcount\@shfB
\newcommand{\shuffle}[2]{%
-\@shfctr=1\relax
-\whiledo{\@shfctr < 101}{%
-\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}%
-\fi
-\advance\@shfctr by 1\relax
-}%
+ \@shfctr=1\relax
+ \whiledo{\@shfctr < 101}%
+ {%
+ \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}%
+ \fi
+ \advance\@shfctr by 1\relax
+ }%
}
% \end{macrocode}
%\end{macro}
@@ -1543,57 +1857,84 @@ Please specify (e.g. {5}{3}):}%
% \begin{macrocode}
\newcount\@ps@forrand
\newcommand{\doforrandN}[4]{%
-{\@ps@forrand=0\relax
-\@for#2:=#3\do{%
-\advance\@ps@forrand by 1\relax
-\expandafter\edef\csname @doforrandN@\romannumeral\@ps@forrand\endcsname{#2}}%
-\ifnum\@ps@forrand<#1\relax
-\PackageError{probsoln}{Can't randomly select \number#1 item(s)}{You
-have requested \number#1 item(s), but there
-are only \number\@ps@forrand item(s) in the list}%
-\else
-\shuffle{@doforrandN@}{\@ps@forrand}%
-\ifnum#1>0\relax
-\@ps@forrand=0\relax
-\loop
-\advance\@ps@forrand by 1\relax
-\edef#2{\csname @doforrandN@\romannumeral\@ps@forrand\endcsname}%
-#4%
-\ifnum\@ps@forrand<#1\relax
-\repeat
-\fi
-\fi
-}}
+ {%
+ \@ps@forrand=0\relax
+ \@for#2:=#3\do{%
+ \advance\@ps@forrand by 1\relax
+ \expandafter
+ \edef\csname @doforrandN@\romannumeral\@ps@forrand\endcsname{#2}%
+ }%
+ \ifnum\@ps@forrand<#1\relax
+ \PackageError{probsoln}{Can't randomly select \number#1 item(s)}{You
+ have requested \number#1 item(s), but there
+ are only \number\@ps@forrand item(s) in the list}%
+ \else
+ \shuffle{@doforrandN@}{\@ps@forrand}%
+ \ifnum#1>0\relax
+ \@ps@forrand=0\relax
+ \loop
+ \advance\@ps@forrand by 1\relax
+ \edef#2{\csname @doforrandN@\romannumeral\@ps@forrand\endcsname}%
+ #4%
+ \ifnum\@ps@forrand<#1\relax
+ \repeat
+ \fi
+ \fi
+ }%
+}
% \end{macrocode}
%\end{macro}
%\subsection{Compatibility With Older Versions}
% These commands ensure that this version is compatible with
% versions prior to v3.0
%\begin{macro}{\newproblem}
+%\changes{2011/08/22}{3.01}{added second optional argument}
% Defines a new problem.
% \begin{macrocode}
\newcommand*{\newproblem}{\@ifstar\@snewproblem\@newproblem}
% \end{macrocode}
%\end{macro}
%\begin{macro}{\@snewproblem}
+% Store first optional argument
+% \begin{macrocode}
+\newcommand{\@snewproblem}[1][0]{%
+ \def\@newprob@argN{#1}%
+ \@s@newproblem
+}%
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\@s@newproblem}
+% Define a new problem without a solution
% \begin{macrocode}
-\newcommand{\@snewproblem}[3][0]{%
-\begin{defproblem}[#1]{#2}%
-#3%
-\end{defproblem}}
+\newcommand{\@s@newproblem}[3][]{%
+ \begin{defproblem}[\@newprob@argN][#1]{#2}%
+ #3%
+ \end{defproblem}%
+}
% \end{macrocode}
%\end{macro}
%\begin{macro}{\@newproblem}
+% Store first optional argument
% \begin{macrocode}
-\newcommand{\@newproblem}[4][0]{%
-\begin{defproblem}[#1]{#2}%
-#3%
-\begin{onlysolution}%
-\begin{solution}%
-#4%
-\end{solution}%
-\end{onlysolution}%
-\end{defproblem}}
+\newcommand{\@newproblem}[1][0]{%
+ \def\@newprob@argN{#1}%
+ \@ns@newproblem
+}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\@ns@newproblsm}
+% Define problem with a solution:
+% \begin{macrocode}
+\newcommand{\@ns@newproblem}[4][]{%
+ \begin{defproblem}[\@newprob@argN][#1]{#2}%
+ #3%
+ \begin{onlysolution}%
+ \begin{solution}%
+ #4%
+ \end{solution}%
+ \end{onlysolution}%
+ \end{defproblem}%
+}
% \end{macrocode}
%\end{macro}
%
@@ -1621,13 +1962,15 @@ are only \number\@ps@forrand item(s) in the list}%
% These commands are provided to format parts of the
% problems/solutions.
%\begin{environment}{solution}
+%\changes{2011/08/22}{3.01}{added space after solution tag}
% \begin{macrocode}
\@ifundefined{solution}{%
-\newenvironment{solution}{\par\noindent\textbf{\solutionname:}}{}%
+ \newenvironment{solution}{\par\noindent\textbf{\solutionname:}\space
+ \ignorespaces}{}%
}{}
% \end{macrocode}
%\end{environment}
-%\begin{macro}{\solutioname}
+%\begin{macro}{\solutionname}
% \begin{macrocode}
\newcommand*{\solutionname}{Solution}
% \end{macrocode}
@@ -1638,17 +1981,23 @@ are only \number\@ps@forrand item(s) in the list}%
%\changes{2007 Oct 6}{2.05}{new}
% \begin{macrocode}
\newenvironment{textenum}{%
-\ifnum\@enumdepth>\thr@@
- \@toodeep
-\else
- \advance\@enumdepth\@ne
- \edef\@enumctr{enum\romannumeral\the\@enumdepth}%
- \let\@item\@textitem
- \def\@itemlabel{\refstepcounter{\@enumctr}%
- \csname label\@enumctr\endcsname}%
- \setcounter{\@enumctr}{0}%
-\fi\ignorespaces}{%
-\global\advance\@enumdepth\m@ne}
+ \ifnum\@enumdepth>\thr@@
+ \@toodeep
+ \else
+ \advance\@enumdepth\@ne\relax
+ \edef\@enumctr{enum\romannumeral\the\@enumdepth}%
+ \let\@item\@textitem
+ \def\@itemlabel{%
+ \refstepcounter{\@enumctr}%
+ \csname label\@enumctr\endcsname
+ }%
+ \setcounter{\@enumctr}{0}%
+ \fi
+ \ignorespaces
+}%
+{%
+ \global\advance\@enumdepth\m@ne\relax
+}
% \end{macrocode}
%\end{environment}
%\begin{macro}{\@textitem}
@@ -1725,24 +2074,347 @@ are only \number\@ps@forrand item(s) in the list}%
%\fi
%\iffalse
% \begin{macrocode}
-%<*1stprncp.tex>
+%<*sample.tex>
% \end{macrocode}
%\fi
%\iffalse
% \begin{macrocode}
- % These all involve differentiating from 1st principles
-
-\newproblem{dfp:xcube}{%
-Differentiate $f(x) = x^3$ with respect to $x$ by first principles.}{%
-\begin{eqnarray*}
-\frac{dy}{dx} & = & \lim_{\Delta x\rightarrow 0}\frac{f(x+\Delta x) - f(x)}{\Delta x}\\
- & = & \lim_{\Delta x\rightarrow 0}\frac{(x+\Delta x)^3-x^3}{\Delta x}\\
- & = & \lim_{\Delta x\rightarrow 0}\frac{(x+\Delta x)(x^2+2x\Delta x+(\Delta x)^2)-x^3}{\Delta x}\\
- & = & \lim_{\Delta x\rightarrow 0}\frac{x^3+3x^2\Delta x+3x(\Delta x)^2+(\Delta x)^3-x^3}{\Delta x}\\
- & = & \lim_{\Delta x\rightarrow 0}\frac{3x^2\Delta x+3x(\Delta x)^2+(\Delta x)^3}{\Delta x}\\
- & = & \lim_{\Delta x\rightarrow 0}3x^2+3x\Delta x + (\Delta x)^2\\
- & = & 3x^2
-\end{eqnarray*}}
+ % This file is public domain
+\documentclass[a4paper]{article}
+
+\usepackage{probsoln}
+ %uncomment the following line to display the answers
+\showanswers
+
+ % The following will generate a different set of
+ % problems each year
+ %\PSNrandseed{\year}
+
+ % Load 1 problem randomly selected from the given file
+ % and store in database 'firstprinciples':
+\loadrandomproblems[firstprinciples]{1}{prob-1stprncp}
+
+ % Load 5 problems randomly selected from the given file
+ % and store in database 'easy':
+\loadrandomproblems[easy]{5}{prob-easy}
+
+ % Load 2 problems randomly selected from the given file
+ % and store in database 'implicit':
+\loadrandomproblems[implicit]{2}{prob-implicit}
+
+ % Load 2 problems randomly selected from the given file
+ % and store in database 'probspaces':
+\loadrandomproblems[probspaces]{2}{prob-probspaces}
+
+ % Load 1 problem randomly selected from the given file
+ % and store in database 'mchoice':
+\loadrandomproblems[mchoice]{1}{prob-mchoice}
+
+ % Load 1 problem randomly selected from the given file
+ % and store in database 'nosoln':
+\loadrandomproblems[nosoln]{1}{prob-nosoln}
+
+
+\begin{document}
+\title{Sample Problem Sheet}
+\author{Nicola Talbot}
+\maketitle
+
+\begin{enumerate}
+ % Differentiation from first principles
+ \foreachproblem[firstprinciples]{\item \thisproblem}
+
+\item Differentiate the following functions:
+\begin{enumerate}
+ \foreachproblem[easy]{\item \thisproblem}
+\end{enumerate}
+
+ % Implicit differentiation
+\foreachproblem[implicit]{\item \thisproblem}
+
+ % Finite probability spaces
+\foreachproblem[probspaces]{\item \thisproblem}
+
+ % Multiple choice question
+\foreachproblem[mchoice]{\item \thisproblem}
+
+ % select one essay style question that doesn't come with a solution
+
+\foreachproblem[nosoln]{\item \thisproblem}
+\end{enumerate}
+\end{document}
+% \end{macrocode}
+%\fi
+%\iffalse
+% \begin{macrocode}
+%
+% \end{macrocode}
+%\fi
+%\iffalse
+% \begin{macrocode}
+%<*sample2.tex>
+% \end{macrocode}
+%\fi
+%\iffalse
+% \begin{macrocode}
+ % This file is public domain
+\documentclass[a4paper]{article}
+
+\usepackage{probsoln}
+ %uncomment the following line to display the answers
+\showanswers
+
+ % The following will generate a different set of
+ % problems in subsequent years
+ %\PSNrandseed{\year}
+
+ % The following will generate a different set of
+ % problems on every run (where each run is at
+ % least a minute apart from the previous one)
+\PSNrandseed{\time}
+
+\begin{document}
+\title{Sample Problem Sheet}
+\author{Nicola Talbot}
+\maketitle
+
+\begin{enumerate}
+
+\newcounter{numproblems}
+ % store a random number from 1 to 3 in the counter numproblems
+\random{numproblems}{1}{3}
+
+ % selects 1,2 or 3 problems from 1 of the given files:
+\doforrandN{1}{\file}{prob-1stprncp,prob-implicit}{\selectrandomly{\file}{\value{numproblems}}}
+
+\item Differentiate the following functions:
+\input{prob-args}% load database
+\begin{enumerate}
+\newcounter{A}
+\newcounter{B}
+\newcounter{C}
+\random{A}{-4}{5}
+\random{B}{-3}{3}
+\random{C}{-1}{10}
+\item \useproblem{diff:quad}{\arabic{A}}{\arabic{B}}{\arabic{C}}
+
+\random{A}{-5}{5}
+ % make sure its not 0
+\whiledo{\value{A}=0}{\random{A}{-5}{5}}
+\item \useproblem{diff:sin}{\arabic{A}}
+\end{enumerate}
+\end{enumerate}
+\end{document}
+% \end{macrocode}
+%\fi
+%\iffalse
+% \begin{macrocode}
+%
+% \end{macrocode}
+%\fi
+%\iffalse
+% \begin{macrocode}
+%<*sample3.tex>
+% \end{macrocode}
+%\fi
+%\iffalse
+% \begin{macrocode}
+ % This file is public domain
+\documentclass[a4paper]{article}
+
+\usepackage{longtable}
+\usepackage{probsoln}
+
+ %\showanswers
+
+\newcounter{problem}
+\renewcommand{\PSNitem}{\refstepcounter{problem}%
+\theproblem. }
+\renewcommand{\endPSNitem}{\\}
+
+\renewenvironment{solution}{}{}
+
+\newcommand{\selected}{\fbox{$\times$}}
+\newcommand{\notselected}{\fbox{\phantom{$\times$}}}
+
+\begin{document}
+\begin{longtable}{lrrrl}
+\bfseries Question & \bfseries A & \bfseries B &
+\bfseries C & \ifshowanswers \bfseries Reason\fi\\
+\selectrandomly{prob-tabmchoice}{2}
+\end{longtable}
+\end{document}
+% \end{macrocode}
+%\fi
+%\iffalse
+% \begin{macrocode}
+%
+% \end{macrocode}
+%\fi
+%\iffalse
+% \begin{macrocode}
+%<*sample4.tex>
+% \end{macrocode}
+%\fi
+%\iffalse
+% \begin{macrocode}
+ % This file is public domain
+\documentclass[a4paper]{article}
+
+\usepackage{probsoln}
+
+ % Sample file illustrating use of \loadallproblems
+ % All problems defined in specified file will be used
+ % in order of definition
+
+ \loadallproblems{prob-easy}
+ %\loadselectedproblems{diffeasy:gpowh,diffeasy:arccos}{prob-easy}
+ %\loadexceptproblems{diffeasy:gpowh,diffeasy:arccos}{prob-easy}
+
+ \showanswers
+
+\begin{document}
+Differentiate the following functions:
+\begin{enumerate}
+ \foreachproblem{\item \thisproblem}
+\end{enumerate}
+\end{document}
+% \end{macrocode}
+%\fi
+%\iffalse
+% \begin{macrocode}
+%
+% \end{macrocode}
+%\fi
+%\iffalse
+% \begin{macrocode}
+%<*sample5.tex>
+% \end{macrocode}
+%\fi
+%\iffalse
+% \begin{macrocode}
+ % This file is public domain
+\documentclass[a4paper]{report}
+
+\usepackage{probsoln}
+
+\begin{document}
+\hideanswers
+
+\chapter{Easy Problems}
+\loadrandomproblems[easyproblems]{5}{prob-easy2}
+
+\renewcommand{\theenumi}{\thechapter.\arabic{enumi}}
+\begin{enumerate}
+\foreachproblem[easyproblems]{\item\label{prob:\thisproblemlabel}\thisproblem}
+\end{enumerate}
+
+\chapter{Probability Spaces}
+\loadrandomproblems[probspaces]{2}{prob-probspaces2}
+
+\renewcommand{\theenumi}{\thechapter.\arabic{enumi}}
+\begin{enumerate}
+\foreachproblem[probspaces]{\item\label{prob:\thisproblemlabel}\thisproblem}
+\end{enumerate}
+
+\appendix
+\chapter{Solutions}
+\showanswers
+\begin{enumerate}
+\foreachdataset{\thisdataset}{%
+\foreachproblem[\thisdataset]{\item[\ref{prob:\thisproblemlabel}]\thisproblem}
+}
+\end{enumerate}
+
+\end{document}
+% \end{macrocode}
+%\fi
+%\iffalse
+% \begin{macrocode}
+%
+% \end{macrocode}
+%\fi
+%\iffalse
+% \begin{macrocode}
+%<*sample6.tex>
+% \end{macrocode}
+%\fi
+%\iffalse
+% \begin{macrocode}
+\documentclass{article}
+
+\usepackage[usedefaultargs]{probsoln}
+
+\loadallproblems{prob-args}
+
+\begin{document}
+\begin{enumerate}
+\foreachproblem{\item \thisproblem}
+\end{enumerate}
+\end{document}
+% \end{macrocode}
+%\fi
+%\iffalse
+% \begin{macrocode}
+%
+% \end{macrocode}
+%\fi
+%\iffalse
+% \begin{macrocode}
+%<*sample7.tex>
+% \end{macrocode}
+%\fi
+%\iffalse
+% \begin{macrocode}
+\documentclass{article}
+
+\usepackage{tikz}
+\usepackage{probsoln}
+
+\loadallproblems{prob-mixed}
+
+\begin{document}
+\section{Exercises}
+\begin{enumerate}
+ \foreachproblem{\item\label{q-\thisproblemlabel} \thisproblem}
+\end{enumerate}
+
+\section{Solutions}
+\showanswers
+
+\begin{enumerate}
+ \foreachsolution{\item[\ref{q-\thisproblemlabel}] \thisproblem}
+\end{enumerate}
+\end{document}
+% \end{macrocode}
+%\fi
+%\iffalse
+% \begin{macrocode}
+%
+% \end{macrocode}
+%\fi
+%\iffalse
+% \begin{macrocode}
+%<*prob-1stprncp.tex>
+% \end{macrocode}
+%\fi
+%\iffalse
+% \begin{macrocode}
+ % This file is public domain
+ %
+ % These problems all involve differentiating from 1st principles
+
+\newproblem{dfp:xcube}{%
+Differentiate $f(x) = x^3$ with respect to $x$ by first principles.}{%
+\begin{eqnarray*}
+\frac{dy}{dx} & = & \lim_{\Delta x\rightarrow 0}\frac{f(x+\Delta x) - f(x)}{\Delta x}\\
+ & = & \lim_{\Delta x\rightarrow 0}\frac{(x+\Delta x)^3-x^3}{\Delta x}\\
+ & = & \lim_{\Delta x\rightarrow 0}\frac{(x+\Delta x)(x^2+2x\Delta x+(\Delta x)^2)-x^3}{\Delta x}\\
+ & = & \lim_{\Delta x\rightarrow 0}\frac{x^3+3x^2\Delta x+3x(\Delta x)^2+(\Delta x)^3-x^3}{\Delta x}\\
+ & = & \lim_{\Delta x\rightarrow 0}\frac{3x^2\Delta x+3x(\Delta x)^2+(\Delta x)^3}{\Delta x}\\
+ & = & \lim_{\Delta x\rightarrow 0}3x^2+3x\Delta x + (\Delta x)^2\\
+ & = & 3x^2
+\end{eqnarray*}}
\newproblem{dfp:Ioverxsq}{%
Differentiate $\displaystyle f(x) = \frac{1}{x^2}$ with respect to $x$ by first principles.}{%
@@ -1795,22 +2467,24 @@ differentiate from first principles $f(x) = \cos x$.}{%
%\fi
%\iffalse
% \begin{macrocode}
-%1stprncp.tex>
+%
% \end{macrocode}
%\fi
%\iffalse
% \begin{macrocode}
-%<*args.tex>
+%<*prob-args.tex>
% \end{macrocode}
%\fi
%\iffalse
% \begin{macrocode}
+ % This file is public domain
+ %
% These problems require arguments
-
+%
% Arguments: #1->a_2, #2->a_1 and #3->a_0
% (Arguments must be integers)
\newcount\ctr
-\newproblem[3]{diff:quad}{%
+\newproblem[3][{1}{2}{3}]{diff:quad}{%
\(f(x) =
\ifnum#1=0
\else
@@ -1844,26 +2518,30 @@ differentiate from first principles $f(x) = \cos x$.}{%
\)
}
-\newproblem[1]{diff:sin}{%
-\(f(x) = \sin(#1x)\)
-}{%
-\(f'(x) = #1\cos(#1x)\)
-}
-
+\begin{defproblem}[1][{6}]{diff:sin}
+\begin{onlyproblem}
+ \(f(x) = \sin(#1x)\)
+\end{onlyproblem}
+\begin{onlysolution}
+ \(f'(x) = #1\cos(#1x)\)
+\end{onlysolution}
+\end{defproblem}
% \end{macrocode}
%\fi
%\iffalse
% \begin{macrocode}
-%
+%
% \end{macrocode}
%\fi
%\iffalse
% \begin{macrocode}
-%<*easy.tex>
+%<*prob-easy.tex>
% \end{macrocode}
%\fi
%\iffalse
% \begin{macrocode}
+ % This file is public domain
+ %
% These are all easy differentiation problems
\newproblem{diffeasy:gpowh}{%
@@ -1953,16 +2631,18 @@ $y = \frac{\sin x}{x}$.}{%
%\fi
%\iffalse
% \begin{macrocode}
-%
+%
% \end{macrocode}
%\fi
%\iffalse
% \begin{macrocode}
-%<*easy2.tex>
+%<*prob-easy2.tex>
% \end{macrocode}
%\fi
%\iffalse
% \begin{macrocode}
+ % This file is public domain
+ %
% These are all easy differentiation problems
\begin{defproblem}{diffeasy:gpowh}%
@@ -2102,16 +2782,18 @@ $y = \frac{\sin x}{x}$.
%\fi
%\iffalse
% \begin{macrocode}
-%
+%
% \end{macrocode}
%\fi
%\iffalse
% \begin{macrocode}
-%<*implicit.tex>
+%<*prob-implicit.tex>
% \end{macrocode}
%\fi
%\iffalse
% \begin{macrocode}
+ % This file is public domain
+ %
% These are all implicit differentiation problems
\newproblem{imd:circ}{%
@@ -2157,16 +2839,19 @@ xe^{xy}\frac{dy}{dx} - \frac{dy}{dx} & = & 2 - ye^{xy} \\
%\fi
%\iffalse
% \begin{macrocode}
-%
+%
% \end{macrocode}
%\fi
%\iffalse
% \begin{macrocode}
-%<*mchoice.tex>
+%<*prob-mchoice.tex>
% \end{macrocode}
%\fi
%\iffalse
% \begin{macrocode}
+ % This file is public domain
+ %
+ % These problems are for multiple choice questions
\newproblem{mc:prod}{%
Which of the following is the derivative of $x\sin(x)$?
(Circle the correct answer.)
@@ -2184,37 +2869,130 @@ Which of the following is the derivative of $x\sin(x)$?
\end{description}
}
-\newproblem{mc:quot}{%
-Which of the following is the derivative of $\frac{\sin(x)}{x}$?
-(Circle the correct answer.)
-\ifthenelse{\boolean{showanswers}}{}%
-{\begin{description}
-\item[A] $\sin(x)$
-\item[B] $\cos(x)$
-\item[C] $\frac{\cos(x)x-\sin(x)}{x^2}$
-\end{description}
-}}{%
-\begin{description}
-\item[A] $\sin(x)$
-\item[B] $\cos(x)$
-\item[\textcircled{C}] $\frac{\cos(x)x-\sin(x)}{x^2}$
-(quotient rule)
-\end{description}
-}
+\newproblem{mc:quot}{%
+Which of the following is the derivative of $\frac{\sin(x)}{x}$?
+(Circle the correct answer.)
+\ifthenelse{\boolean{showanswers}}{}%
+{\begin{description}
+\item[A] $\sin(x)$
+\item[B] $\cos(x)$
+\item[C] $\frac{\cos(x)x-\sin(x)}{x^2}$
+\end{description}
+}}{%
+\begin{description}
+\item[A] $\sin(x)$
+\item[B] $\cos(x)$
+\item[\textcircled{C}] $\frac{\cos(x)x-\sin(x)}{x^2}$
+(quotient rule)
+\end{description}
+}
+% \end{macrocode}
+%\fi
+%\iffalse
+% \begin{macrocode}
+%
+% \end{macrocode}
+%\fi
+%\iffalse
+% \begin{macrocode}
+%<*prob-mixed.tex>
+% \end{macrocode}
+%\fi
+%\iffalse
+% \begin{macrocode}
+ % This file is public domain
+ %
+ % These problems are a mixture of essay-style and questions with
+ % answers. One of these problems requires the tikz package
+
+\newproblem*{oop}{Describe what is meant by object-oriented
+programming.}
+
+\begin{defproblem}{inheritance}
+ Describe what is meant by the term \emph{inheritance} in
+ object-oriented programming. Use examples.
+\end{defproblem}
+
+\begin{defproblem}{weightedcoin}%
+ \begin{onlyproblem}
+ A coin is weighted so that heads is four times as likely
+ as tails. Find the probability that:
+ \begin{textenum}
+ \item tails appears,
+ \item heads appears
+ \end{textenum}%
+ \end{onlyproblem}%
+ \begin{onlysolution}
+ Let $p=P(T)$, then $P(H)=4p$. We require $P(H)+P(T)=1$,
+ so $4p+p=1$, hence $p=\frac{1}{5}$. Therefore:
+ \begin{textenum}
+ \item $P(T)=\frac{1}{5}$,
+ \item $P(H)=\frac{4}{5}$
+ \end{textenum}
+ \end{onlysolution}
+\end{defproblem}
+
+\begin{defproblem}{validprobspaces}
+\begin{onlyproblem}%
+Under which of the following functions does
+$S=\{a_1,a_2\}$ become a probability space?
+\par
+\begin{textenum}
+\begin{tabular}{ll}
+\item $P(a_1)=\frac{1}{3}$, $P(a_2)=\frac{1}{2}$
+&
+\item\label{validprobspacescorrect1} $P(a_1)=\frac{3}{4}$,
+$P(a_2)=\frac{1}{4}$
+\\
+\item\label{validprobspacescorrect2} $P(a_1)=1$, $P(a_2)=0$
+&
+\item $P(a_1)=\frac{5}{4}$, $P(a_2)=-\frac{1}{4}$
+\end{tabular}
+\end{textenum}
+\end{onlyproblem}%
+\begin{onlysolution}%
+\ref{validprobspacescorrect1} and \ref{validprobspacescorrect2}%
+\end{onlysolution}
+\end{defproblem}
+
+\begin{defproblem}{digraph}\label{ex:digraph}
+ \begin{onlyproblem}
+ Identify, if any, the sinks and sources of the digraph shown in Figure~\ref{fig:digraph}.
+
+ \begin{figure}[tbh]
+ \centering
+ \begin{tikzpicture}[every node/.style={draw,circle}]
+ \path (0,0) node (A) {$A$}
+ (1,0) node (B) {$B$}
+ (0,1) node (C) {$C$};
+ \draw[->] (A) -- (B);
+ \draw[->] (B) -- (C);
+ \draw[->] (A) -- (C);
+ \end{tikzpicture}
+ \par
+ \caption{Digraph for Question~\ref{ex:digraph}}
+ \label{fig:digraph}
+ \end{figure}
+ \end{onlyproblem}
+ \begin{onlysolution}
+ $A$ is a souce and $C$ is a sink.
+ \end{onlysolution}
+\end{defproblem}
% \end{macrocode}
%\fi
%\iffalse
% \begin{macrocode}
-%
+%
% \end{macrocode}
%\fi
%\iffalse
% \begin{macrocode}
-%<*newdata.tex>
+%<*prob-newdata.tex>
% \end{macrocode}
%\fi
%\iffalse
% \begin{macrocode}
+ % This file is public domain
\begin{defproblem}{sample}
\begin{onlyproblem}
Differentiate $y=\sin x$
@@ -2245,16 +3023,18 @@ $y' = 2x$
%\fi
%\iffalse
% \begin{macrocode}
-%
+%
% \end{macrocode}
%\fi
%\iffalse
% \begin{macrocode}
-%<*nosoln.tex>
+%<*prob-nosoln.tex>
% \end{macrocode}
%\fi
%\iffalse
% \begin{macrocode}
+ % This file is public domain
+ %
% these problems don't have solutions
\newproblem*{oop}{Describe what is meant by object-oriented
@@ -2266,16 +3046,18 @@ programming.}
%\fi
%\iffalse
% \begin{macrocode}
-%
+%
% \end{macrocode}
%\fi
%\iffalse
% \begin{macrocode}
-%<*probspaces.tex>
+%<*prob-probspaces.tex>
% \end{macrocode}
%\fi
%\iffalse
% \begin{macrocode}
+ % This file is public domain
+ %
% Finite probability spaces
\newproblem{weightedcoin}{%
A coin is weighted so that heads is four times as likely
@@ -2311,16 +3093,18 @@ $S=\{a_1,a_2\}$ become a probability space?
%\fi
%\iffalse
% \begin{macrocode}
-%
+%
% \end{macrocode}
%\fi
%\iffalse
% \begin{macrocode}
-%<*probspaces2.tex>
+%<*prob-probspaces2.tex>
% \end{macrocode}
%\fi
%\iffalse
% \begin{macrocode}
+ % This file is public domain
+ %
% Finite probability spaces
\begin{defproblem}{weightedcoin}
\begin{onlyproblem}%
@@ -2366,249 +3150,18 @@ $S=\{a_1,a_2\}$ become a probability space?
%\fi
%\iffalse
% \begin{macrocode}
-%
-% \end{macrocode}
-%\fi
-%\iffalse
-% \begin{macrocode}
-%<*sample.tex>
-% \end{macrocode}
-%\fi
-%\iffalse
-% \begin{macrocode}
-\documentclass[a4paper]{article}
-
-\usepackage{probsoln}
- %uncomment the following line to display the answers
-\showanswers
-
- % The following will generate a different set of
- % problems in subsequent years
- %\PSNrandseed{\year}
-\PSNrandseed{2007}
-
-\begin{document}
-\title{Sample Problem Sheet}
-\author{Nicola Talbot}
-\maketitle
-
-\begin{enumerate}
- % Differentiation from first principles
-\selectrandomly{1stprncp}{1}
-
-\item Differentiate the following functions:
-\newcount\oldseed
-\PSNgetrandseed\oldseed
-\begin{enumerate}
-\selectrandomly{easy}{5}
-\end{enumerate}
-\PSNrandseed\oldseed
-
- % Implicit differentiation
-\selectrandomly{implicit}{2}
-
- % Finite probability spaces
-\selectrandomly{probspaces}{2}
-
- % Multiple choice question
-\selectrandomly{mchoice}{1}
-
- % select one essay style question that doesn't come with a solution
-
-\selectrandomly{nosoln}{1}
-\end{enumerate}
-\end{document}
-% \end{macrocode}
-%\fi
-%\iffalse
-% \begin{macrocode}
-%
-% \end{macrocode}
-%\fi
-%\iffalse
-% \begin{macrocode}
-%<*sample2.tex>
-% \end{macrocode}
-%\fi
-%\iffalse
-% \begin{macrocode}
-\documentclass[a4paper]{article}
-
-\usepackage{probsoln}
- %uncomment the following line to display the answers
-\showanswers
-
- % The following will generate a different set of
- % problems in subsequent years
- %\PSNrandseed{\year}
-
- % The following will generate a different set of
- % problems on every run (where each run is at
- % least a minute apart from the previous one)
-\PSNrandseed{\time}
-
-\begin{document}
-\title{Sample Problem Sheet}
-\author{Nicola Talbot}
-\maketitle
-
-\begin{enumerate}
-
-\newcounter{numproblems}
- % store a random number from 1 to 3 in the counter numproblems
-\random{numproblems}{1}{3}
-
- % selects 1,2 or 3 problems from 1 of the given files:
-\doforrandN{1}{\file}{1stprncp,implicit}{\selectrandomly{\file}{\value{numproblems}}}
-
-\item Differentiate the following functions:
-\input{args}% load database
-\begin{enumerate}
-\newcounter{A}
-\newcounter{B}
-\newcounter{C}
-\random{A}{-4}{5}
-\random{B}{-3}{3}
-\random{C}{-1}{10}
-\item \useproblem{diff:quad}{\arabic{A}}{\arabic{B}}{\arabic{C}}
-
-\random{A}{-5}{5}
- % make sure its not 0
-\whiledo{\value{A}=0}{\random{A}{-5}{5}}
-\item \useproblem{diff:sin}{\arabic{A}}
-\end{enumerate}
-\end{enumerate}
-\end{document}
-% \end{macrocode}
-%\fi
-%\iffalse
-% \begin{macrocode}
-%
-% \end{macrocode}
-%\fi
-%\iffalse
-% \begin{macrocode}
-%<*sample3.tex>
-% \end{macrocode}
-%\fi
-%\iffalse
-% \begin{macrocode}
-\documentclass[a4paper]{article}
-
-\usepackage{longtable}
-\usepackage{probsoln}
-
- %\showanswers
-
-\newcounter{problem}
-\renewcommand{\PSNitem}{\refstepcounter{problem}%
-\theproblem. }
-\renewcommand{\endPSNitem}{\\}
-
-\renewenvironment{solution}{}{}
-
-\newcommand{\selected}{\fbox{$\times$}}
-\newcommand{\notselected}{\fbox{\phantom{$\times$}}}
-
-\begin{document}
-\begin{longtable}{lrrrl}
-\bfseries Question & \bfseries A & \bfseries B &
-\bfseries C & \ifshowanswers \bfseries Reason\fi\\
-\selectrandomly{tabmchoice}{2}
-\end{longtable}
-\end{document}
-% \end{macrocode}
-%\fi
-%\iffalse
-% \begin{macrocode}
-%
-% \end{macrocode}
-%\fi
-%\iffalse
-% \begin{macrocode}
-%<*sample4.tex>
-% \end{macrocode}
-%\fi
-%\iffalse
-% \begin{macrocode}
-\documentclass[a4paper]{article}
-
-\usepackage{probsoln}
-
- % Sample file illustrating use of \selectallproblems
- % All problems defined in specified file will be used
- % in order of definition
-
-\showanswers
-
-\begin{document}
-Differentiate the following functions:
-\begin{enumerate}
-\selectallproblems{easy}
-\end{enumerate}
-\end{document}
-% \end{macrocode}
-%\fi
-%\iffalse
-% \begin{macrocode}
-%
-% \end{macrocode}
-%\fi
-%\iffalse
-% \begin{macrocode}
-%<*sample5.tex>
-% \end{macrocode}
-%\fi
-%\iffalse
-% \begin{macrocode}
-\documentclass[a4paper]{report}
-
-\usepackage{probsoln}
-
-\begin{document}
-
-\hideanswers
-
-\chapter{Easy Problems}
-\loadrandomproblems[easyproblems]{5}{easy2}
-
-\renewcommand{\theenumi}{\thechapter.\arabic{enumi}}
-\begin{enumerate}
-\foreachproblem[easyproblems]{\item\label{prob:\thisproblemlabel}\thisproblem}
-\end{enumerate}
-
-\chapter{Probability Spaces}
-\loadrandomproblems[probspaces]{2}{probspaces2}
-
-\renewcommand{\theenumi}{\thechapter.\arabic{enumi}}
-\begin{enumerate}
-\foreachproblem[probspaces]{\item\label{prob:\thisproblemlabel}\thisproblem}
-\end{enumerate}
-
-\appendix
-\chapter{Solutions}
-\showanswers
-\begin{enumerate}
-\foreachdataset{\thisdataset}{%
-\foreachproblem[\thisdataset]{\item[\ref{prob:\thisproblemlabel}]\thisproblem}
-}
-\end{enumerate}
-
-\end{document}
-% \end{macrocode}
-%\fi
-%\iffalse
-% \begin{macrocode}
-%
+%
% \end{macrocode}
%\fi
%\iffalse
% \begin{macrocode}
-%<*tabmchoice.tex>
+%<*prob-tabmchoice.tex>
% \end{macrocode}
%\fi
%\iffalse
% \begin{macrocode}
+ % This file is public domain
+ %
% These problems are designed to be placed in a
% tabular environment
%
@@ -2629,7 +3182,7 @@ What is $-1+2\times3$? &
%\fi
%\iffalse
% \begin{macrocode}
-%
+%
% \end{macrocode}
%\fi
%\Finale
diff --git a/Master/texmf-dist/source/latex/probsoln/probsoln.ins b/Master/texmf-dist/source/latex/probsoln/probsoln.ins
index f9233c99474..4b5315b74ca 100644
--- a/Master/texmf-dist/source/latex/probsoln/probsoln.ins
+++ b/Master/texmf-dist/source/latex/probsoln/probsoln.ins
@@ -1,10 +1,10 @@
-% probsoln.ins generated using makedtx version 0.94b 2008/8/27 14:19
+% probsoln.ins generated using makedtx version 0.94b 2011/8/22 22:10
\input docstrip
\preamble
probsoln.dtx
- Copyright 2008 Nicola Talbot
+ Copyright 2011 Nicola Talbot
This work may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either version 1.3
@@ -18,7 +18,7 @@
The Current Maintainer of this work is Nicola Talbot.
- This work consists of the files probsoln.dtx and probsoln.ins and the derived files probsoln.sty, 1stprncp.tex, args.tex, easy.tex, easy2.tex, implicit.tex, mchoice.tex, newdata.tex, nosoln.tex, probspaces.tex, probspaces2.tex, sample.tex, sample2.tex, sample3.tex, sample4.tex, sample5.tex, tabmchoice.tex.
+ This work consists of the files probsoln.dtx and probsoln.ins and the derived files probsoln.sty, sample.tex, sample2.tex, sample3.tex, sample4.tex, sample5.tex, sample6.tex, sample7.tex, prob-1stprncp.tex, prob-args.tex, prob-easy.tex, prob-easy2.tex, prob-implicit.tex, prob-mchoice.tex, prob-mixed.tex, prob-newdata.tex, prob-nosoln.tex, prob-probspaces.tex, prob-probspaces2.tex, prob-tabmchoice.tex.
\endpreamble
@@ -26,22 +26,44 @@
\generate{\file{probsoln.sty}{\usepreamble\defaultpreamble
\usepostamble\defaultpostamble\from{probsoln.dtx}{probsoln.sty,package}}
-\file{1stprncp.tex}{\nopreamble\nopostamble\from{probsoln.dtx}{1stprncp.tex}}
-\file{args.tex}{\nopreamble\nopostamble\from{probsoln.dtx}{args.tex}}
-\file{easy.tex}{\nopreamble\nopostamble\from{probsoln.dtx}{easy.tex}}
-\file{easy2.tex}{\nopreamble\nopostamble\from{probsoln.dtx}{easy2.tex}}
-\file{implicit.tex}{\nopreamble\nopostamble\from{probsoln.dtx}{implicit.tex}}
-\file{mchoice.tex}{\nopreamble\nopostamble\from{probsoln.dtx}{mchoice.tex}}
-\file{newdata.tex}{\nopreamble\nopostamble\from{probsoln.dtx}{newdata.tex}}
-\file{nosoln.tex}{\nopreamble\nopostamble\from{probsoln.dtx}{nosoln.tex}}
-\file{probspaces.tex}{\nopreamble\nopostamble\from{probsoln.dtx}{probspaces.tex}}
-\file{probspaces2.tex}{\nopreamble\nopostamble\from{probsoln.dtx}{probspaces2.tex}}
-\file{sample.tex}{\nopreamble\nopostamble\from{probsoln.dtx}{sample.tex}}
-\file{sample2.tex}{\nopreamble\nopostamble\from{probsoln.dtx}{sample2.tex}}
-\file{sample3.tex}{\nopreamble\nopostamble\from{probsoln.dtx}{sample3.tex}}
-\file{sample4.tex}{\nopreamble\nopostamble\from{probsoln.dtx}{sample4.tex}}
-\file{sample5.tex}{\nopreamble\nopostamble\from{probsoln.dtx}{sample5.tex}}
-\file{tabmchoice.tex}{\nopreamble\nopostamble\from{probsoln.dtx}{tabmchoice.tex}}
+\file{sample.tex}{\usepreamble\defaultpreamble
+\usepostamble\defaultpostamble\from{probsoln.dtx}{sample.tex,package}}
+\file{sample2.tex}{\usepreamble\defaultpreamble
+\usepostamble\defaultpostamble\from{probsoln.dtx}{sample2.tex,package}}
+\file{sample3.tex}{\usepreamble\defaultpreamble
+\usepostamble\defaultpostamble\from{probsoln.dtx}{sample3.tex,package}}
+\file{sample4.tex}{\usepreamble\defaultpreamble
+\usepostamble\defaultpostamble\from{probsoln.dtx}{sample4.tex,package}}
+\file{sample5.tex}{\usepreamble\defaultpreamble
+\usepostamble\defaultpostamble\from{probsoln.dtx}{sample5.tex,package}}
+\file{sample6.tex}{\usepreamble\defaultpreamble
+\usepostamble\defaultpostamble\from{probsoln.dtx}{sample6.tex,package}}
+\file{sample7.tex}{\usepreamble\defaultpreamble
+\usepostamble\defaultpostamble\from{probsoln.dtx}{sample7.tex,package}}
+\file{prob-1stprncp.tex}{\usepreamble\defaultpreamble
+\usepostamble\defaultpostamble\from{probsoln.dtx}{prob-1stprncp.tex,package}}
+\file{prob-args.tex}{\usepreamble\defaultpreamble
+\usepostamble\defaultpostamble\from{probsoln.dtx}{prob-args.tex,package}}
+\file{prob-easy.tex}{\usepreamble\defaultpreamble
+\usepostamble\defaultpostamble\from{probsoln.dtx}{prob-easy.tex,package}}
+\file{prob-easy2.tex}{\usepreamble\defaultpreamble
+\usepostamble\defaultpostamble\from{probsoln.dtx}{prob-easy2.tex,package}}
+\file{prob-implicit.tex}{\usepreamble\defaultpreamble
+\usepostamble\defaultpostamble\from{probsoln.dtx}{prob-implicit.tex,package}}
+\file{prob-mchoice.tex}{\usepreamble\defaultpreamble
+\usepostamble\defaultpostamble\from{probsoln.dtx}{prob-mchoice.tex,package}}
+\file{prob-mixed.tex}{\usepreamble\defaultpreamble
+\usepostamble\defaultpostamble\from{probsoln.dtx}{prob-mixed.tex,package}}
+\file{prob-newdata.tex}{\usepreamble\defaultpreamble
+\usepostamble\defaultpostamble\from{probsoln.dtx}{prob-newdata.tex,package}}
+\file{prob-nosoln.tex}{\usepreamble\defaultpreamble
+\usepostamble\defaultpostamble\from{probsoln.dtx}{prob-nosoln.tex,package}}
+\file{prob-probspaces.tex}{\usepreamble\defaultpreamble
+\usepostamble\defaultpostamble\from{probsoln.dtx}{prob-probspaces.tex,package}}
+\file{prob-probspaces2.tex}{\usepreamble\defaultpreamble
+\usepostamble\defaultpostamble\from{probsoln.dtx}{prob-probspaces2.tex,package}}
+\file{prob-tabmchoice.tex}{\usepreamble\defaultpreamble
+\usepostamble\defaultpostamble\from{probsoln.dtx}{prob-tabmchoice.tex,package}}
}
\endbatchfile
diff --git a/Master/texmf-dist/tex/latex/probsoln/probsoln.sty b/Master/texmf-dist/tex/latex/probsoln/probsoln.sty
index fe9a6d3b2b6..365b1075773 100644
--- a/Master/texmf-dist/tex/latex/probsoln/probsoln.sty
+++ b/Master/texmf-dist/tex/latex/probsoln/probsoln.sty
@@ -7,7 +7,7 @@
%% probsoln.dtx (with options: `probsoln.sty,package')
%%
%% probsoln.dtx
-%% Copyright 2008 Nicola Talbot
+%% Copyright 2011 Nicola Talbot
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
@@ -21,7 +21,7 @@
%%
%% The Current Maintainer of this work is Nicola Talbot.
%%
-%% This work consists of the files probsoln.dtx and probsoln.ins and the derived files probsoln.sty, 1stprncp.tex, args.tex, easy.tex, easy2.tex, implicit.tex, mchoice.tex, newdata.tex, nosoln.tex, probspaces.tex, probspaces2.tex, sample.tex, sample2.tex, sample3.tex, sample4.tex, sample5.tex, tabmchoice.tex.
+%% This work consists of the files probsoln.dtx and probsoln.ins and the derived files probsoln.sty, sample.tex, sample2.tex, sample3.tex, sample4.tex, sample5.tex, sample6.tex, sample7.tex, prob-1stprncp.tex, prob-args.tex, prob-easy.tex, prob-easy2.tex, prob-implicit.tex, prob-mchoice.tex, prob-mixed.tex, prob-newdata.tex, prob-nosoln.tex, prob-probspaces.tex, prob-probspaces2.tex, prob-tabmchoice.tex.
%%
%% \CharacterTable
%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@@ -47,9 +47,8 @@
%% Display the problems
%% You may need to change \theenumi back here
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{probsoln}[2008/08/25 v3.0 (NLCT)]
+\ProvidesPackage{probsoln}[2011/08/22 v3.01 (NLCT)]
\RequirePackage{ifthen}
-\RequirePackage{substr}
\RequirePackage{amsmath}
\newif\ifshowanswers
\showanswersfalse
@@ -57,6 +56,10 @@
\let\hideanswers\showanswersfalse
\DeclareOption{answers}{\showanswerstrue}
\DeclareOption{noanswers}{\showanswersfalse}
+\newif\ifusedefaultprobargs
+\DeclareOption{usedefaultargs}{\usedefaultprobargstrue}
+\DeclareOption{nousedefaultargs}{\usedefaultprobargsfalse}
+\usedefaultprobargsfalse
\newcommand*{\prob@showdraftlabel}[2]{}
\newcommand*{\draftproblemlabel}[2]{[#1,#2]}
\DeclareOption{draft}{%
@@ -66,10 +69,12 @@
\ProcessOptions
\newcommand*{\prob@db@default}{}
\newcommand*{\prob@databases}{default}
+\newcommand*{\prob@db@default@solutions}{}
\newcommand*{\prob@newdb}[1]{%
\@ifundefined{prob@db@#1}{%
\expandafter\gdef\csname prob@db@#1\endcsname{}%
\xdef\prob@databases{\prob@databases,#1}%
+ \expandafter\gdef\csname prob@db@#1@solutions\endcsname{}%
}{%
\PackageError{probsoln}{Data set `#1' is already defined}{}}}
\newcommand*{\prob@currentdb}{default}
@@ -127,37 +132,60 @@
\do@moveargs
}%
}
-\newcommand{\prob@newproblem}[4]{%
-\@ifundefined{prob@db@#2}{\prob@newdb{#2}}{}%
-\@ifundefined{prob@data@#2@#3}{%
-\let\@tmp=\undefined
-\newcommand\@tmp[#1]{#4}%
-\expandafter\global\expandafter\let
- \csname prob@data@#2@#3\endcsname=\@tmp
-\expandafter\xdef\csname prob@argN@#2@#3\endcsname{\number#1}%
-\let\@tmp=\undefined
-\expandafter\ifx\csname prob@db@#2\endcsname\@empty
- \expandafter\xdef\csname prob@db@#2\endcsname{#3}%
-\else
- \expandafter\xdef\csname prob@db@#2\endcsname{%
- \csname prob@db@#2\endcsname,#3}%
-\fi
-\ifnum#1>0\relax
- \@prob@do@getargs{#1}{#2}{#3}%
-\fi
- }{%
- \PackageError{probsoln}{Problem `#3' is already defined for
- data base `#2'}{Problem labels must be unique for each data base}}%
+\newcommand{\prob@newproblem}[5]{%
+ \@ifundefined{prob@db@#2}{\prob@newdb{#2}}{}%
+ \@ifundefined{prob@data@#2@#3}%
+ {%
+ \let\@tmp=\undefined
+ \newcommand\@tmp[#1]{#4}%
+ \expandafter\global\expandafter\let
+ \csname prob@data@#2@#3\endcsname=\@tmp
+ \expandafter\xdef\csname prob@argN@#2@#3\endcsname{\number#1}%
+ \let\@tmp=\undefined
+ \expandafter\ifx\csname prob@db@#2\endcsname\@empty
+ \expandafter\xdef\csname prob@db@#2\endcsname{#3}%
+ \else
+ \expandafter\xdef\csname prob@db@#2\endcsname{%
+ \csname prob@db@#2\endcsname,#3}%
+ \fi
+ \ifx\@empty#5\@empty
+ \else
+ \edef\thisprob@currentdb{#2}%
+ \edef\thisprob@currentlabel{#3}%
+ \expandafter\@setdefaultprobargs\expandafter{#5}%
+ \fi
+ }%
+ {%
+ \PackageError{probsoln}{Problem `#3' is already defined for
+ data base `#2'}{Problem labels must be unique for each data base}%
+ }%
}
\newcommand{\@prob@gobblethree}[3]{}
\newcommand{\@prob@getargs}[3]{%
\message{Problem `#3' (in data base `#2') requires #1 argument(s).^^J
-Please specify (e.g. {5}{3}):}%
+Please specify (e.g. \csname @prob@getargs@eg@\romannumeral#1\endcsname):}%
\read-1to\@tmp
\expandafter\global\expandafter\let
\csname prob@args@#2@#3\endcsname=\@tmp
}
+\def\@prob@getargs@eg@i{{12}}
+\def\@prob@getargs@eg@ii{{5}{3}}
+\def\@prob@getargs@eg@iii{{4}{5}{2}}
+\def\@prob@getargs@eg@iv{{5}{3}{10}{8}}
+\def\@prob@getargs@eg@v{{5}{3}{10}{8}{4}}
+\def\@prob@getargs@eg@vi{{5}{3}{10}{8}{4}{24}}
+\def\@prob@getargs@eg@vii{{5}{3}{10}{8}{4}{24}{32}}
+\def\@prob@getargs@eg@viii{{5}{3}{10}{8}{4}{24}{32}{9}}
+\def\@prob@getargs@eg@ix{{5}{3}{10}{8}{4}{24}{32}{9}{2}}
\let\@prob@do@getargs\@prob@gobblethree
+\newcommand*{\setprobargs}[3][default]{%
+ \expandafter\gdef\csname prob@args@#1@#2\endcsname{#3}%
+}
+\newcommand*{\@setdefaultprobargs}[1]{%
+ \ifusedefaultprobargs
+ \setprobargs[\thisprob@currentdb]{\thisprob@currentlabel}{#1}%
+ \fi
+}
\long\def\long@collect@body#1{%
\@envbody{\@xp#1\@xp{\the\@envbody}}%
\edef\process@envbody{\the\@envbody\@nx\end{\@currenvir}}%
@@ -167,9 +195,15 @@ Please specify (e.g. {5}{3}):}%
\edef\process@envbody{\@xp\@nx\csname\@currenvir\endcsname}%
\process@envbody
}
-\long\def\long@addto@envbody#1{\global\@envbody\@xp{\the\@envbody#1}}
+\long\def\long@addto@envbody#1{%
+ \toks@{#1}%
+ \edef\@psn@tmp{\the\@envbody\the\toks@}%
+ \global\@envbody\@xp{\@psn@tmp}%
+}
\long\def\long@collect@@body#1\end#2{%
- \edef\begin@stack{\long@push@begins#1\begin\end \@xp\@gobble\begin@stack}%
+ \protected@edef\begin@stack{%
+ \long@push@begins#1\begin\end \@xp\@gobble\begin@stack
+ }%
\ifx\@empty\begin@stack
\endgroup
\@checkend{#2}%
@@ -182,22 +216,60 @@ Please specify (e.g. {5}{3}):}%
\long\def\long@push@begins#1\begin#2{%
\ifx\end#2\else b\@xp\long@push@begins\fi
}
-\newenvironment{defproblem}[2][0]{%
- \def\@prob@currentargN{#1}%
+\newenvironment{defproblem}[1][0]{%
+ \edef\@prob@currentargN{\number0#1}%
+ \@defproblem@beginenv
+}{}
+
+\newcommand*{\@defproblem@beginenv}[2][]{%
+ \def\@prob@currentdefaultargs{#1}%
\def\@prob@currentlabel{#2}%
\long@collect@body\prob@do@defproblem
-}{}
+}
\newcommand{\prob@do@newproblem}[1]{%
-\prob@newproblem\@prob@currentargN\prob@currentdb
- \@prob@currentlabel{#1}}
+ \prob@newproblem\@prob@currentargN\prob@currentdb
+ \@prob@currentlabel{#1}{\@prob@currentdefaultargs}}
\let\prob@do@defproblem=\prob@do@newproblem
\newenvironment{onlysolution}{%
\long@collect@body\do@onlysolution
}{}
\newcommand{\do@onlysolution}[1]{%
-\ifshowanswers
- #1%
-\fi}
+ \ifshowanswers
+ #1%
+ \fi
+ \@ifundefined{@prob@currentlabel}
+ {}%
+ {%
+ \expandafter
+ \psn@add@unique@label
+ \csname prob@db@\prob@currentdb @solutions\endcsname{%
+ \@prob@currentlabel
+ }%
+ }%
+}
+\newcommand*{\psn@add@unique@label}[2]{%
+ \ifx#1\@empty
+ \xdef#1{#2}%
+ \else
+ \edef\@tmp@label{#2}%
+ \expandafter\DTLifinlist\expandafter{\@tmp@label}{#1}%
+ {}% ignore
+ {\xdef#1{#1,\@tmp@label}}%
+ \fi
+}
+\providecommand{\DTLifinlist}[4]{%
+ \def\@dtl@doifinlist##1,#1,##2\end@dtl@doifinlist{%
+ \def\@before{##1}%
+ \def\@after{##2}%
+ }%
+ \expandafter\@dtl@doifinlist\expandafter,#2,#1,\@nil
+ \end@dtl@doifinlist
+ \ifx\@after\@nnil
+ #4%
+ \else
+ #3%
+ \fi
+}
\newenvironment{onlyproblem}{%
\long@collect@body\do@onlyproblem
}{}
@@ -207,15 +279,20 @@ Please specify (e.g. {5}{3}):}%
#1%
\fi}
\newcommand{\useproblem}[2][default]{%
-\prob@showdraftlabel{#1}{#2}%
-\let\@next=\relax
-\@ifundefined{prob@data@#1@#2}{%
- \PackageError{probsoln}{Problem `#2' is not defined in data set
- `#1'}{}%
-}{%
- \def\@next{\csname prob@data@#1@#2\endcsname}%
-}%
-\@next}
+ \def\@prob@currentlabel{#2}%
+ \def\prob@currentdb{#1}%
+ \prob@showdraftlabel{#1}{#2}%
+ \let\@useprob@next=\relax
+ \@ifundefined{prob@data@#1@#2}%
+ {%
+ \PackageError{probsoln}%
+ {Problem `#2' is not defined in data set `#1'}{}%
+ }%
+ {%
+ \def\@useprob@next{\csname prob@data@#1@#2\endcsname}%
+ }%
+ \@useprob@next
+}
\newcommand*{\loadallproblems}[2][default]{%
\bgroup
\let\par\relax
@@ -224,8 +301,11 @@ Please specify (e.g. {5}{3}):}%
\egroup
}
\newcommand{\prob@do@selectedproblem}[1]{%
-\IfSubStringInString{,\@prob@currentlabel,}{,\prob@selectedlabels,}{%
-\prob@do@newproblem{#1}}{}%
+ \expandafter\DTLifinlist\expandafter{\@prob@currentlabel}{\prob@selectedlabels}%
+ {%
+ \prob@do@newproblem{#1}%
+ }%
+ {}%
}
\newcommand{\loadselectedproblems}[3][default]{%
\bgroup
@@ -236,6 +316,22 @@ Please specify (e.g. {5}{3}):}%
\input{#3}%
\egroup
}
+\newcommand{\prob@do@exceptedproblem}[1]{%
+ \expandafter\DTLifinlist\expandafter{\@prob@currentlabel}{\prob@selectedlabels}%
+ {}%
+ {%
+ \prob@do@newproblem{#1}%
+ }%
+}
+\newcommand{\loadexceptproblems}[3][default]{%
+\bgroup
+ \let\par\relax
+ \edef\prob@currentdb{#1}%
+ \edef\prob@selectedlabels{#2}%
+ \let\prob@do@defproblem=\prob@do@exceptedproblem
+ \input{#3}%
+\egroup
+}
\newcommand{\prob@add@currentlabel}[1]{%
\ifx\prob@selectedlabels\@empty
\xdef\prob@selectedlabels{\@prob@currentlabel}%
@@ -246,6 +342,12 @@ Please specify (e.g. {5}{3}):}%
\newif\iffirstpass
\firstpasstrue
\newcommand{\loadrandomproblems}[3][default]{%
+ \@loadrandomproblems{#1}{#2}{#3}{}%
+}
+\newcommand{\loadrandomexcept}[4][default]{%
+ \@loadrandomproblems{#1}{#2}{#3}{#4}%
+}
+\newcommand{\@loadrandomproblems}[4]{%
\bgroup
\let\par\relax
\def\prob@db@reserved{}%
@@ -256,17 +358,20 @@ Please specify (e.g. {5}{3}):}%
\input{#3}%
\@probselN=0\relax
\@for\@thislabel:=\prob@selectedlabels\do{%
- \advance\@probselN by 1\relax
- \expandafter
- \edef\csname @prob@tmp@\romannumeral\@probselN\endcsname{%
- \@thislabel}%
+ \expandafter\DTLifinlist\expandafter
+ {\@thislabel}{#4}{}%
+ {%
+ \advance\@probselN by 1\relax
+ \expandafter
+ \edef\csname @prob@tmp@\romannumeral\@probselN\endcsname{%
+ \@thislabel}%
+ }%
}%
\shuffle{@prob@tmp@}{\@probselN}%
\ifnum\@probselN<#2\relax
- \PackageError{probsoln}{%
- Can't select \number#2\space\space problem(s):^^J
- '#3' only contains \number\@probselN\space problem(s)}{%
- Only \number\@probselN\space problem(s) will be selected}%
+ \PackageWarning{probsoln}{You have requested
+ \number#2\space\space problem(s) but `#3' only contains
+ \number\@probselN\space problems. All problems will be selected}%
\else
\@probselN=#2\relax
\fi
@@ -317,6 +422,33 @@ Please specify (e.g. {5}{3}):}%
}%
}%
}
+\newcommand{\foreachsolution}[2][default]{%
+\@ifundefined{prob@db@#1}{%
+ \PackageError{probsoln}{Data base `#1' is not defined}{}%
+}{%
+ \expandafter\let\expandafter\@tmp\csname prob@db@#1@solutions\endcsname
+ \@for\thisproblemlabel:=\@tmp\do{%
+ \ifx\thisproblemlabel\@empty
+ \else
+ \expandafter\ifnum
+ \csname prob@argN@#1@\thisproblemlabel\endcsname>0\relax
+ \@ifundefined{prob@args@#1@\thisproblemlabel}{%
+ \expandafter\@prob@getargs
+ \csname prob@argN@#1@\thisproblemlabel\endcsname
+ {#1}{\thisproblemlabel}}{}%
+ \expandafter\let\expandafter\thisproblemargs
+ \csname prob@args@#1@\thisproblemlabel\endcsname
+ \else
+ \let\thisproblemargs\@empty
+ \fi
+ \expandafter\toks@\expandafter{\thisproblemargs}%
+ \edef\thisproblem{\noexpand\useproblem[#1]{\thisproblemlabel}%
+ \the\toks@}%
+ #2%
+ \fi
+ }%
+}%
+}
\newcommand{\foreachdataset}[2]{%
\@for#1:=\prob@databases\do{#2}}
\newcount\@probN \newcount\@probselN \newcount\@rndselctr
@@ -324,35 +456,50 @@ Please specify (e.g. {5}{3}):}%
\newcount\@ps@randtmp
\r@ndcur=1\relax
\newcommand*{\PSNrandseed}[1]{%
-\ifnum#1=0\relax
- \PackageWarning{probsoln}{Can't have 0 as random seed, changing to 1}%
- \global\r@ndcur=1\relax
-\else
- \global\r@ndcur=#1\relax
-\fi
-\PackageInfo{probsoln}{Random Seed = \number\r@ndcur}%
+ \ifnum#1=0\relax
+ \PackageWarning{probsoln}{Can't have 0 as random seed, changing to 1}%
+ \global\r@ndcur=1\relax
+ \else
+ \global\r@ndcur=#1\relax
+ \fi
+ \PackageInfo{probsoln}{Random Seed = \number\r@ndcur}%
}
\newcommand*{\PSNgetrandseed}[1]{#1=\r@ndcur\relax}
\newcommand*{\PSNrand}{%
-\@ps@randtmp=\r@ndcur
-\multiply\@ps@randtmp by 16807\relax
-\r@ndcur=\@ps@randtmp
-\global\divide\r@ndcur by 120001\relax
-\global\multiply\r@ndcur by 120001\relax
-\advance\@ps@randtmp by -\r@ndcur
-\global\r@ndcur = \@ps@randtmp
-\ifnum\r@ndcur=0\relax
- \global\r@ndcur=1\relax
-\fi
+ \@ps@randtmp=\r@ndcur
+ \multiply\@ps@randtmp by 16811\relax
+ \r@ndcur=\@ps@randtmp
+ \global\divide\r@ndcur by 39989\relax
+ \global\multiply\r@ndcur by 39989\relax
+ \advance\@ps@randtmp by -\r@ndcur
+ \global\r@ndcur = \@ps@randtmp
+ \ifnum\r@ndcur=0\relax
+ \global\r@ndcur=1\relax
+ \fi
+}
+\newcommand*{\PSN@old@rand}{%
+ \@ps@randtmp=\r@ndcur
+ \multiply\@ps@randtmp by 16807\relax
+ \r@ndcur=\@ps@randtmp
+ \global\divide\r@ndcur by 120001\relax
+ \global\multiply\r@ndcur by 120001\relax
+ \advance\@ps@randtmp by -\r@ndcur
+ \global\r@ndcur = \@ps@randtmp
+ \ifnum\r@ndcur=0\relax
+ \global\r@ndcur=1\relax
+ \fi
+}
+\newcommand*{\PSNuseoldrandom}{%
+ \let\PSNrand\PSN@old@rand
}
\newcommand{\PSNrandom}[2]{%
-\PSNrand
-#1=\r@ndcur
-\@ps@randtmp=\r@ndcur
-\divide\@ps@randtmp by #2\relax
-\multiply\@ps@randtmp by #2\relax
-\advance#1 by -\@ps@randtmp
-\advance#1 by 1\relax
+ \PSNrand
+ #1=\r@ndcur
+ \@ps@randtmp=\r@ndcur
+ \divide\@ps@randtmp by #2\relax
+ \multiply\@ps@randtmp by #2\relax
+ \advance#1 by -\@ps@randtmp
+ \advance#1 by 1\relax
}
\newcommand{\random}[3]{%
\ifnum#2=1\relax
@@ -368,58 +515,73 @@ Please specify (e.g. {5}{3}):}%
}
\newcount\@shfctr \newcount\@shfA \newcount\@shfB
\newcommand{\shuffle}[2]{%
-\@shfctr=1\relax
-\whiledo{\@shfctr < 101}{%
-\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}%
-\fi
-\advance\@shfctr by 1\relax
-}%
+ \@shfctr=1\relax
+ \whiledo{\@shfctr < 101}%
+ {%
+ \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}%
+ \fi
+ \advance\@shfctr by 1\relax
+ }%
}
\newcount\@ps@forrand
\newcommand{\doforrandN}[4]{%
-{\@ps@forrand=0\relax
-\@for#2:=#3\do{%
-\advance\@ps@forrand by 1\relax
-\expandafter\edef\csname @doforrandN@\romannumeral\@ps@forrand\endcsname{#2}}%
-\ifnum\@ps@forrand<#1\relax
-\PackageError{probsoln}{Can't randomly select \number#1 item(s)}{You
-have requested \number#1 item(s), but there
-are only \number\@ps@forrand item(s) in the list}%
-\else
-\shuffle{@doforrandN@}{\@ps@forrand}%
-\ifnum#1>0\relax
-\@ps@forrand=0\relax
-\loop
-\advance\@ps@forrand by 1\relax
-\edef#2{\csname @doforrandN@\romannumeral\@ps@forrand\endcsname}%
-#4%
-\ifnum\@ps@forrand<#1\relax
-\repeat
-\fi
-\fi
-}}
+ {%
+ \@ps@forrand=0\relax
+ \@for#2:=#3\do{%
+ \advance\@ps@forrand by 1\relax
+ \expandafter
+ \edef\csname @doforrandN@\romannumeral\@ps@forrand\endcsname{#2}%
+ }%
+ \ifnum\@ps@forrand<#1\relax
+ \PackageError{probsoln}{Can't randomly select \number#1 item(s)}{You
+ have requested \number#1 item(s), but there
+ are only \number\@ps@forrand item(s) in the list}%
+ \else
+ \shuffle{@doforrandN@}{\@ps@forrand}%
+ \ifnum#1>0\relax
+ \@ps@forrand=0\relax
+ \loop
+ \advance\@ps@forrand by 1\relax
+ \edef#2{\csname @doforrandN@\romannumeral\@ps@forrand\endcsname}%
+ #4%
+ \ifnum\@ps@forrand<#1\relax
+ \repeat
+ \fi
+ \fi
+ }%
+}
\newcommand*{\newproblem}{\@ifstar\@snewproblem\@newproblem}
-\newcommand{\@snewproblem}[3][0]{%
-\begin{defproblem}[#1]{#2}%
-#3%
-\end{defproblem}}
-\newcommand{\@newproblem}[4][0]{%
-\begin{defproblem}[#1]{#2}%
-#3%
-\begin{onlysolution}%
-\begin{solution}%
-#4%
-\end{solution}%
-\end{onlysolution}%
-\end{defproblem}}
+\newcommand{\@snewproblem}[1][0]{%
+ \def\@newprob@argN{#1}%
+ \@s@newproblem
+}%
+\newcommand{\@s@newproblem}[3][]{%
+ \begin{defproblem}[\@newprob@argN][#1]{#2}%
+ #3%
+ \end{defproblem}%
+}
+\newcommand{\@newproblem}[1][0]{%
+ \def\@newprob@argN{#1}%
+ \@ns@newproblem
+}
+\newcommand{\@ns@newproblem}[4][]{%
+ \begin{defproblem}[\@newprob@argN][#1]{#2}%
+ #3%
+ \begin{onlysolution}%
+ \begin{solution}%
+ #4%
+ \end{solution}%
+ \end{onlysolution}%
+ \end{defproblem}%
+}
\newcommand*{\selectallproblems}[1]{{\loadallproblems[#1]{#1}}%
\foreachproblem[#1]{\PSNitem\thisproblem\endPSNitem}}
\newcommand*{\selectrandomly}[2]{%
@@ -428,21 +590,28 @@ are only \number\@ps@forrand item(s) in the list}%
}
\newenvironment{PSNitem}{\item}{}
\@ifundefined{solution}{%
-\newenvironment{solution}{\par\noindent\textbf{\solutionname:}}{}%
+ \newenvironment{solution}{\par\noindent\textbf{\solutionname:}\space
+ \ignorespaces}{}%
}{}
\newcommand*{\solutionname}{Solution}
\newenvironment{textenum}{%
-\ifnum\@enumdepth>\thr@@
- \@toodeep
-\else
- \advance\@enumdepth\@ne
- \edef\@enumctr{enum\romannumeral\the\@enumdepth}%
- \let\@item\@textitem
- \def\@itemlabel{\refstepcounter{\@enumctr}%
- \csname label\@enumctr\endcsname}%
- \setcounter{\@enumctr}{0}%
-\fi\ignorespaces}{%
-\global\advance\@enumdepth\m@ne}
+ \ifnum\@enumdepth>\thr@@
+ \@toodeep
+ \else
+ \advance\@enumdepth\@ne\relax
+ \edef\@enumctr{enum\romannumeral\the\@enumdepth}%
+ \let\@item\@textitem
+ \def\@itemlabel{%
+ \refstepcounter{\@enumctr}%
+ \csname label\@enumctr\endcsname
+ }%
+ \setcounter{\@enumctr}{0}%
+ \fi
+ \ignorespaces
+}%
+{%
+ \global\advance\@enumdepth\m@ne\relax
+}
\def\@textitem[#1]{#1\space\ignorespaces}
\newcommand*{\correctitemformat}[1]{\fbox{#1}}
\newcommand*{\incorrectitemformat}[1]{%
--
cgit v1.2.3