5

Last month, I posted the following code as an answer to a question. The code gives the right output. However, what I did not notice but Thérèse did is that it generates a warning concerning undefined labels which persists no matter how many times it is compiled.

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

Why does the warning persist and what ought I to do to avoid it?

\documentclass[a4paper]{article}
\usepackage{geometry,tikz}
\usetikzlibrary{calc}
\usepackage[placement=bottom,scale=1,opacity=1]{background}
\backgroundsetup{contents={%
    \begin{tikzpicture}
      \fill [red] (current page.north west) rectangle ($(current page.north east)!.2!(current page.south east)$) coordinate (a);
      \fill [yellow] (current page.south west) rectangle (a);
    \end{tikzpicture}}}
\usepackage{kantlipsum}
\begin{document}
\kant[1-5]
\end{document}
cfr
  • 198,882

1 Answers1

5

If I were to guess, it would be that tikz thinks the current page changes when the rectangles are added. Adding the overlay option prevents the warning.

\documentclass[a4paper]{article}
\usepackage{geometry,tikz}
\usetikzlibrary{calc}
\usepackage[placement=bottom,scale=1,opacity=1]{background}
\backgroundsetup{contents={%
    \begin{tikzpicture}[overlay]
      \fill [red] (current page.north west) rectangle ($(current page.north east)!.2!(current page.south east)$) coordinate (a);
      \fill [yellow] (current page.south west) rectangle (a);
    \end{tikzpicture}}}
\usepackage{kantlipsum}
\begin{document}
\kant[1-5]
\end{document}
Guho
  • 6,115
  • Hmm. Interesting. It takes 3 compilations to resolve the references even with overlay. – cfr Jan 03 '16 at 22:34