13

This is something which has happened for real in a document where I am using varioref. The LaTeX runs never end, a text chunk keeps on being moved back and forth accross a page break (naturally with some changes each time) as a result of the [above] option when using \vpageref (one could make a similar example without use of this optional argument).

This example is designed to achieve the effect, but again originally it arose in a genuine document.

\documentclass{article}
\usepackage{varioref}
\usepackage{lipsum}

\begin{document}
\begin{center}
  \Large\bfseries Never ending \LaTeX{} runs.
\end{center}

\lipsum[1-3]

Nam dui ligula, fringilla a, euismod sodales, sollicitudin vel, wisi. 

\begin{verbatim}
Nam dui ligula, fringilla a, euismod sodales, sollicitudin
vel, wisi. Morbi auctor lorem non justo. Nam lacus libero,
pretium at, lobortis vitae, ultricies et, tellus. Donec
aliquet, tortor sed accumsan bibendum, erat ligula aliquet
magna, vitae ornare odio metus a mi. Donec aliquet, tortor
sed accumsan bibendum, erat ligula aliquet magna, vitae
ornare odio metus a mi. Donec aliquet, tortor sed accumsan
Donec aliquet, tortor sed accumsan
Donec aliquet, tortor sed accumsan
Donec aliquet, tortor sed accumsan
The magic formula is now obtained.
\end{verbatim}

\begin{figure}[ht!]
  \centering
  \fbox{\rule{0pt}{5cm}\rule{5cm}{0pt}}
  \caption {Some stuff}
  \label{table}
\end{figure}

Nam dui ligula, fringilla a, euismod sodales, sollicitudin
vel, wisi. This beautiful magic formula has been put in a
float which appears \vpageref[above]{table}. 

And here is some more stuff.
\end{document}

The two pictures are from the alternate sequence of LaTeX runs.

never ending vario 1

In fact the figure is on the next page.

never ending vario 2

No, no, the figure is right above!

Made me think of that question.

My question is: does this happen often in your experience with varioref? and would it be reasonable to qualify this as a feature of varioref which could be cured via some extra data written to the aux file to detect the problem?

  • 1
    I just read about this in the LaTeX companion ebook last night. (Kindle location 2804-24 - sorry no page numbers). They mention that an 'occasional loop' might occur but also state that 'all such situations will produce a LaTeX error message, so that you can inspect the problem and perhaps choose to use a \ref command in that place'. – Forkrul Assail Oct 27 '13 at 14:36
  • @ForkrulAssail thanks for the info but this is perhaps not of the type discussed in your reference. There is no error message in the log apart from LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right. ... and LaTeX Warning: Unused global option(s): [a5] sorry about that one, my fault. I edit the question to remove the a5. – user4686 Oct 27 '13 at 15:03
  • 1
    @ForkrulAssail the varioref documentation does speak of some situation where the page break occurs inside the text created by \vpageref. This is not of the type occurring here. – user4686 Oct 27 '13 at 15:06
  • Maybe you can bump the maintainer for a more informed answer? – Forkrul Assail Oct 27 '13 at 15:11
  • 2
    @ForkrulAssail the maintainer (and author) has seen it but he just returned from Tokyo (where he happend to talk about precisely these kind of "impossible" documents) but it is too late tonight to write an answer – Frank Mittelbach Oct 27 '13 at 23:34
12

This is a nice example of what I term "impossible document", i.e., a document those content any layout specifications do not have a valid representation. This kind of problem can happen whenever content presentation depends on content placement. This particular case the placement of the figure resulted in a reference string of different length (which when used changed the placement). With varioref the possibility of this happening is higher than in other documents (due to the fact that references will show a noticable variation in length (that is not increasing in a linear fashion).

However the phenomenon is by no means restricted to the use of varioref: here is a variation on the original input resulting in the same problem with just using base LaTeX.

\documentclass{article}

\pagenumbering{roman}
\setcounter{page}{99}

\usepackage{lipsum}

\begin{document}
\begin{center}
  \Large\bfseries Never ending \LaTeX{} runs.
\end{center}

\lipsum[1-3]


Nam dui ligula, fringilla a, euismod sodales, sollicitudin
vel, wisi. Morb i. This beautiful magic formula has been put in 
figure~\ref{table} which appears on page \pageref{table}. 


\begin{figure}[ht!]
  \centering
  \fbox{\rule{0pt}{4cm}\rule{5cm}{0pt}}
  \caption {Some stuff}
  \label{table}
\end{figure}

And here is some more stuff.
\end{document}

This will give us

enter image description here

which is wrong as the figure is on page "xcix" and not on page "c" followed by

enter image description here

which is wrong too as now the figure was shifted to page "c".

But there are many other possibilities to construct "impossible documents" basically all you need content formatting that is violating a "linear" behavior, i.e., requires less space if move to a "later" place in the document (or results in some other earlier object needing less space, as it was the acase above).

A nice candidate for this is the paragraph breaking algorithm: as it is globally optimizin the whole paragraph is is possible to delete a word or two and get a paragraph that increases in length.

Concerning the question: "can this be automatically detected"? Not really, at least not 100% reliable. From the outside, what you could/would need to do is to verify that all auxiliary files remain unchanged between two different runs as well as the visual results, e.g., the generated pdf or dvi are identical (except for time stamps). But the issue here is that "all auxiliary" means more than just the .aux file and packages are free to use additional helper files to comunicate between runs. Furthermore you could have randomness in your document, e.g., by using the date and time of the formatting run as part of the input.

By the way, the LaTeX Companion is not claiming that varioref identifies all these cases, it is only discussing the most often case that you have the reference string being broken across pages for which the package gives an error.

Your Answer

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