44

I'm getting the following warning:

LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.

The problem is, it doesn't go away after rerunning (any number of times).

The document in question is over 200 pages long and includes about 30 packages, so it's not really feasible for me to provide a minimal example. But I know my own code pretty well. I can probably fix it if I knew a bit more about the problem. So I want to ask some general questions:

  • How does the "labels changed; rerun" mechanism work, anyway?
  • Is there a common culprit responsible for this problem?
  • How would someone generally go about diagnosing it?

I've read the following question:

But I'm not using the elsarticle or acronym packages, so the accepted answer didn't apply to me.


More info: As suggested, I did a kind of 'commenting out' binary search. (By the way, if LaTeX knows that labels may have changed, why can't it tell me which labels?)

Anyway, I seemed to track down the problem to a specific figure. When I compile only chapters 1 to 3, removing that figure also removes the warning. However, if I once again include all chapters, removing that figure isn't enough. So I guess there are other problem locations. But I don't have time to search chapters 4 to 9 right now...

I can also tell you this: I have a tmp directory where LaTeX and friends dump all temporary files. And between two compilations, the relevant content of this directory does not change at all. That is to say, diff -r tells me that the only changes are some timestamps and the .pdf file. In particular: all .aux files are identical.

  • 3
    Did you try the method of dividing the input into two in order to find the part that's responsible for the changing label? – egreg Jan 17 '14 at 16:54
  • 4
    Check if the varioref package is used. It's a common culprit for this kind of behaviour. The only fix would be to use a normal \ref at the point that's responsible or change the text slightly so the \vref isn't at a page boundary anymore. en.wikibooks.org/wiki/LaTeX/… – Christian Jan 17 '14 at 17:55
  • 1
    The fact that removing the figure and reinstating the missing chapter makes the problem reappear might mean that you have two similar situations. – egreg Jan 18 '14 at 14:46
  • 1
    Relevant: Understanding how references and labels work – Werner Jan 28 '14 at 17:16
  • 1
    Run a compile a few times. Copy your .aux file. Rerun the compile again, and then compare the .aux files. – bombcar Mar 13 '14 at 14:42
32

(By the way, if LaTeX knows that labels may have changed, why can't it tell me which labels?)

The following document will give the re-run error message each time.

\documentclass{article}

\makeatletter


% \def\@testdef #1#2#3{%
%   \def\reserved@a{#3}\expandafter \ifx \csname #1@#2\endcsname
%  \reserved@a  \else
% \typeout{^^Jlabel #2 changed:^^J%
% \meaning\reserved@a^^J%
% \expandafter\meaning\csname #1@#2\endcsname^^J}%
% \@tempswatrue \fi}


\begin{document}
\providecommand\r@foo{{1}{1}}
\edef\@currentlabel{.\expandafter\@firstoftwo\r@foo}
\label{foo}
a

\end{document}

produces a log

LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.

If you uncomment the block in the preamble you get an additional diagnostic telling you which label has changed, and the old and new definition:

label foo changed:
macro:->{............1}{1}
macro:->{...........1}{1}

)

LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.
  • Awesome. :-) Will try this when I get home. – mhelvens Apr 3 '14 at 14:31
  • Thanks to this diagnostic trick, I was finally able to fix the issue. It turns out, the captions of all offending labels had inline math with a _ (subscript) inside (though the before/after versions were always identical). Replacing these was all I had to do! --- I am unable to reproduce this in a minimal document. Can't say I'm surprised. I hacked around in my thesis code so much, it's hardly LaTeX anymore. --- Thanks! – mhelvens Apr 6 '14 at 18:14
  • @DavidCarlisle This diagose does not always work. I still get an infinite loop without any hints. – user877329 Aug 31 '15 at 11:04
  • @user877329 can't really say anything to a small comment, if you can make a reproducible example, please ask a new question, posting the code. – David Carlisle Aug 31 '15 at 11:06
  • @DavidCarlisle If you know a trick that works regardless of what packages you have, regardless of situation, post it. Your trick works for the first two runs, but fails on all remaining. I use harvard varioref hyperref cleveref glossaries (in that order). – user877329 Aug 31 '15 at 11:13
1

I had this issue too. I used David's excellent little snippet to catch changed references. Since the log file is very long, I grepped them out with:

$ egrep -A2 "label .* changed:" jobname.log

In my case, I found that the unstable labels were of the form pgfidnnnn, which I believe come from using the TikZ key remember picture. And they weren't changing by much. Per the manual's suggestion, I had placed \tikzstyle{every picture}+=[remember picture] in my document's preamble. I shut off this blanket option and the unstable labels disappeared.

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.