[latex3-commits] [git/LaTeX3-latex3-hyperref] master: update xr-hyper to match xr (incorporating xcite and other fixes) (0e4401d)

David Carlisle d.p.carlisle at gmail.com
Thu Oct 3 22:39:50 CEST 2019


Repository : https://github.com/latex3/hyperref
On branch  : master
Link       : https://github.com/latex3/hyperref/commit/0e4401d4844807f52a00a974b4afd2c656c86558

>---------------------------------------------------------------

commit 0e4401d4844807f52a00a974b4afd2c656c86558
Author: David Carlisle <d.p.carlisle at gmail.com>
Date:   Thu Oct 3 21:39:50 2019 +0100

    update xr-hyper to match xr (incorporating xcite and other fixes)


>---------------------------------------------------------------

0e4401d4844807f52a00a974b4afd2c656c86558
 xr-hyper.sty | 68 ++++++++++++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 55 insertions(+), 13 deletions(-)

diff --git a/xr-hyper.sty b/xr-hyper.sty
index 0f36f39..713f4c0 100644
--- a/xr-hyper.sty
+++ b/xr-hyper.sty
@@ -9,7 +9,7 @@
 %% If no problems are reported the version in the tools distribution
 %% will be updated to match this at the next LaTeX release.
 
-%% \externaldocument[prefix]{document}[URL]
+%% \externaldocument[prefix][nocite]{document}[URL]
 
 %% The `document' referred to by the main argument is the file
 %% document.aux
@@ -40,6 +40,25 @@
 %% 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.
+%%
+%%
 %% History
 %%
 %% 1997/10/06 v6.00beta2
@@ -50,28 +69,44 @@
 %% 2000/03/22 v6.00beta4
 %%   \xdef changed to \protected at xdef.
 %%
+%% 2019/10/03 v6.1
+%%   Incorporate updates to xr (including citation support)
+%%
 \NeedsTeXFormat{LaTeX2e}
 \ProvidesPackage{xr-hyper}
-         [2000/03/22 v6.00beta4 eXternal References (DPC)]
+         [2019/10/03 v6.1 eXternal References (DPC)]
 
-\def\externaldocument{\@testopt\XR@{}}
-\def\XR@[#1]#2{\@testopt{\XR@@{#1}{#2}}{#2.\XR at ext}}
+\def\externaldocument{\@testopt\XR at cite{}}
+\let\externalcitedocument\externaldocument
+\def\XR at cite[#1]{\@testopt{\XR@[#1]}{}}
+\def\XR@[#1][#2]#3{\@testopt{\XR@@{#1}{#2}{#3}}{#3.\XR at ext}}
 
-\def\XR@@#1#2[#3]{{%
+\def\XR@@#1#2#3[#4]{{%
   \makeatletter
   \def\XR at prefix{#1}%
-  \def\XR at URL{#3}%
-  \filename at parse{#2}%
-  \XR at next#2.aux\relax\\}}
+   \def\XR at nocite{#2}%
+   \ifx\XR at nocite\XR@@nocite
+     \let\XR at bibcite\vadjust
+   \else
+     \let\XR at bibcite\bibcite
+   \fi
+  \def\XR at URL{#4}%
+  \filename at parse{#3}%
+  \XR at next#3.aux\relax\\}}
+\def\XR@@nocite{nocite}
 \def\XR at next#1\relax#2\\{%
   \edef\XR at list{#2}%
   \XR at loop{#1}}
 \def\XR at aux{%
   \ifx\XR at list\@empty\else\expandafter\XR at 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 at explist{\expandafter\XR at next\XR at list\\}
 \def\XR at loop#1{%
-\def\f{#1}%\show\f
 \openin\@inputcheck#1\relax
   \ifeof\@inputcheck
     \PackageWarning{xr}{^^JNo file #1^^JLABELS NOT IMPORTED.^^J}%
@@ -82,13 +117,20 @@
 \def\XR at read{%
   \read\@inputcheck to\XR at line
   \expandafter\XR at test\XR at line...\XR@}
+% 2019 update to match xr
 \long\def\XR at test#1#2#3#4\XR@{%
+  \let\XR at tempa\@gobblethree
   \ifx#1\newlabel
-     \expandafter\protected at xdef\csname r@\XR at prefix#2\endcsname
-       {\XR at addURL{#3}}%
+    \let\XR at tempa\@firstofthree
+  \else\ifx#1\XR at bibcite
+    \let\XR at tempa\@secondofthree
   \else\ifx#1\@input
-     \edef\XR at list{\XR at list\filename at area#2\relax}%
-  \fi\fi
+     \let\XR at tempa\@thirdofthree
+  \fi\fi\fi
+   \XR at tempa
+    {\expandafter\protected at xdef\csname r@\XR at prefix#2\endcsname{\XR at addURL{#3}{}{}{}}}%
+    {\expandafter\bibcite\expandafter{\XR at prefix#2}{#3}}%
+    {\edef\XR at list{\XR at list\filename at area#2\relax}}%
   \ifeof\@inputcheck\expandafter\XR at aux
   \else\expandafter\XR at read\fi}
 





More information about the latex3-commits mailing list