4

I am working on a multi-volume project where different volumes contain hyperlinks to other volumes. I use a technique described on this web-site in a number of posts, see e.g., Cross-referencing between different files and Smart cross-references between 2 volumes using Zref package .

I remember that it worked fine in the past but recently I noted that a hyperlink to another file opens it on a last opened page rather than on a desired destination page. Here are not so small working examples which I made to test this problem. I compile these files to pdf with pdflatex or xetex.

File A.tex:

\documentclass{book}
\usepackage[user,xr]{zref}
%\usepackage{zref-xr}
\usepackage{xr-hyper}
\externaldocument[B-]{B}
\zexternaldocument[B-]{B}

\usepackage{hyperref}
\begin{document}

empty page

\newpage
\section{Dittmer}\label{Dittmer}\zlabel{Dittmer}

Dittmer

\newpage
\section{Langmuir}\label{Langmuir}\zlabel{Langmuir}

Langmuir

\newpage
\section{References}

\hyperref[Dittmer]{hyperref to Dittmer} on page \pageref{Dittmer}, \zpageref{Dittmer}

\hyperref[Langmuir]{hyperref to Langmuir} on page \pageref{Langmuir}, \zpageref{Langmuir}

\hyperref[B-Shafranov]{hyperref to B-Shafranov} on page \pageref{B-Shafranov}, \zpageref{B-Shafranov}

\hyperref[B-Stupakov]{hyperref to B-Stupakov} on page \pageref{B-Stupakov}, \zpageref{B-Stupakov}

\end{document} 

File B.tex:

%\providecommand{\reverseit}[1]{#1}
\documentclass{book}
\usepackage[user,xr]{zref}
%\usepackage{zref-xr}
\usepackage{xr-hyper}
\usepackage{hyperref}
\externaldocument[A-]{A}
\zexternaldocument[A-]{A}
%\externaldocument[V4-]{PlasmaBook4}

\begin{document}

empty page 

\newpage
\section{Shafranov}\label{Shafranov}\zlabel{Shafranov}

Shafranov

\newpage
\section{Stupakov}\label{Stupakov}\zlabel{Stupakov}

Stupakov

\newpage
\section{References}

\hyperref[A-Dittmer]{hyperref to A-Dittmer} on page \pageref{A-Dittmer}, \zpageref{A-Dittmer}

\hyperref[A-Langmuir]{hyperref to A-Langmuir} on page \pageref{A-Langmuir}, \zpageref{A-Langmuir}

\hyperref[Shafranov]{hyperref to Shafranov} on page \pageref{Shafranov}, \zpageref{Shafranov}

\hyperref[Stupakov]{hyperref to Stupakov} on page \pageref{Stupakov}, \zpageref{Stupakov}

\end{document}

I have no idea what became broken in this technique. Any advice would be most appreciated. \refpage, \zrefpage print correct page numbers in different files but hyperlinks by \refpage and \hyperref open different file of a wrong page. I tried sumatrapdf and adobe accrobat to browse pdf files.

UPDATE: Finally, I found that \hyperref does not operate as desired on external document if PDFs were compiled under MiKTeX (either by xelatex or pdflatex). When compiled by TeX Live everything works as intended! So this seems to be bug in MiKTeX.

UPDATE 2017-02-13: Today I've checked that the above described problem is absent with the most recent versions of MikTex and TeXlive.

1 Answers1

5

A.tex: Package xr-hyper needs to be loaded before hyperref but \externaldocument should be given after loading hyperref:

\usepackage{xr-hyper}
\usepackage{hyperref}
\externaldocument[B-]{B}
Heiko Oberdiek
  • 271,626
  • What about zref and \zexternaldocument? – Igor Kotelnikov Dec 04 '15 at 03:06
  • @IgorKotelnikov With the change from the answer, all links in the references sections work for me as expected. – Heiko Oberdiek Dec 04 '15 at 05:35
  • but it doesn't work for me! I sent you files compiled on my computer. Is it work as desired on your computer? – Igor Kotelnikov Dec 06 '15 at 13:20
  • I found that \hyperref does not operate as desired on external document if PDF were compiled under MiKTeX (either by xelatex or pdflatex). When compiled by TeX Live everything works as intended! – Igor Kotelnikov Dec 08 '15 at 14:48
  • @IgorKotelnikov: I can not confirm your claim. If I move the (z)externaldocument commands behind hyperref and compile often enough with miktex the links works fine. I tested in sumatra 3.0 and acrobat reader DC. – Ulrike Fischer Dec 09 '15 at 08:38
  • @UlrikeFischer: Iv'e checked this problem twice on two my computers. – Igor Kotelnikov Dec 09 '15 at 10:08
  • @IgorKotelnikov: I don't doubt that you have a problem. But I can't make a bug report if I can't reproduce it or understand the cause. Make zip-folder with the a + b.tex and all the compilation files so that one compare the files. Which pdf-viewer are you using? Which OS? – Ulrike Fischer Dec 09 '15 at 10:19