3

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.

3

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}
  • What about zref and \zexternaldocument? – Igor Kotelnikov Dec 4 '15 at 3:06
  • @IgorKotelnikov With the change from the answer, all links in the references sections work for me as expected. – Heiko Oberdiek Dec 4 '15 at 5: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 6 '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 8 '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 9 '15 at 8:38

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.