I'm writing a LaTeX template that works similar to a spreadsheet: One defines a small number of variables and the whole document is adjusted accordingly.
I have three variables: Level, ProficiencyBonus and AbilityScore. Here is my MWE:
\documentclass{article}
\usepackage{ifthen}
\usepackage{calculator}
\begin{document}
\newcommand\Level{3}
\newcommand\ProficiencyBonus{%
\ifthenelse{\Level<5}{2}{3}%
}
\newcommand\AbilityScore{%
\ADD{\ProficiencyBonus}{10}{\TMP}%
\TMP%
}
Level: \Level \\
Proficiency Bonus: \ProficiencyBonus \\
Ability Score: \AbilityScore
\end{document}
This snippet produces and error during the addition:
Missing number, treated as zero.
Illegal unit of measure (pt inserted).
I suspect that \ifthenelse somehow doesn't return the "pure" number (are there "invisible" additional tokens?). However, I don't know how to debug this problem: I tried unsuccessfully to gain insight in the return value of \ifthenelse using \show and \meaning.
I'd appreciate any help that either solves this problem or shows me how to debug such a situation.
(I use XeLaTeX but this error appears also with normal LaTeX.)