Article 13748 of comp.text.tex:
Newsgroups: comp.text.tex
Path: sifon!thunder.mcrcim.mcgill.edu!enterpoop.mit.edu!gatech!howland.reston.ans.net!usc!elroy.jpl.nasa.gov!news.claremont.edu!hmcvax.claremont.edu!dhosek
From: dhosek@hmcvax.claremont.edu
Subject: Re: Cross References to other documents?
Message-ID: <1993May28.210340.1@hmcvax.claremont.edu>
Lines: 100
Sender: news@news.claremont.edu (The News System)
Organization: Harvey Mudd College
References: <chrisf.738392064@suite.sw.oz.au>
Date: Sat, 29 May 1993 05:03:40 GMT

In article <chrisf.738392064@suite.sw.oz.au>, chrisf@suite.sw.oz.au (Christopher Fraser) writes:
> Are there any existing packages or tools for maintaining references between
> two separate (LaTeX) documents? What I really want is to use a reference tag
> which refers to a section in another document. If there's isn't an existing
> packages, how difficult would it be to implement? I assume I'd be able to use
> most of the existing cross reference code, just have it read out of a
> different aux file.

The following ought to do the trick:
%% This is crossdoc.sty as of 28-May-1993
%% Copyright 1993 Don Hosek
%%
%% A style option to provide cross-document cross-referencing.
%%
%% Full documentation forthcoming.
%%
%% To use, supply crossdoc in the document style option list.
%% Two new commands are added: \Xref and \Xpageref. Each takes
%% two arguments: the name of the file from which the cross-refernce
%% comes and the reference key. Thus, to refer to the label 'foo'
%% in the document bar, one could say \Xref{bar}{foo} for the
%% structure number or \Xpageref{bar}{foo} for the page number.
%%
%% See end of file for commonly asked questions.

\def\Xref#1#2{%
  \@ifundefined{R!#1}{%
    \@readaux{#1}%
  }{}%
  \@ifundefined{R@#1-#2}{%
    {\reset@font\bf ??}%
    \@warning{Reference `#2' from file `#1' on page \thepage\space
        undefined}}%
      {\edef\@tempa{\@nameuse{R@#1-#2}}%
       \expandafter\@car\@tempa \@nil\null}%
}

\def\Xref#1#2{%
  \@ifundefined{R!#1}{%
    \@readaux{#1}%
  }{}%
  \@ifundefined{R@#1-#2}{%
    {\reset@font\bf ??}%
    \@warning{Reference `#2' from file `#1' on page \thepage\space
        undefined}}%
      {\edef\@tempa{\@nameuse{R@#1-#2}}%
       \expandafter\@cdr\@tempa \@nil\null}%
}

\def\@readaux#1{%
  \if@filesw
    \begingroup
    \@auxdefs{#1}%
    \@input{#1.aux}%
    \endgroup
  \fi
  \@namedef{R!#1}{}%
}

\def\@auxdefs#1{%
  \makeatletter
  \def\newlabel##1##2{%
    \GLOBAL\@namedef{R@#1-##1}{##2}%
  }%
  \def\global\@namedef##1##2{}%
  \let\bibcite\@gobbletwo
  \let\@writefile\@gobbletwo
%  \let\citation\@gobble
%  \let\bibdata\@gobble
%  \let\bibstyle\@gobble
}

\let\GLOBAL\global
\endinput

* Commonly-asked questions:
1. LaTeX can't find the other document's aux file even though
   it's in my TeX input path. Why not?

The existence of aux files is tested with the TeX \openin
command. On some TeX versions, \openin will follow the rules
used by \input for searching for files, on others it will not.
Both, according to Knuth, are acceptable. The only solution if
this happens to you is to copy the .aux files to your directory.

2. I have two files which cross-reference each other. How can I
   be sure that the cross-references are up-to-date?

The best way, since a changed reference in one document might
affect references in the other, is to alternate LaTeX runs until 
both have run twice without indicating that labels have changed.
Note that the 'labels may have changed warning' will not occur on
a LaTeX run that it will necessarily affect. Running the two
documents in parallel is _not_ encouraged.

Don Hosek                  
dhosek@ymir.claremont.edu  
Quixote Digital Typography 
909-621-1291




