Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

It is an unfortunate reality that one must compile a LaTeX file several times in order to get all labels and citations correct. As far as I know, one should go on compiling as long as TeX warns that that "labels may have changed", and two or three passes may not be enough.

Is it possible to write a LaTeX document that never stabilizes, i.e., no matter how many times I compile it, it will go on complaining that labels have changed?

I am thinking about something like a \pageref{something} written in a large font that moves from page 9 to page 10, which requires longer to typeset and thus makes the corresponding label change page and so on ad infinitum.

share|improve this question
    
We will need a minimal example. –  Joseph Wright Oct 6 '11 at 11:37
7  
@JosephWright That's the question! :) –  egreg Oct 6 '11 at 11:50
1  
Due to the halting problem, it isn't even possible to find out, if the document will eventually compile without label-changes. –  FUZxxl Oct 6 '11 at 12:01
    
it's possible that with some add-on packages, this warning becomes "pathological". we know it's true with the package amsbooktoc (which is sent out to ams authors only on request, so it's not in general distribution), but haven't had time to track down the source of the problem yet. however, after the number of runs normally required to get a good table of contents, the document is stable, so we just warn our authors about what they should check for. but i believe this is a different situation than you are describing. –  barbara beeton Oct 6 '11 at 12:17
2  
@FUZxxl That isn't true: That just states that there exists a class of problems exists for which you cannot prove if they will halt or not. Not all problems belong to that class. For example, you can mathematically prove that while(n>0){n++;} will go forever, and that n=10;while(n<10){n--}; will halt. –  Canageek Jan 22 '12 at 20:47
show 9 more comments

3 Answers 3

up vote 19 down vote accepted

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}
share|improve this answer
    
Cool, that's exactly what I was looking for. I hope @RoelofSpijker won't mind if I accept this answer instead. –  Federico Poloni Oct 30 '12 at 14:01
add comment

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.

share|improve this answer
    
Nevertheless the output is stable: the 'A' at the end is typeset in '\Huge' fontsize. –  Count Zero Oct 6 '11 at 11:52
    
The output is different each time, the A might have the same size, but it is not on the same page. The output switches between having 0 and 1 blank pages prior to the Huge A. I would not call that stable at all. –  Roelof Spijker Oct 6 '11 at 11:56
    
As a matter of fact, thats incorrect. The A also switches between Huge and small size. Change the capital A to a lowercase a in the else branch to see this a little more clearly. –  Roelof Spijker Oct 6 '11 at 11:59
5  
Now someone should put this into latexmk and watch it run forever. –  Canageek Jan 22 '12 at 21:23
2  
@Canageek: I got 'pdflatex' needed too many passes after latexmk compiled it five times. –  Martin Scharrer May 1 '12 at 18:48
show 2 more comments

I accidently 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 appearently 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?

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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