Compilation fails when there are no figures or no tables in the document
mattwigway opened this issue · 2 comments
I get this error when building with XeLaTeX (MacTeX 2020) after deleting the sample chapters and starting my own:
Package calculator Warning: The value of the variable
(calculator) in the logarithm function must be positive
(calculator) I can't define log(0) on input line 1094.
! Undefined control sequence.
<argument> \cctr@logx
l.1094 \listoffigures
If I put a figure somewhere in the dissertation, it compiles fine. I get a similar error if there are no tables. I think the culprit is the algorithm that calculates the number of digits in the figure count - when there are no figures, \totfig and \tottables are 0, and the code tries to take Log10(0).
Thanks Matthew, I think you're right. The problem is this section:
544 % Here is the algorithm:
545 % Floor(Log10(\number)) + 1
546 \LOG[10]{\totfig}{\tempAfig}%
547 \FLOOR{\tempAfig}{\tempBfig}%
548 \ADD{\tempBfig}{1}{\digitsinfig}% % Number of digits in number of figs
And in this section:
574 \LOG[10]{\tottab}{\tempAtab}%
575 \FLOOR{\tempAtab}{\tempBtab}%
576 \ADD{\tempBtab}{1}{\digitsintab}% % Number of digits in number of tabs
If the total number of figures or tables in the document is zero, then the calculator
package ends up trying to perform Log10(0), which results in the error that you're seeing. As a temporary workaround, you can probably replace \totfig
and \tottab
with "1".
The longer term fix is probably using the calculator
package to take a maximum of \totfig
and "1" and use that value instead of \totfig
directly. (And the same change for \tottab
.) That way, the log function always operates on a number that is equal or greater than 1.
This issue is resolved by 996867a