1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
|
%% xr-hyper package (beta release)
%% Copyright (C) 1993-2022 David Carlisle
%% This is a modified version of the xr package from the Standard LaTeX
%% tools distribution. It has some internal changes to cooperate with
%% the hyperref package, and one new user level argument, also mainly of
%% use for hyperref.
%% If no problems are reported the version in the tools distribution
%% will be updated to match this at the next LaTeX release.
%% \externaldocument[prefix][nocite]{document}[URL]
%% The `document' referred to by the main argument is the file
%% document.aux
%% which must be somewhere on TeX's input path.
%% Some packages (eg hyperref) really need to know the location of the
%% final document rather than the aux file. By default this is assumed
%% to be `document.dvi'. A package may redefine the command \XR@ext to
%% change this default extension (eg some of the hyperref backends
%% define this to be `document.pdf'). However sometimes the final
%% document may be in a position unrelated to the aux file, or the
%% browser may not be able to find files at an arbitrary point in
%% TeX's input path, so the new final optional argument allows a full
%% URL to the final document to be specified.
%%
%% \externaldocument{file}[http://here.xxx.edu/this/path/to/file.dvi]
%%
%% Unless a package redefines \XR@addfile, the optional URL argument
%% will be ignored.
%%
%% Version beta2 also added another improvement unrelated
%% to the hyperref support. Olivier Michel pointed out that
%% if the aux file was not on texinputs you could not always go
%% \externaldocument{/some/path/to/file}
%% specifically that worked if file.aux was a `simple' document with
%% one aux file, but if \include had been used, the `sub' aux files
%% would not be found by xr in the remote directory.
%% This version calls \filename@parse to get the directory name of the
%% remote directory, which is then explicitly prepended to the names of
%% any included aux files.
%%
%%
%% Version 6.1 incorporates linking to citations in external documents
%% (originally from xcite package and now included in xr.
%%
%% Many packages have variant citation commands (natbib,
%% biblatex,....) and the external document may or may not have used
%% hyperref. Because of these differences the citation linking may not
%% always work, it can be disabled by specifying [nocite] after the
%% prefix:
%%
%% \externaldocument[][nocite]{somefile}
%%
%% In the case of \ref, if the external document has not used
%% hyperref, this package will work like xr and produce the correct
%% text, but can not produce a well formed link as the target document
%% is not set up. In this case you may prefer to use \ref* rather than
%% \ref to avoid generating a hyperlink.
%%
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{xr-hyper}
[2022-11-13 v7.00u eXternal References (DPC)]
\def\externaldocument{\@testopt\XR@cite{}}
\let\externalcitedocument\externaldocument
\def\XR@cite[#1]{\@testopt{\XR@[#1]}{}}
\def\XR@[#1][#2]#3{\@testopt{\XR@@{#1}{#2}{#3}}{#3.\XR@ext}}
\def\XR@@#1#2#3[#4]{{%
\makeatletter
\def\XR@prefix{#1}%
\def\XR@nocite{#2}%
\ifx\XR@nocite\XR@@nocite
\let\XR@bibcite\vadjust
\else
\let\XR@bibcite\bibcite
\fi
\def\XR@URL{#4}%
\filename@parse{#3}%
\XR@next#3.aux\relax\\}}
\def\XR@@nocite{nocite}
\def\XR@next#1\relax#2\\{%
\edef\XR@list{#2}%
\XR@loop{#1}}
\def\XR@aux{%
\ifx\XR@list\@empty\else\expandafter\XR@explist\fi}
\long\def\@gobblethree #1#2#3{}
\long\def\@firstofthree #1#2#3{#1}
\long\def\@secondofthree#1#2#3{#2}
\long\def\@thirdofthree #1#2#3{#3}
\def\XR@explist{\expandafter\XR@next\XR@list\\}
\def\XR@loop#1{%
\openin\@inputcheck#1\relax
\ifeof\@inputcheck
\PackageWarning{xr}{^^JNo file #1^^JLABELS NOT IMPORTED.^^J}%
\expandafter\XR@aux
\else
\PackageInfo{xr}{IMPORTING LABELS FROM #1}%
\expandafter\XR@read\fi}
\def\XR@read{%
\read\@inputcheck to\XR@line
\expandafter\XR@test\XR@line...\XR@}
% 2019 update to match xr
% 2020 don't extend r@-arguments if hyperref has been detected in the source
% newlabel has already the right number of arguments
\def\XR@HYPcompargs{{}{}{}}
\long\def\XR@test#1#2#3#4\XR@{%
\let\XR@tempa\@gobblethree
\ifx#1\HyperFirstAtBeginDocument
\def\XR@HYPcompargs{}%
\fi
\ifx#1\newlabel
\let\XR@tempa\@firstofthree
\else\ifx#1\XR@bibcite
\let\XR@tempa\@secondofthree
\else\ifx#1\@input
\let\XR@tempa\@thirdofthree
\fi\fi\fi
\XR@tempa
{\expandafter\protected@xdef\csname r@\XR@prefix#2\endcsname{\XR@addURL{#3}\XR@HYPcompargs}}%
{\expandafter\bibcite\expandafter{\XR@prefix#2}{#3}}%
{\edef\XR@list{\XR@list\filename@area#2\relax}}%
\ifeof\@inputcheck\expandafter\XR@aux
\else\expandafter\XR@read\fi}
\providecommand*{\XR@addURL}[1]{#1}
% The above definition doesn't actually use the URL, hyperref 6 could
% make a definition like so to put the URL in the fifth field of its
% ref structure.
\@ifpackageloaded{hyperref}{%
\PackageWarningNoLine{xr-hyper}{Load package `hyperref' after `xr-hyper'}%
}{}
%\def\XR@addURL#1{\XR@@dURL#1{}{}{}{}\\}
%\def\XR@@dURL#1#2#3#4#5\\{%
% {#1}{#2}%
% \if!#4!%
% \else
% {#3}{#4}{\XR@URL}%
% \fi
%}
\providecommand\XR@ext{dvi}
\endinput
%%
%% End of file `xr-hyper.sty'.
%% History
%%
%% 1997/10/06 v6.00 beta2
%%
%% 1999/09/01 v6.00 beta3
%% Definitions of \XR@addURL corrected (Heiko Oberdiek).
%%
%% 2000/03/22 v6.00 beta4
%% \xdef changed to \protected@xdef.
%%
%% 2019/10/03 v6.1
%% Incorporate updates to xr (including citation support)
%%
%% 2020-05-14 v7.00e
%% add additional braces to \r@ only if hyperref is not detected in the aux
%% of the source document (https://github.com/latex3/hyperref/issues/118)
%%
|