25

Sometimes I want to refer (using \ref) a \label from some other tex file. What is the right way to do it?

(It's, of course, possible to \include all files in one and then use \includeonly — but it breaks e.g. page and section numbering.)

lockstep
  • 250,273
Grigory M
  • 4,984
  • 4
  • 39
  • 37

1 Answers1

38

https://texfaq.org/FAQ-extref

Referring to labels in other documents

When producing a set of inter-related documents, you’ll often want to refer to labels in another document of the set; but LaTeX, of its own accord, doesn’t permit this.

So the package xr was written: if you say

\usepackage{xr}
\externaldocument{volume1}

will load all the references from volume1 into your present document.

(...)

David Carlisle
  • 757,742
Ulrike Fischer
  • 327,261
  • 3
    The package looks for the aux file, so it does not work in all settings and, more importantly, without a full document. (Which is fair, but noteworthy for unwary readers.) – Raphael Nov 07 '13 at 16:38
  • @Ulrike Fischer: Could you please explain how I an do the reverse at the same time? For instance, if I want to call a reference from the the 'present document' into the the 'volume1'? – rainman Jan 16 '22 at 04:16