I have a piece of code, which sometimes compiled correctly, other times it gives an error.
Is it possible that the package fp is unstable? Or might another package conflict with fp? How could I fix this error? I am also willing to switch to another package, if there is an alternative.
Here is the relevant code of the file (with all used packages):
\documentclass[addpoints,12pt]{exam}
\usepackage{array}
\usepackage[nomessages]{fp}%Számoláshoz
\newcommand{\gradekey}[4]{\begin{tabular}{rcrl>{\bfseries}l}
\FPeval{\result}{round(#4*\numpoints,0)}\result&-&\numpoints&&5\\
\FPeval{\result}{round(#3*\numpoints,0)}\result&-&\FPeval{\result}{round(#4*\numpoints-1,0)}\result&&4\\
\FPeval{\result}{round(#2*\numpoints,0)}\result&-&\FPeval{\result}{round(#3*\numpoints-1,0)}\result&&3\\
\FPeval{\result}{round(#1*\numpoints,0)}\result&-&\FPeval{\result}{round(#2*\numpoints-1,0)}\result&&2\\
0&-&\FPeval{\result}{round(#1*\numpoints-1,0)}\result&&1\\
\end{tabular}
}
\newcommand{\defaultgradekey}{%
\begin{center}\gradekey{0.35}{0.5}{0.75}{0.9}\end{center}
}
%%
\begin{document}
\defaultgradekey
\begin{questions}
\question[50] Question 1
\end{questions}
\end{document}
Here is the error message from my logfile:
(Line numbers are larger, as I left all unrelevant code from the MWE)
! FP error: Illegal character \unhbox found in float number!. \FP@errmessage #1->\errmessage {FP error: #1!}
l.145 \defaultgradekey
This error message was generated by an \errmessage command, so I can't give any explicit help. Pretend that you're Hercule Poirot: Examine all clues, and deduce the truth by order and method.
! FP error: Illegal character \voidb@x found in float number!. \FP@errmessage #1->\errmessage {FP error: #1!}
l.145 \defaultgradekey
(That was another \errmessage.)
! FP error: Illegal character \hbox found in float number!. \FP@errmessage #1->\errmessage {FP error: #1!}
l.145 \defaultgradekey
(That was another \errmessage.)
! Missing control sequence inserted.
\inaccessiblel.145 \defaultgradekey
Please don't say
\def cs{...}', say\def\cs{...}'. I've inserted an inaccessible control sequence so that your definition will be completed without mixing me up too badly. You can recover graciously from this error, if you're careful; see exercise 27.2 in The TeXbook.
The last part (from !Missing control sequence inserted) repeats many many (infinite?) times. I don't know whether it's infinite, as I killed the compilation after a reasonable amount of time.
If I comment out the lines containing \FPeval, there is no error, and the pdf file is generated. After that, there is no error even if I uncomment those lines.
But, if I delete the .aux file, the error is there again. So it seems to me that because of the \FPeval commands (inside of the \newcommand), the .aux file cannot be produced somehow.
I use pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016/Debian).
(On Windows, I could also reproduce my problem, with MikTex 2.9)
pdflatex. – Heiko Oberdiek Dec 04 '17 at 09:10\numpointsis a macro and defined as\@ifundefined {exam@numpoints}{\mbox {\normalfont \bfseries??}}\exam@numpoints. This explodes in \FPeval. Give\exam@numpointsa sensible default definition (e.g. 0). – Ulrike Fischer Dec 04 '17 at 09:25