1

I want to change the numbering of exam questions using probsoln. At the moment it just starts each question directly beneath each other and numbering it as a list. I want it to look something like this:

Question : Vraag 1

Whatever the question may be.

Question : Vraag 2

Another question

etc

Here is the code I have been using, but can't get it to change the numbering at all:

\documentclass[a4paper]{report}
\usepackage{probsoln}

\loadallproblems{prob-easy}
\showanswers

\begin{document}

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


\end{document}
\endinput

Would appreciate any help!

cgnieder
  • 66,645

1 Answers1

1

This can be done in a number of ways; first, without additional packages, you can (locally) redefine \labelenumi:

\documentclass[a4paper]{report}
\usepackage{probsoln}

\loadallproblems{prob-easy}
\showanswers

\begin{document}

\begingroup
\renewcommand\labelenumi{\textbf{Question : Vraag \arabic{enumi}}}
\begin{enumerate}
\foreachproblem{\item\thisproblem}
\end{enumerate}
\endgroup

\end{document}

You can also achieve the desired result with the help of the enumitem package:

\documentclass[a4paper]{report}
\usepackage{probsoln}
\usepackage{enumitem}

\loadallproblems{prob-easy}
\showanswers

\begin{document}

\begin{enumerate}[label=\bfseries Question : Vraag \arabic*]
\foreachproblem{\item\thisproblem}
\end{enumerate}

\end{document}

Or, defining a dedicated list:

\documentclass[a4paper]{report}
\usepackage{probsoln}
\usepackage{enumitem}

\newlist{myproblems}{enumerate}{4}
\setlist[myproblems,1]{label=\bfseries Question : Vraag \arabic*}

\loadallproblems{prob-easy}
\showanswers

\begin{document}

\begin{myproblems}
\foreachproblem{\item\thisproblem}
\end{myproblems}

\end{document}

enter image description here

The file prob-easy.tex used in my 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}

\begin{defproblem}{sinxsqsinx}%
\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}

Update

In a comment it has been requested to have the title for each problem centered in a line of its own; here's one possibility:

\documentclass[a4paper]{report}
\usepackage{probsoln}

\newcounter{myprob}
\newenvironment{myproblems}
  {\par\setcounter{myprob}{0}}
  {\par}
\newcommand\MyProb{%
  {\par\medskip\centering\refstepcounter{myprob}\bfseries Question : Vraag \arabic{myprob}\par\nobreak}%
  }

\loadallproblems{prob-easy}
%\showanswers

\begin{document}

\begin{myproblems}
\foreachproblem{\MyProb\thisproblem}
\end{myproblems}

\end{document}

enter image description here

This was prob-easy.tex:

\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}

\begin{defproblem}{texttest}%
\begin{onlyproblem}%
Some text for the example. so the problem will have text and not necessarily a math expression.%
\end{onlyproblem}%
\begin{onlysolution}%
\[\frac{dy}{dx} = -\sin(x^2)2x\sin x + \cos(x^2)\cos x\]
\end{onlysolution}%
\end{defproblem}

\begin{defproblem}{sinxsqsinx}%
\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}
Gonzalo Medina
  • 505,128
  • Thanks a lot! It works, except if I have a question that does not start with a mathematical formula, the "Question : Vraag" is on the left of the page and the question starts on the same line then. Is there any way the put it in the center of the page above the question? – user3278494 Aug 04 '14 at 15:29
  • @user3278494 Do you mean for all the questions? – Gonzalo Medina Aug 04 '14 at 15:43
  • Yes, for all the questions the "Question : Vraag" goes on the left and the immediately after that the question starts on the same line. I would like the "Question : Vraag" for each question to be above the question in the center of the page so it looks neater. Thanks!! – user3278494 Aug 04 '14 at 16:33
  • @user3278494 Please see my updated answer. – Gonzalo Medina Aug 04 '14 at 23:32
  • @user3278494 You're welcome! Don't forget that you can accept the answer, if you consider it solved your problem, by clicking the checkmark to its left. In case of doubt, please see How do you accept an answer?. – Gonzalo Medina Aug 05 '14 at 16:59