0

I have this error: Dimension to large. } the code is:

\documentclass{report}
\usepackage{pgffor}  
\parindent=0cm
\begin{document}
    \foreach \n in {1,...,20000}{
Hola a todos. el numero es \n   \\
}
\end{document}
  • Yes, the "magical number" here is 16383. If you loop until 16382, it's fine. Don't ask me why, but for historical reasons TeX has that limitation. But frankly, even after a few lines the content of that document is no longer exciting. ;-) – user121799 Nov 7 '18 at 0:49
  • @marmot Could you elaborate what exactly is the limitation here? If you rewrite that code with a plain \loop \repeat construction, you can well go beyond the 20,000 lines limit. – siracusa Nov 7 '18 at 1:56
3

I don't know if this qualifies for an answer. There are two facts that come into play:

  1. pgffor works with dimensions, see e.g. this nice answer. This has several advantages, among them the fact that you can loop over non-integers. Drawbacks include the above observation and some inaccuracies reported e.g. here.
  2. The maximal dimension is 16383.99999pt, see e.g. here. The loop will stop when the number exceeds 16383-1. A precise explanation of the -1 would require to look up the internals of pgffor, but I do not see a motivation for this.

So the bottom-line is that you cannot go above 16382 in the above loop.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.