Smile for the Camera: a new cybercrime short story ebook.

probsoln package FAQ

This is the FAQ for the probsoln package. See also the package documentation and The probsoln Package.

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.

2020-07-03 10:26:33

Top

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.

2020-07-03 11:11:19

Top

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.

2020-07-03 11:12:04

Top

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.

2013-12-09 09:53:52

Top

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:

\doforrandN{10}{\file}{file1,file2,file3}{%
\loadrandomproblems{2}{\file}}
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.

2020-07-03 11:13:01

Top

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.

2020-07-03 11:13:58

Top

Something's wrong-perhaps a missing \item 🔗

This error occurs when you have a list type of environment without 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

\begin{enumerate}
\foreachproblem{\item\thisproblem}
\end{enumerate}
will produce this error message (because the body of the loop never gets implemented because there aren’t any problems).

2020-07-03 11:14:42

Top

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:

\iffirstpass
\newcommand{\mycmd}{}
\fi
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.

2020-07-03 11:15:46

Top

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.

2020-07-03 11:16:22

Top

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.

2020-07-03 11:16:56

Top

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.

2020-07-03 11:18:24

Top

General Queries

How do I substitute the word “Solution” for something else? 🔗

Redefine \solutionname. For example:

\renewcommand{\solutionname}{La soluci\'on}

2020-07-03 11:19:02

Top

How do I change the way the word “Solution” is formatted? 🔗

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

\renewenvironment{solution}{\par\textsf{\solutionname}}{}

2020-07-03 11:19:32

Top

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:

\begin{enumerate}
\foreachproblem{\item\thisproblem\par\hrulefill}
\end{enumerate}

2020-07-03 11:20:19

Top

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:

\begin{defproblem}{sample}%
What is $2+3$? & 1 & 5 & 10 & 42
\end{defproblem}
Then load the problems (say you want to randomly select 10 problems from myproblems.tex):
\loadrandomproblems{10}{myproblems}
Now display the problems:
\begin{tabular}{lllll}
\bfseries Question & \bfseries A & \bfseries B & \bfseries C &
\bfseries D\\
\foreachproblem{\thisproblem\\}%
\end{tabular}
(If the table is likely to be longer than a page, then use longtable or supertabular instead of tabular.)

2020-07-03 11:21:46

Top

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

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

2013-12-09 10:08:19

Top

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.

2020-07-03 11:23:45

Top

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:

\begin{defproblem}{inheritance}%
Describe what is meant by the term \emph{inheritance} in
object-oriented programming. Use examples.%
\end{defproblem}
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.}

2020-07-03 11:24:49

Top

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:

\begin{enumerate}
\selectallproblems{probs}
\end{enumerate}
As with \selectrandomly, \selectallproblems uses \PSNitem at the start of each problem.

2020-07-03 11:26:15

Top

Can I assign a certain number of points to each problem? 🔗

Unlike the datatool package, the probsoln package doesn’t have a concept of columns or fields so it’s not possible to assign associated data to a particular problem.

If you want to switch to datatool, try reading Using the datatool Package for Exams or Assignment Sheets.

If you want to stick with the probsoln package, then there are several approaches. The examples below use a very simplistic definition of a custom command called \points. You will need to modify it to fit in with your document.

2020-07-03 11:55:20

Top