Say I have a document of type






Where Chap1 \ref's labels of Chap2 and vice versa. Using \includeonly, I want to compile Chap1 to Chap1.pdf and Chap2 to Chap2.pdf.

Is there a way to inform hyperref about this, so a reference Chap2.pdf will automatically be hyperlinked so that it opens the referenced location in Chap1.pdf ?

  • The instructions for the xr-hyper package are the same as for the xr package. I'll post a quick answer to explain its functioning.
    – Mico
    Apr 14, 2014 at 23:28

1 Answer 1


If I understand your setup correctly, you have two separate standalone documents, say, doca.tex and docb.tex, and you'd like to cross-reference an item (e.g., a chapter) from Document A in Document B.

One way to achieve this objective is to use the xr-hyper package, which is part of the hyperref bundle. The xr-hyper pacakge works exactly like the xr package. E.g., suppose doca.tex consists of the following code:

%% doca.tex
\chapter{Beginning of Doc A} \label{doca:chap:1}
In the beginning, \dots

Note that both the hyperref and xr-hyper packages are loaded. Compile it twice and make sure not to delete the file doca.aux as it contains important cross-referencing information.

Suppose further that docb.tex contains the following code:

\chapter{End of Doc B} 
As we argued in \autoref{doca:chap:1} of Document A, \dots

The crucial extra instruction is \externaldocument{doca}: it tells LaTeX to search in doca.aux for labels to cross-references. The directive \autoref{doca:chap:1} will then successfully create a cross-reference to "chapter 1" of Document A.

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .