I have two documents (A and B) with labels. I would like to reference the labels in document A from document B. I would like to use the hyperref
package to create hyperlinks in document B to the labels within document B. I want to resolve the references in document B to document A with the correct numbering, but I do not want to create hyperlinks for theses references. Is this possible? My motivation is that document A is being published on an external site, so I can't link to references within it and I don't want broken hyperlinks.
- If I use the
xr-hyper
package (a great minimal example is available in this answer to the question "Does hyperref work between two files?"), LaTeX will create a link to document A from document B when document B references a label in document A. - If I use the
xr
package instead ofxr-hyper
, LaTeX will create a hyper link to label 1 of document B when document B references label 1 of document A (i.e. it still tries to create hyperlinks but it does not link them outside of the document).
For a full minimal working example, look at this adapted version of the example given in the answer here:
docA.tex
\documentclass{article}
\usepackage{xr-hyper}
\usepackage{hyperref}
\externaldocument[B-]{docB}[docB.pdf]% <- full or relative path
\begin{document}
This is a test for math.
\begin{equation}
E=mc^2 \label{eq:1}
\end{equation}
This is a second test for math.
\begin{equation}
r = \sqrt{x^2 + y^2} \label{eq:2}
\end{equation}
In document B Eq.~~(\ref{B-eq:x})
\end{document}
docB.tex
\documentclass{article}
\usepackage{xr-hyper}
\usepackage{hyperref}
\externaldocument[A-]{docA}[docA.pdf]% <- full or relative path
\begin{document}
\setcounter{equation}{5}
As was shown in Eq.~(\ref{A-eq:1}) is it
... or in Eq.~(\ref{A-eq:2}) is ...
\begin{equation}
\mathrm{e}^{i\pi}-1=0 \label{eq:x}
\end{equation}
Here is a hyperlinked internal reference to \ref{eq:x}.
\end{document}
I want to produce a pdf with the first \ref
in document B turned into a "1" but not hyperlinked to an external document and the last \ref
in document B turned into a "6" and hyperlinked to eq:x
.
xr-hyper
package?\ref*{...}
for the external references?\setcounter
statement. (Before finding that other question to reference, I had actually worked out basically the same minimal working example myself. Then when I found that question, I switched to its version, but I guess I didn't try compiling it to compare).