Free Software
Recent news (2017-02-08): Added aliases example to the glossaries-extra.sty gallery.

probsoln package FAQ

Search: Category:
Search Tips

This is the FAQ for the probsoln package. See also the package documentation.

Unexpected Output

I have lots of blank space before the first problem when using \selectrandomly

This is probably because you have lots of extraneous white space in your database. \selectrandomly will input the entire file, so any extra space will be included. Try commenting out the extra space using %.

As from version 3.0, you can first load the problems using \loadselectedproblems, and then iterate through the data set using \foreachproblem, so you may find it easier to load the problems in the preamble where the space between problem definitions won't matter. (Spaces occurring within problem definitions will still matter.) Then in the document you can iterate through the data set.

Last Modified: 2013-12-14 10:02:07


Error Messages

Label ... already used

Each label identifier used in defproblem or \newproblem must be unique. Check to make sure you haven't used the same label more than once. Also check to make sure you haven't loaded the same file more than once.

Last Modified: 2013-12-09 09:51:53


Label ... undefined

You need to define a problem before you can use it. Check to make sure you haven't mis-spelt it, and check to make sure you have used the file in which it is defined either via \input, \loadallproblems or \loadselectedproblems. If you have used \loadrandomproblems, you shouldn't try referencing a problem since there's a chance it may not have been selected.

Last Modified: 2013-12-09 09:52:53


Requested number too large

You have asked for more problems than are defined within the specified file. All problems in that file will be selected.

Last Modified: 2013-12-09 09:53:52


Can't randomly select n item(s)

You have asked to randomly select n items from a list that has less than n elements. For example, the following will generate this error:
In this case the list, file1,file2,file3 has only 3 elements, but the user has asked for 10 elements. If you type "h" at the LaTeX prompt, it will tell you how many items it thinks there are in the list. Remember that each item must be separated by a comma.

Last Modified: 2013-12-09 09:55:34


Lonely \item-perhaps missing list environment

Each problem selected using \selectrandomly is proceeded by \PSNitem which by default is defined as \item, and should therefore be placed in one of the list environments, such as enumerate. Alternatively, redefine \PSNitem.

As from v3.0, you can iterate through a data set using \foreachproblem and which doesn't use \PSNitem as it leaves it up to you to decide how to format the problems in the body of the loop.

Last Modified: 2013-12-14 10:03:00


Something's wrong-perhaps a missing \item

This error occurs when you have a list type of environment with out any items. So if the data set is empty (i.e. you haven't defined any problems yet, or you have loaded all the problems into a different data set) then the following code
will produce this error message (because the body of the loop never gets implemented because there aren't any problems).

Last Modified: 2013-12-09 09:57:38


I get an error when I put a command definition in my database when using \selectrandomly

\selectrandomly inputs the database twice, so any command definition will be read twice, causing an error. You can use the switch \iffirstpass to prevent the error. For example:
However it is generally not a good idea to put anything other than problem definitions (\newproblem or defproblem) within the database. Note that if you use \loadallproblems, \loadselectedproblems or \loadrandomproblems, the file will be loaded within a group, so any commands in the file that occur outside of problem definitions will only have a local effect.

Last Modified: 2013-12-09 09:59:10


The solution environment is already defined

As from version 2.03, the probsoln package will not define the solution environment if it has already been defined.

Last Modified: 2013-12-09 09:59:58


Missing } inserted

Assuming you don't have a missing end group token, this can be caused if you try to put verbatim text inside the body of onlyproblem or onlysolution. See also I get an error when using verbatim text.

Last Modified: 2013-12-09 10:01:21


I get an error when using verbatim text

Remember that you can't use verbatim text in command arguments (see Why doesn't verbatim work within...?). You also can't use verbatim text within the environments defproblem, onlysolution or onlyproblem since they have to gather their contents and pass the contents in the argument of a command.

Last Modified: 2013-12-09 10:02:29


General Queries

How do I substitute the word "Solution" for something else?

Redefine \solutionname. For example:
\renewcommand{\solutionname}{La soluci\'on}

Last Modified: 2013-12-09 10:03:33


How do I change the way the word "Solution" is formatted?

Redefine the solution environment (as from version 2.01). For example:

Last Modified: 2013-12-09 10:04:27


How do I insert something at the end of each problem?

As from v3.0, you can use \foreachproblem to iterate through each problem in the data set. It's then up to you to decide how to format each problem. For example, if you want each problem to be in a separate item of a numbered list, followed by a horizontal line:

Last Modified: 2013-12-09 10:05:20


How do I stop \selectrandomly from using \item?

As from version 3.0, you can first load the randomly selected problems using \loadrandomproblems and then iterate through the data set using \foreachproblem. It's then up to you to format the problems. For example, suppose you want multiple choice style questions formatted in a tabular style environment with the question in the first column and possible answers in the subsequent columns. Then you could define the problems in the following style:
What is $2+3$? & 1 & 5 & 10 & 42
Then load the problems (say you want to randomly select 10 problems from myproblems.tex):
Now display the problems:
\bfseries Question & \bfseries A & \bfseries B & \bfseries C &
\bfseries D\\
(If the table is likely to be longer than a page, then use longtable or supertabular instead of tabular.)

Last Modified: 2013-12-09 10:07:22


How do I align my problems in a table instead of a list?

See How do I stop \selectrandomly from using \item?.

Last Modified: 2013-12-09 10:08:19


How do I determine whether or not the answers are being displayed?

Use the boolean variable showanswers. For example:
Problem Sheet 1\ifthenelse{\boolean{showanswers}}{ (Solutions)}{}
As from version 3.0, you can also use the environments onlyproblem and onlysolution.

Last Modified: 2013-12-09 10:09:24


How can I define a problem without a solution (e.g. an essay style question)?

As from version 3.0, you can just use the defproblem environment. For example:
Describe what is meant by the term \emph{inheritance} in
object-oriented programming. Use examples.%
Or, as from version 2.03, you can use \newproblem*. For example:
\newproblem*{inheritance}{Describe what is meant by the term 
\emph{inheritance} in object-oriented programming. Use examples.}

Last Modified: 2013-12-09 10:10:33


How do I select all problems from a database in the order in which they were defined?

As from version 3.0, you can load all problems in a file using \loadallproblems and then iterate through the data set using \foreachproblem. Or, as from version 2.02, you can use the command \selectallproblems. For example, if your problems are defined in the file probs.tex:
As with \selectrandomly, \selectallproblems uses \PSNitem at the start of each problem.

Last Modified: 2013-12-09 10:12:04


© 2012 Dickimaw Books. "Dickimaw", "Dickimaw Books" and the Dickimaw parrot logo are trademarks. The Dickimaw parrot was painted by Magdalene Pritchett.

Terms of Use Privacy Policy Site Map FAQs