Background:
I am stuck on a "Dimension too large" problem which is occurring during index generation. This is a large index of links to files (along with other related information), and am sure the problem is not with the indexing packages, but in my code that adds the related information. The message I get in my actual use case is:
./FileName-FileName.ind:8741: Dimension too large. \pgfmath@x
l.8741 ...path to file} \hyperpage{119} ?
If I reduce the size of this index (even if it includes the offending file that was being linked to, as listed in the error message above) the problem does not occur. So, it is not a problem with the file listed in the error message, but with the macros that determine which related information to add.
If I could get a stack dump and know what part of my code calls pgfmath before the problem occurs, then I could have some hope of determining the root of the problem. This same code is executed 1000s of times before the problem shows up, so I can't just terminate early by putting an undefined macro in the code to do a manual trace.
Sample Test Case
Although things are obvious in the "cooked" up MWE below, they are not in my actual code. The MWE below terminates with:
./TeX-SE.tex:38: Dimension too large.
to be read again
\relax l.38 }
%
So, from the error message I know where the problem originates in the main source code. But form there, how do I determine where the problem lies? Also note that the error message here gives no indication that the problem is some pgfmath function.
References:
Notes:
- In the MWE below, the source of the problem is obvious and several fixes are possible. But, in my actual use case I have not yet been able to narrow down the source of a problem with a similar error message. So, this question is about how do I narrow down the source of the problem, not how do I fix this specific issue..
Code:
\begin{filecontents*}{GrillFunctions.sty}
\newcommand*{\FunctionValue}[1]{%
% ... lots of code ....
\pgfmathsetmacro{\NewValue}{\arabic{MyCounter}/100}%
\num{\NewValue}%
% ... lots of code ....
}
\end{filecontents*}
\begin{filecontents*}{GrillMacros.sty}
\newcommand*{\DeterminePercentage}[1]{%
% ... lots of code ....
% ... Don't know what in here is creating the problem.
% Obvious given this MWE, but in actual usage not so obvious
\FunctionValue{#1}%
% ... lots of code ....
}
\end{filecontents*}
\documentclass[12pt]{article}
\usepackage{siunitx}
\usepackage{xstring}
\usepackage{tikz}
\usepackage{GrillFunctions}
\usepackage{GrillMacros}
\newcounter{MyCounter}
\setcounter{MyCounter}{100000}
\begin{document}
\IfStrEq{\arabic{MyCounter}}{0}{%
Value of counter is zero.%
}{%
Value of counter is \DeterminePercentage{\arabic{MyCounter}}.%
}%
\end{document}
\tracingall/'marker' macros is so important in debugging TeX code. As such, perhaps all we will be able to say is that you'll have to try to isolate the conditions for the error (not an answer, clearly!). – Joseph Wright Aug 05 '14 at 06:19\tracingallgets its information from? If one could access that, then it should be possible to build a stack trace. Or perhaps I can conditionally enable\tracingallafter a certain number of iterations. I will try that... – Peter Grill Aug 05 '14 at 06:33\tracingmacros=2to the MWE, I don't see how to read that to find the problem. Even knowing that the problem is with\FunctionValuein this case and searching for it in the log file, we see that\FunctionValueshows up only on the lines around 870 in the log file, but there are over 2000 lines in the log file. – Peter Grill Aug 05 '14 at 06:49tracingmacros=2on the MWE and its output to determine the location of the problem. – Peter Grill Aug 05 '14 at 06:59\expandafter\def\expandafter\NewValue\expandafter {\the\numexpr \value{MyCounter}/100\relax }, or with an\edef. – Sep 27 '14 at 19:25