[latex3-commits] [latex3/latex2e] firstaid/cleveref: firstaid for cleveref (five arguments in newlabel if xr-hyper ist used) (73e4922e)
github at latex-project.org
github at latex-project.org
Fri Mar 22 00:38:55 CET 2024
Repository : https://github.com/latex3/latex2e
On branch : firstaid/cleveref
Link : https://github.com/latex3/latex2e/commit/73e4922e310db16b02c254e1460ba1f4710c21cc
>---------------------------------------------------------------
commit 73e4922e310db16b02c254e1460ba1f4710c21cc
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Fri Mar 22 00:38:55 2024 +0100
firstaid for cleveref (five arguments in newlabel if xr-hyper ist used)
>---------------------------------------------------------------
73e4922e310db16b02c254e1460ba1f4710c21cc
required/firstaid/changes.txt | 5 ++
.../latex2e-first-aid-for-external-files.dtx | 67 +++++++++++++++++++++-
required/firstaid/testfiles/firstaid-cleveref.lvt | 16 ++++++
required/firstaid/testfiles/firstaid-cleveref.tlg | 61 ++++++++++++++++++++
.../firstaid/testfiles/firstaid-cleveref.xetex.tlg | 65 +++++++++++++++++++++
5 files changed, 212 insertions(+), 2 deletions(-)
diff --git a/required/firstaid/changes.txt b/required/firstaid/changes.txt
index 9d14a66b..7ddcfbce 100644
--- a/required/firstaid/changes.txt
+++ b/required/firstaid/changes.txt
@@ -1,3 +1,8 @@
+2024-03-22 Ulrike Fischer <Ulrike.Fischer at latex-project.org>
+
+ * latex2e-first-aid-for-external-files.dtx: add firstaid for cleveref
+ to support five data in \newlabel.
+
2024-03-18 Frank Mittelbach <Frank.Mittelbach at latex-project.org>
* latex2e-first-aid-for-external-files.dtx:
diff --git a/required/firstaid/latex2e-first-aid-for-external-files.dtx b/required/firstaid/latex2e-first-aid-for-external-files.dtx
index a0cb733f..423e4fac 100644
--- a/required/firstaid/latex2e-first-aid-for-external-files.dtx
+++ b/required/firstaid/latex2e-first-aid-for-external-files.dtx
@@ -111,8 +111,8 @@
% \end{macrocode}
%
% \begin{macrocode}
-\def\LaTeXFirstAidDate{2024/03/18}
-\def\LaTeXFirstAidVersion{v1.1d}
+\def\LaTeXFirstAidDate{2024/03/20}
+\def\LaTeXFirstAidVersion{v1.1e}
% \end{macrocode}
%
% \begin{macrocode}
@@ -655,6 +655,69 @@
}
% \end{macrocode}
%
+% \subsection{The \pkg{cleveref} package first aid}
+%
+% The \pkg{cleveref} package expects only two data containers
+% for its internal \cs{newlabel} command. This fails if
+% \pkg{xr-hyper} is used which expands every \cs{newlabel} to
+% five data container and puts the file name into the last one.
+% \begin{macrocode}
+\AddToHook{package/cleveref/after}[firstaid]{%
+ \FirstAidNeededT{cleveref}{sty}{2018/03/27 v0.21.4 Intelligent cross-referencing}
+ {%
+% \end{macrocode}
+% This are the two commands which retrieve the data from the label info.
+% We change it to expand five arguments.
+% \begin{macrocode}
+ \def\cref at getref#1#2{%
+ \expandafter\let\expandafter#2\csname r@#1 at cref\endcsname%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter#2%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@firstoffive#2}}% <-------- five
+ \def\cpageref at getref#1#2{%
+ \expandafter\let\expandafter#2\csname r@#1 at cref\endcsname%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter#2%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@secondoffive#2}}% <----------- five
+% \end{macrocode}
+% We also need to redefine the internal label commands of cleveref.
+% This must be done after cleveref, so we use an unique label.
+% \begin{macrocode}
+ \AddToHook{begindocument}[firstaid/cleveref]{%
+ \def\label at noarg#1{%
+ \cref at old@label{#1}%
+ \@bsphack%
+ \edef\@tempa{{page}{\the\c at page}}%
+ \setcounter{page}{1}%
+ \edef\@tempb{\thepage}%
+ \expandafter\setcounter\@tempa%
+ \cref at constructprefix{page}{\cref at result}%
+ \protected at write\@auxout{}%
+ {\string\newlabel{#1 at cref}{{\cref at currentlabel}%
+ {[\@tempb][\arabic{page}][\cref at result]\thepage}{}{}{}}}% <----- five
+ \@esphack}%
+ \def\label at optarg[#1]#2{%
+ \cref at old@label{#2}%
+ \@bsphack%
+ \edef\@tempa{{page}{\the\c at page}}%
+ \setcounter{page}{1}%
+ \edef\@tempb{\thepage}%
+ \expandafter\setcounter\@tempa%
+ \cref at constructprefix{page}{\cref at result}%
+ \protected at edef\cref at currentlabel{%
+ \expandafter\cref at override@label at type%
+ \cref at currentlabel\@nil{#1}}%
+ \protected at write\@auxout{}%
+ {\string\newlabel{#2 at cref}{{\cref at currentlabel}%
+ {[\@tempb][\arabic{page}][\cref at result]\thepage}{}{}{}}}% <------- five
+ \@esphack}%
+ }
+ }%
+}
+% \end{macrocode}
+%
% \begin{macrocode}
%</kernel>
% \end{macrocode}
diff --git a/required/firstaid/testfiles/firstaid-cleveref.lvt b/required/firstaid/testfiles/firstaid-cleveref.lvt
new file mode 100644
index 00000000..bb6e353a
--- /dev/null
+++ b/required/firstaid/testfiles/firstaid-cleveref.lvt
@@ -0,0 +1,16 @@
+\input{regression-test}
+\begin{filecontents}{fileone.aux}
+\newlabel{sec:one}{{1}{1}{One}{section.1}{}}
+\newlabel{sec:one at cref}{{[section][1][]1}{[1][1][]1}}
+\end{filecontents}
+\documentclass{article}
+
+\usepackage{xr-hyper}
+\externaldocument{fileone}
+\usepackage{hyperref}
+\usepackage{cleveref}
+
+\begin{document}
+\START \showoutput
+\cref{sec:one}
+\end{document}
diff --git a/required/firstaid/testfiles/firstaid-cleveref.tlg b/required/firstaid/testfiles/firstaid-cleveref.tlg
new file mode 100644
index 00000000..227fbfc9
--- /dev/null
+++ b/required/firstaid/testfiles/firstaid-cleveref.tlg
@@ -0,0 +1,61 @@
+This is a generated file for the l3build validation system.
+Don't change this file in any respect.
+Completed box being shipped out [1]
+\vbox(633.0+0.0)x407.0
+.\hbox(0.0+0.0)x0.0
+.\vbox(0.0+0.0)x0.0, glue set - 14.99626fil
+..\kern 0.0
+..\kern 16.0
+..\kern -1.00374
+..\hbox(0.0+0.0)x0.0, glue set - 60.99626fil
+...\kern 0.0
+...\kern 62.0
+...\kern -1.00374
+...\pdfdest name{page.1} xyz
+...\penalty 10000
+...\glue 0.0 plus 1.0fil minus 1.0fil
+..\glue 0.0 plus 1.0fil minus 1.0fil
+.\glue(\lineskip) 0.0
+.\vbox(633.0+0.0)x407.0
+..\glue 16.0
+..\vbox(617.0+0.0)x345.0, shifted 62.0
+...\vbox(12.0+0.0)x345.0, glue set 12.0fil
+....\glue 0.0 plus 1.0fil
+....\hbox(0.0+0.0)x345.0
+.....\hbox(0.0+0.0)x345.0
+...\glue 25.0
+...\glue(\lineskip) 0.0
+...\vbox(550.0+0.0)x345.0, glue set 539.94232fil
+....\write-{}
+....\pdfdest name{Doc-Start} xyz
+....\glue(\topskip) 3.32141
+....\hbox(6.67859+0.0)x345.0, glue set 291.61105fil
+.....\hbox(0.0+0.0)x15.0
+.....\OT1/cmr/m/n/10 s
+.....\OT1/cmr/m/n/10 e
+.....\OT1/cmr/m/n/10 c
+.....\OT1/cmr/m/n/10 t
+.....\OT1/cmr/m/n/10 i
+.....\OT1/cmr/m/n/10 o
+.....\OT1/cmr/m/n/10 n
+.....\penalty 10000
+.....\glue 3.33333 plus 1.66666 minus 1.11111
+.....\pdfstartlink(*+*)x* attr{/Border[0 0 1]/H/I/C[0 .5 .5]} action user{/Subtype/Link/A<</F(fileone.pdf)/S/GoToR/D(section.1)>>}
+.....\OT1/cmr/m/n/10 1
+.....\pdfendlink
+.....\penalty 10000
+.....\glue(\parfillskip) 0.0 plus 1.0fil
+.....\glue(\rightskip) 0.0
+....\glue 0.0 plus 1.0fil
+....\glue 0.0
+....\glue 0.0 plus 0.0001fil
+...\glue(\baselineskip) 23.55556
+...\hbox(6.44444+0.0)x345.0
+....\hbox(6.44444+0.0)x345.0, glue set 170.0fil
+.....\glue 0.0 plus 1.0fil
+.....\OT1/cmr/m/n/10 1
+.....\glue 0.0 plus 1.0fil
+.\kern 0.0
+(firstaid-cleveref.aux)
+Package rerunfilecheck Info: File `firstaid-cleveref.out' has not changed.
+(rerunfilecheck) Checksum: D41D8CD98F00B204E9800998ECF8427E;0.
diff --git a/required/firstaid/testfiles/firstaid-cleveref.xetex.tlg b/required/firstaid/testfiles/firstaid-cleveref.xetex.tlg
new file mode 100644
index 00000000..d5a50873
--- /dev/null
+++ b/required/firstaid/testfiles/firstaid-cleveref.xetex.tlg
@@ -0,0 +1,65 @@
+This is a generated file for the l3build validation system.
+Don't change this file in any respect.
+Completed box being shipped out [1]
+\vbox(633.0+0.0)x407.0
+.\hbox(0.0+0.0)x0.0
+..\special{pdf:docinfo<</Title()/Subject()/Creator(LaTeX with hyperref)/Author()/Keywords()>>}
+.\vbox(0.0+0.0)x0.0, glue set - 14.99626fil
+..\kern 0.0
+..\kern 16.0
+..\kern -1.00374
+..\hbox(0.0+0.0)x0.0, glue set - 60.99626fil
+...\kern 0.0
+...\kern 62.0
+...\kern -1.00374
+...\special{pdf:dest (page.1) [@thispage /XYZ @xpos @ypos null]}
+...\penalty 10000
+...\glue 0.0 plus 1.0fil minus 1.0fil
+..\glue 0.0 plus 1.0fil minus 1.0fil
+.\glue(\lineskip) 0.0
+.\vbox(633.0+0.0)x407.0
+..\glue 16.0
+..\vbox(617.0+0.0)x345.0, shifted 62.0
+...\vbox(12.0+0.0)x345.0, glue set 12.0fil
+....\glue 0.0 plus 1.0fil
+....\hbox(0.0+0.0)x345.0
+.....\hbox(0.0+0.0)x345.0
+...\glue 25.0
+...\glue(\lineskip) 0.0
+...\vbox(550.0+0.0)x345.0, glue set 539.94232fil
+....\write-{}
+....\special{pdf:majorversion 1}
+....\special{pdf:minorversion 5}
+....\special{pdf:docview<</OpenAction[@page1/Fit]/PageMode/UseOutlines>>}
+....\special{pdf:dest (Doc-Start) [@thispage /XYZ @xpos @ypos null]}
+....\glue(\topskip) 3.32141
+....\hbox(6.67859+0.0)x345.0, glue set 291.61105fil
+.....\hbox(0.0+0.0)x15.0
+.....\OT1/cmr/m/n/10 s
+.....\OT1/cmr/m/n/10 e
+.....\OT1/cmr/m/n/10 c
+.....\OT1/cmr/m/n/10 t
+.....\OT1/cmr/m/n/10 i
+.....\OT1/cmr/m/n/10 o
+.....\OT1/cmr/m/n/10 n
+.....\penalty 10000
+.....\glue 3.33333 plus 1.66666 minus 1.11111
+.....\special{pdf:bann<</Type/Annot/Subtype/Link/Border[0 0 1]/H/I/C[0 .5 .5]/A<</S/GoToR/F(fileone.pdf)/D(section.1)>>>>}
+.....\OT1/cmr/m/n/10 1
+.....\special{pdf:eann}
+.....\penalty 10000
+.....\glue(\parfillskip) 0.0 plus 1.0fil
+.....\glue(\rightskip) 0.0
+....\glue 0.0 plus 1.0fil
+....\glue 0.0
+....\glue 0.0 plus 0.0001fil
+...\glue(\baselineskip) 23.55556
+...\hbox(6.44444+0.0)x345.0
+....\hbox(6.44444+0.0)x345.0, glue set 170.0fil
+.....\glue 0.0 plus 1.0fil
+.....\OT1/cmr/m/n/10 1
+.....\glue 0.0 plus 1.0fil
+.\kern 0.0
+(firstaid-cleveref.aux)
+Package rerunfilecheck Info: File `firstaid-cleveref.out' has not changed.
+(rerunfilecheck) Checksum: D41D8CD98F00B204E9800998ECF8427E;0.
More information about the latex3-commits
mailing list.