I am having two documents, call them A and B. I want to make several cross-references from file A to file B and by clicking on the hyperlink, I want to open file B at the respective page.
In my preamble of file A, I created a short command to make the hyperlink and the reference (separately):
\usepackage{xr-hyper}
\usepackage{hyperref}
\externaldocument[B-]{B}
\newcommand{\test}[2][Seite]{\href{file:B\#page.#1}{also see in File B S.\pageref{#2}}}
As an example, in the document, I have...
\begin{document}
\test[11]{B-sec:aSectionInFileB}
\end{document}
... which works properly. When I click on the link, file B opens at page 11 as specified in the brackets [].
But the thing is, I don't want to specify the page number manually for every reference, but rather "take it from the \pageref command" so that any changes made to document B do not require me to change the page numbers manually. I already tried out to put \pageref{} into brackets [], but apparently this won't work. I found a solution here, but I think it is even less convenient than doing it manually.
Is there any simple automatic way of doing this?
\pagerefisn't expandable, that's the main cause, in my point of view – Dec 21 '15 at 12:51