I have a problem using \intertext
together with \vref
when hyperref is also used. Consider the following minimal example:
\documentclass{article}
\usepackage{amsmath, varioref}
\usepackage{hyperref}
\begin{document}
\begin{equation}
\label{kinetic-energy}
E = MC^2
\end{equation}
\begin{gather}
A \\
\intertext{ and therefore due to \vref{kinetic-energy}: }
B
\end{gather}
\end{document}
which yields an error message of the pattern:
! Package amsmath Error: Multiple \label's: label '1@xvr' will be lost.
at the end of the gather environment.
If I either comment out hyperref, OR use \ref
instead of \vref
the example works fine. I am using TeXLive 2011.
Have I encountered a package bug/conflict, or is there some remedial I have missed?
UPDATE:
I tried the solution of Mico, and it works except for a slight incompatibility between cleveref and refstyle (sic); it misses a space between the equation number and the page reference. Adding this to the preamble after including cleveref seems to fix the problem:
\makeatletter
\let\withoutspacecref@@vpageref\cref@@vpageref
\renewcommand\cref@@vpageref{\space\withoutspacecref@@vpageref}
\makeatother
Best Answer
You have indeed discovered a (mild) incompatibility between the
varioref
andhyperref
packages. A solution to this problem is to load yet one more cross-referencing package, viz., the cleveref package. This approach would appear to work becausecleveref
modifies some ofvarioref
's internals in order to makevarioref
andcleveref
cooperate better; in the process,varioref
andhyperref
also become mutually (more) compatible. Note that in the MWE below, the cross-referencing command that's executed is still\vref
(and not, say,\cref
).Incidentally, the
cleveref
package should be loaded later than all other packages that perform cross-referencing tasks. In fact, it's highly advisable to loadcleveref
last, i.e., after all other packages have been loaded, simply because one may not know for sure whether or not the other packages might perform certain tasks -- however trivial they may seem at first -- that are related to LaTeX's cross-referencing mechanisms.