[latex3-commits] [latex3/hyperref] newlabel: adapt xr-hyper, WIP (86ca076)
github at latex-project.org
github at latex-project.org
Sat May 13 17:06:45 CEST 2023
Repository : https://github.com/latex3/hyperref
On branch : newlabel
Link : https://github.com/latex3/hyperref/commit/86ca076ed5d66afd4ed69d7908d57a37afe7a338
>---------------------------------------------------------------
commit 86ca076ed5d66afd4ed69d7908d57a37afe7a338
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Sat May 13 17:06:45 2023 +0200
adapt xr-hyper, WIP
>---------------------------------------------------------------
86ca076ed5d66afd4ed69d7908d57a37afe7a338
testfiles/xr-newlabel-1.lvt | 37 +++++++++++++++++++++++++++++++++++++
xr-hyper.sty | 42 ++++++++++++++++++++++++++++++++++--------
2 files changed, 71 insertions(+), 8 deletions(-)
diff --git a/testfiles/xr-newlabel-1.lvt b/testfiles/xr-newlabel-1.lvt
new file mode 100644
index 0000000..1702c6f
--- /dev/null
+++ b/testfiles/xr-newlabel-1.lvt
@@ -0,0 +1,37 @@
+\documentclass{book}
+\begin{filecontents}[force]{test-aux1.aux}
+% aux-file with five arguments
+\newlabel{Ia}{{1.1}{1}{}{}{}}
+\newlabel{Ib}{{1.2}{1}{}{}{}}
+\newlabel{Icfail}{{1.3}{1}}%to check if test stopped
+\end{filecontents}
+\begin{filecontents}[force]{test-aux2.aux}
+% aux-file with two arguments
+\newlabel{IIa}{{1.1}{1}}
+\newlabel{IIb}{{1.2}{1}}
+\newlabel{IIbfail}{{1.2}{1}{}{}{}}%to check if test stopped
+\newlabel{IIc}{{1.3}{1}}
+\end{filecontents}
+
+\begin{filecontents}[force]{test-aux3.aux}
+% aux-file with five arguments and destinations
+\newlabel{IIIa}{{1.1}{1}{title}{section.title}{}}
+\end{filecontents}
+\usepackage{xr-hyper}
+%\usepackage{hyperref}
+\externaldocument{test-aux1}
+\externaldocument{test-aux2}
+%\externaldocument{test-aux3}
+\begin{document}
+
+\makeatletter
+\show\r at Ia
+\show\r at Ib
+\show\r at Icfail
+\show\r at IIa
+\show\r at IIb
+\show\r at IIbfail
+\show\r at IIc
+\show\r at IIIa
+
+\end{document}
\ No newline at end of file
diff --git a/xr-hyper.sty b/xr-hyper.sty
index b7871a4..3e71015 100644
--- a/xr-hyper.sty
+++ b/xr-hyper.sty
@@ -61,7 +61,7 @@
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{xr-hyper}
- [2023-04-22 v7.00x eXternal References (DPC)]
+ [2023-05-13 v7.00x eXternal References (DPC)]
\def\externaldocument{\@testopt\XR at cite{}}
\let\externalcitedocument\externaldocument
@@ -92,6 +92,35 @@
\long\def\@secondofthree#1#2#3{#2}
\long\def\@thirdofthree #1#2#3{#3}
+% 2023-05-13 we need to handle \newlabel's with two arguments differently
+% to \newlabel's with three argument. For this we count the values of the first
+% \newlabel of an aux-file.
+% By default we assume five arguments as that will be the case in future LaTeX
+\ExplSyntaxOn
+\def\XR at HYPcompargs{}
+\newcommand\XR at testnewlabel[1]{}
+\cs_new_protected:Npn\XR at testnewlabel@aux #1
+ {
+ \cs_set_eq:NN \XR at testnewlabel \use_none:n
+ \int_compare:nNnT{\tl_count:n{#1}}={2}
+ {
+ \def\XR at HYPcompargs{{}{}{}}
+ }
+ }
+\ExplSyntaxOff
+% we also have to ensure that hyperref doesn't remove the empty braces again
+\AddToHook{package/hyperref/after}
+ {
+ \def\XR@@dURL#1#2#3#4#5\\{%
+ {#1}{#2}%
+ \if!#4!%
+ {#3}{#4}{}% new perhaps this could use \XR at URL too?
+ \else
+ {#3}{#4}{\XR at URL}%
+ \fi
+ }%
+ }
+
\def\XR at explist{\expandafter\XR at next\XR at list\\}
\def\XR at loop#1{%
\openin\@inputcheck#1\relax
@@ -100,19 +129,14 @@
\expandafter\XR at aux
\else
\PackageInfo{xr}{IMPORTING LABELS FROM #1}%
+ \let\XR at testnewlabel\XR at testnewlabel@aux
\expandafter\XR at read\fi}
\def\XR at read{%
\read\@inputcheck to\XR at line
\expandafter\XR at test\XR at line...\XR@}
% 2019 update to match xr
-% 2020 don't extend r at -arguments if hyperref has been detected in the source
-% newlabel has already the right number of arguments
-\def\XR at HYPcompargs{{}{}{}}
\long\def\XR at test#1#2#3#4\XR@{%
\let\XR at tempa\@gobblethree
- \ifx#1\HyperFirstAtBeginDocument
- \def\XR at HYPcompargs{}%
- \fi
\ifx#1\newlabel
\let\XR at tempa\@firstofthree
\else\ifx#1\XR at bibcite
@@ -121,7 +145,9 @@
\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}\XR at HYPcompargs}}%
+ {\XR at testnewlabel{#3}%
+ \expandafter\protected at xdef\csname r@\XR at prefix#2\endcsname{\XR at addURL{#3}\XR at HYPcompargs}%
+ }%
{\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
More information about the latex3-commits
mailing list.