0

My goal is to have half points that are printed with a comma as a decimal symbol (e.g. 2,5 points). Thus, I use a workaround and multiply all points with 10 and use the patchmd command from etoolbox together with the FPDiv and numprint command from fp and numprint packages for dividing by 10 and printing the number with the correct decimal symbol, respectively (see Exam package decimal points). However, I also want the number of points to be printed at the title of the \titledquestion. For that, I am using the command \qformat{\Large \textbf{Aufgabe \thequestion: \thequestiontitle~(\totalpoints~Punkte)} \hfill}. The problem here is that I have no idea how to correctly patch the \totalpoints command. Having looked into the exam.cls source, I saw that is defined as \pointsofquestion{\arabic{question}}. I tried patching both of them, but the first compilation always fails. It only works if I compile it a second time, when the patch command is commented out on the first compilation. I would appreciate any help.

Here is a minimial working example that showcases my problem:

\documentclass[addpoints, 10pt, answers]{exam}
\usepackage{etoolbox}
\usepackage{fp}
\usepackage{numprint}
\npdecimalsign{,}
\nprounddigits{1}

% Only works on 2nd compile
\patchcmd{\totalpoints}{\pointsofquestion{\arabic{question}}}{\FPdiv\pointdiv{\pointsofquestion{\arabic{question}}}{10}\numprint{\pointdiv}}{}{}

\qformat{\Large \textbf{Task \thequestion: \thequestiontitle~(\totalpoints~Points)} \hfill}
\begin{document}

\newpage
\begin{questions}
    \titledquestion{Question 1}
    \begin{parts}
    \part[20] Subtask 1
    \part[15] Subtask 2
    \end{parts}
\end{questions}

\end{document}
2

1 Answer 1

1

As a quick workaround you can modify the definition of \pointsofquestion to output -10 if the points are not calculated yet (i.e., at the first run), instead of ?? which confuses \FPdiv.

\documentclass[addpoints]{exam}
\usepackage{etoolbox}
\usepackage{fp}
\usepackage{numprint}
\npdecimalsign{,}
\nprounddigits{1}

\patchcmd{\pointsofquestion}{\mbox{\normalfont\bfseries ??}}{-10}{}{}
\patchcmd{\totalpoints}{\pointsofquestion{\arabic{question}}}{\FPdiv\pointdiv{\pointsofquestion{\arabic{question}}}{10}\numprint{\pointdiv}}{}{}

\qformat{\Large \textbf{Task \thequestion: \thequestiontitle~(\totalpoints~Points)} \hfill}
\begin{document}

Points of question 1: \pointsofquestion{1}
\begin{questions}
    \titledquestion{Question 1}
    \begin{parts}
    \part[20] Subtask 1
    \part[15] Subtask 2
    \end{parts}
\end{questions}

\end{document}

First compilation:

enter image description here

Second compilation:

enter image description here

1
  • This is exactly what I need. My project compiles twice anyway, so the points are shown correctly at the first manual compile already. Thanks! Mar 1 at 21:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .