Document requiring infinitely many compiler passes?

Having an explicit \ifthenelse test makes the document look like the looping is intentional. It is possible for the cross referencing not to converge even if there is no explicit conditional switching within the file. This document for example.

\documentclass{article}

\pagenumbering{Roman}
\begin{document}

a\clearpage b\clearpage c\clearpage

\begin{figure}[!t]
\framebox(200,430){}
\caption{a figure to take up space}
\end{figure}


Some interesting text about  something in Section \ref{x},
which starts on page \pageref{x}.

\section{zzz\label{x}}
The text of an interesting section.
\end{document}

Quickly testing something, this seems to give the warning each time it is compiled.

\documentclass{article}
\usepackage{ifthen}
\begin{document}
\newcommand{\tes}[1]{\ifthenelse{\equal{#1}{1}}{\Huge A}{\small A}}
\vspace*{.95\textheight}
\tes{\pageref{test}}
\label{test}
\end{document}

So it seems that it is possible. Basically, \tes puts a huge A in front of the label if the label is on page 1, moving its location to page 2. If it's on page 2, \tes puts a small A in front of it instead, moving it back to page 1. Changed the code a little bit, no longer needs lipsum, just uses a vspace now. If you just run latex file.tex you will see the output switches between a 1 page dvi and a 2 page dvi after each run.


I accidentally created such a document for real. I used biblatex-icomp. Two consecutive citations of the same source happened to be in the vicinity of a page break. Then apparently the following happened (citing Paul Stanley's accurate description):

  1. On the first run the citation seems to fit on the first page, so the aux file records "this citation was on page 1".

  2. Next time round, biblatex looks at this, and says "OK, that fit on page 1, so I'll use ibid". Unfortunately, doing that forces the citation onto the next page, so this time the aux file records: "citation was on page 2". And biblatex (which is using "old information" about where the citation appears) wrongly prints the citation as an "ibid".

  3. All would be well if the citation stayed on page 2, because biblatex would put things right next time it ran and it would get back in sync. But in fact next time, because a full citation is used, it moves back to page 1! So this time you end up with a full citation on page 1.

  4. And next time ... you get the picture.

A working example and Paul Stanley's explanation can be found at the question Avoid infinite compiler passes with biblatex ibid citation styles?