%%% Save file as: XR.STY                      Source: FILESERV@SHSU.BITNET
%%% The following checksum includes all SHSU-generated topmatter.
%%% checksum = "20896 84 452 3043"
% xr.sty
% cross references between LaTeX documents.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% USAGE: the command
%         \externaldocument{DOCUMENT}
% should be placed in the preamble
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Author:
% Jean-Pierre Drucbert
% ONERA/CERT/GPI
% Office National d'\'Etudes et de Recherches A\'eroSpatiales
% Centre de'\'Etudes et de Recherches de Toulouse
% Groupe de Prestations Informatiques
% Complexe Scientifique de Rangueil
% 2, Avenue \'Edouard Belin
% BP 4025
% F-31055 TOULOUSE CEDEX
% FRANCE
%
% Phone +33-61-55-70-59
% Fax +33-61-55-71-72
% Telex 521 596 F
%
% Email: drucbert@onecert.fr
%
% Please send me any (constructive) suggestions and comments.
%
%%%%%%%%%%%
% HISTORY
%
% VERSION 2 (10Jun93) David Carlisle corrected a bug about \makeatletter by
% adding a grouping level. This eliminates the need of preserving some
% definitions.  He has also cleanead up the code by using \@gobble.
%%%%%%%%%%%
\def\@i@input#1{\openin\@inputcheck #1 \ifeof\@inputcheck \typeout
  {^^JNo file #1.^^JLABELS NOT IMPORTED.^^J}\else\closein\@inputcheck
 \relax\@@input #1 \fi}
\def\externaldocument#1{%
\typeout{^^JIMPORTATION OF LABELS FROM #1^^J}%
{\makeatletter
\def\@writefile##1##2{}%
\let\bibstyle\@gobble
\let\citation\@gobble
\let\bibdata\@gobble
\let\bibcite\@writefile
\let\setcounter\@writefile
\let\gdef\@writefile
\@i@input{#1.aux}%
\typeout{^^JEND OF IMPORTATION OF LABELS FROM #1^^J}%
}}
\endinput
%
%
% Some months ago (at the end of 1992), I had written an style option, named
% ``xr.sty'' (for eXternal References), which reads the .aux file of the
% other document, ignoring all unuseful commands. The user needs to invoke
% the \externaldocument{DOCUMENT} command to ``import'' the labels of that
% document. To use these labels (i.e. to make reference to labels in the
% ``external'' document, kind of cross-referencing), the user has the commands
% \ref and \pageref as usual. Of course, you cannot use identical labels in
% the two documents (the local one and the one the labels of which are
% imported), but LaTeX signals multiple definitions of labels.  Of course,
% with a rational method for giving names to labels, we can reduce the
% chances of having the same label twice.
%
% The local redefinition of \gdef is vital if you use the
% longtable.sty option from David Carlisle (and I do a great usage of it),
% because this option puts \gdef's in the .aux file.
%
% The .aux file of the ``external'' document is read only once.
%
% So I send you the xr.sty file below, if it can be useful (please preserve
% the author notice) to anybody, so you can UPDATE it in the SHSU LaTeX style
% archive.  A lot of thanks for that.
%
% At least, I must apologize about my poor english, but I'm better in french.
%
%				     Sincerely yours,
%
%				     Jean-Pierre Drucbert
%				     drucbert@onecert.fr

