texlive[72876] Master/texmf-dist: zref-clever (17nov24)

commits+karl at tug.org commits+karl at tug.org
Sun Nov 17 22:18:07 CET 2024


Revision: 72876
          https://tug.org/svn/texlive?view=revision&revision=72876
Author:   karl
Date:     2024-11-17 22:18:07 +0100 (Sun, 17 Nov 2024)
Log Message:
-----------
zref-clever (17nov24)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/zref-clever/CHANGELOG.md
    trunk/Master/texmf-dist/doc/latex/zref-clever/zref-clever-code.pdf
    trunk/Master/texmf-dist/doc/latex/zref-clever/zref-clever-doc.pdf
    trunk/Master/texmf-dist/doc/latex/zref-clever/zref-clever-doc.tex
    trunk/Master/texmf-dist/source/latex/zref-clever/zref-clever.dtx
    trunk/Master/texmf-dist/tex/latex/zref-clever/zref-clever.sty

Modified: trunk/Master/texmf-dist/doc/latex/zref-clever/CHANGELOG.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/zref-clever/CHANGELOG.md	2024-11-17 21:17:56 UTC (rev 72875)
+++ trunk/Master/texmf-dist/doc/latex/zref-clever/CHANGELOG.md	2024-11-17 21:18:07 UTC (rev 72876)
@@ -1,7 +1,12 @@
 # Changelog
 
-## [Unreleased](https://github.com/gusbrs/zref-clever/compare/v0.4.8...HEAD)
+## [Unreleased](https://github.com/gusbrs/zref-clever/compare/v0.4.9...HEAD)
 
+## [v0.4.9](https://github.com/gusbrs/zref-clever/compare/v0.4.8...v0.4.9) (2024-11-16)
+
+### Changed
+- Convert improved `beamer` work-around into compatibility module.
+
 ## [v0.4.8](https://github.com/gusbrs/zref-clever/compare/v0.4.7...v0.4.8) (2024-11-07)
 
 ### Changed

Modified: trunk/Master/texmf-dist/doc/latex/zref-clever/zref-clever-code.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/zref-clever/zref-clever-doc.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/zref-clever/zref-clever-doc.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/zref-clever/zref-clever-doc.tex	2024-11-17 21:17:56 UTC (rev 72875)
+++ trunk/Master/texmf-dist/doc/latex/zref-clever/zref-clever-doc.tex	2024-11-17 21:18:07 UTC (rev 72876)
@@ -61,6 +61,7 @@
 
 \NewDocumentCommand\opt{m}{\texttt{#1}}
 
+\NewDocumentCommand\contributor{m}{#1}
 \NewDocumentCommand\username{m}{`\texttt{#1}'}
 
 \makeatletter
@@ -87,6 +88,8 @@
   language=[LaTeX]TeX,
   moretexcs={
     AddToHook,
+    AddToHookWithArguments,
+    DeclareHookRule,
     define at key,
     patchcmd,
     eq at setnumber,
@@ -105,6 +108,7 @@
     NewCommandCopy,
     ltx at gobble,
     @currentcounter,
+    @currentHref,
     zref at label,
     zref at wrapper@babel,
     zref at ifpropundefined,
@@ -115,6 +119,8 @@
     alt,
     beamer at nameslide,
     beamer at dummynameslide,
+    uncover,
+    only,
     ordinal,
     tcbuselibrary,
     tcbset,
@@ -165,7 +171,7 @@
   \zcsetup{countertype={lstlisting=zcworkaround}}%
   \lstset{#1}%
   \stepcounter{zcworkaround}%
-  \setcounter{lstlisting}{\value{zcworkaround}}%
+  \setcounter{lstlisting}{\value{zcworkaround}-1}%
 }{}
 \lstnewenvironment{zcexample}[1][]{%
   \renewcommand{\lstlistingname}{Example}%
@@ -2027,6 +2033,68 @@
 \end{zchowto}
 
 
+\subsection{\cls{beamer}}
+
+\zctask{Making references in \cls{beamer}.}
+
+\cls{beamer} does some atypical things with regard to cross-references, in
+particular it redefines \cs{label} to support overlays.  The special treatment
+is not extended to \cs{zlabel}, hence \cls{beamer} requires the use of
+\cs{label} with the \opt{labelhook} option.  Some setup for references to
+frames is also needed, with a fitting setting for the \opt{countertype} of the
+\texttt{framenumber} counter and, possibly, corresponding type names for
+it.\footnote{I'm not sure what the best type name for it would be though.
+  ``Frame'' sounds too \cls{beamer}-specific, and possibly ``slide'' is what
+  ``the audience'' would expect.  But \emph{some} name (or preexisting type)
+  would need to be assigned, and you can always choose something else, of
+  course.  This is just to illustrate the procedure.}
+
+\begin{zchowto}[caption={\cls{beamer}}]
+\documentclass{beamer}
+\usepackage{zref-clever}
+\zcsetup{countertype={framenumber=slide}}
+\zcRefTypeSetup{slide}{
+  Name-sg = Slide ,
+  name-sg = slide ,
+  Name-pl = Slides ,
+  name-pl = slides ,
+}
+\begin{document}
+\begin{frame}[label={fr:1}]
+  \begin{table}
+    \begin{tabular}{cc}
+      1 & 2 \\
+      3 & 4 \\
+    \end{tabular}
+    \caption{Table 1}
+    \label{tab:1}
+  \end{table}
+\end{frame}
+\begin{frame}[label={fr:2}]
+  \begin{figure}
+    \rule{5cm}{5cm}
+    \caption{Figure 1}
+    \label{fig:1}
+  \end{figure}
+\end{frame}
+\begin{frame}
+  \zcref{fr:1,fr:2,tab:1,fig:1}
+\end{frame}
+\begin{frame}
+  \begin{align}
+    a &= b + c \label{eq:1}\\
+    c &= d + e \label{eq:2}
+  \end{align}
+  Blah blah. \uncover<2>{More blah blah.}\par
+  \only<3>{Specification is needed now.\label<3>{overlay}}
+\end{frame}
+\begin{frame}
+  \zcref{eq:1,eq:2,overlay}
+\end{frame}
+\end{document}
+\end{zchowto}
+
+
 \subsection{Ordinal references}
 
 \zctask{Typesetting the references as ordinal numbers.}
@@ -2321,114 +2389,32 @@
 This module just sets appropriate \opt{countertype} and \opt{counterresetby}
 for the \texttt{subfigure} and \texttt{subtable} counters.
 
+\DescribeOption{beamer} %
+This compatibility module sets proper values of \cs{@currentHref}, so that the
+\cs{label}s are stored with anchors which correspond to the ones \cls{beamer}
+actually creates, using the \texttt{label} hook for the purpose, meaning this
+strictly requires the use of \cs{label} with the \opt{labelhook} option.  It
+also sets appropriate \cs{@currentcounter} for frames, using a generic
+\texttt{cmd} hook on \cls{beamer}'s \cs{refcounter} macro.
 
-\section{Work-arounds}
 
-\marginpar{\raggedleft\raisebox{-1.5ex}{\dbend}}The compatibility modules
-presented in \zcref{sec:comp-modules} should go a long way in ensuring the
-user has little to worry about in setting up \pkg{zref-clever} for some more
-traditional document classes and packages, but they cannot be expected to go
-all the way.  Not only because this kind of support will never be exhaustive,
-but also since, sometimes, given the way certain features are implemented,
-there may not be a reasonable way to provide this support, from our side.
-But, still, most of the time, it is still ``viable'' to get there, if one
-really wishes to do so.  So, this section keeps track of some known recipes,
-which I don't think belong in \pkg{zref-clever} itself, but which you may
-choose to use.  Note that this list is intended to spare users from having to
-reinvent the wheel every time someone needs something of the sort, but from
-\pkg{zref-clever}'s perspective, their status is ``not supported''.
+% \section{Work-arounds}
+%
+% \marginpar{\raggedleft\raisebox{-1.5ex}{\dbend}}The compatibility modules
+% presented in \zcref{sec:comp-modules} should go a long way in ensuring the
+% user has little to worry about in setting up \pkg{zref-clever} for some more
+% traditional document classes and packages, but they cannot be expected to go
+% all the way.  Not only because this kind of support will never be exhaustive,
+% but also since, sometimes, given the way certain features are implemented,
+% there may not be a reasonable way to provide this support, from our side.
+% But, still, most of the time, it is still ``viable'' to get there, if one
+% really wishes to do so.  So, this section keeps track of some known recipes,
+% which I don't think belong in \pkg{zref-clever} itself, but which you may
+% choose to use.  Note that this list is intended to spare users from having to
+% reinvent the wheel every time someone needs something of the sort, but from
+% \pkg{zref-clever}'s perspective, their status is ``not supported''.
 
 
-\subsection*{\cls{beamer}}
-
-\cls{beamer} does some really atypical things with regard to cross-references.
-To start with, it redefines \cs{label} to receive an optional
-\texttt{<\meta{overlay specification}>} argument.  Then, presumably to support
-overlays, it goes on and hijacks \pkg{hyperref}'s anchoring system, sets
-anchors (\cs{hypertarget}s) to each \emph{label} in the \file{.snm} file,
-while letting every standard label's anchor in the \file{.aux} file default to
-\texttt{Doc-Start}.  Of course, having rendered useless \pkg{hyperref}'s
-anchoring, it has to redefine \cs{ref} so that it uses its own \file{.snm}
-provided ``label anchors'' to make hyperlinks.  In particular, from our
-perspective, there is no support at all for \pkg{zref} provided by
-\cls{beamer}.  Which is specially unfortunate since the above procedures also
-appear to break \pkg{cleveref}.\footnote{See, for example,
-  \url{https://tex.stackexchange.com/q/266080},
-  \url{https://tex.stackexchange.com/q/668998}, and
-  \url{https://github.com/josephwright/beamer/issues/750}.  The workaround
-  provided at \url{https://tex.stackexchange.com/a/266109} is not general
-  enough since it breaks \pkg{cleveref}'s ability to receive a list of labels
-  as argument.}
-
-Adding proper support for this is the business of \cls{beamer}, \pkg{zref},
-and/or \pkg{hyperref}.  Likely the former's really.  But, taking advantage of
-\pkg{zref}'s flexibility, as a user, you can have a work-around in the
-meantime.
-
-\begin{zcworkaround}[caption={\cls{beamer}}]
-\documentclass{beamer}
-\usepackage{zref-clever}
-\makeatletter
-\RenewDocumentCommand{\zlabel}{ D<>{1} m }{%
-  \ifx\label\ltx at gobble
-  \else
-    \zref at wrapper@babel{\zref at label<#1>}{#2}%
-  \fi
-}
-\NewCommandCopy\beamer at old@zref at label\zref at label
-\RenewDocumentCommand{\zref at label}{ D<>{1} m }{%
-  \alt<#1>{%
-    \zref at ifpropundefined{anchor}{}{\zref at setcurrent{anchor}{#2}}%
-    \beamer at old@zref at label{#2}%
-    \beamer at nameslide{#2}%
-  }{%
-    \beamer at dummynameslide%
-  }%
-}
-\makeatother
-\begin{document}
-\begin{frame}
-  \begin{table}
-    \begin{tabular}{cc}
-      1 & 2 \\
-      3 & 4 \\
-    \end{tabular}
-    \caption{Table 1}
-    \zlabel{tab:1}
-  \end{table}
-\end{frame}
-\begin{frame}
-  \begin{figure}
-    \rule{5cm}{5cm}
-    \caption{Figure 1}
-    \zlabel{fig:1}
-  \end{figure}
-\end{frame}
-\begin{frame}
-  \zcref{tab:1,fig:1}
-\end{frame}
-\end{document}
-\end{zcworkaround}
-
-This work-around redefines \cs{zlabel} so that it takes an overlay
-specification argument, and provides that the work done by \cls{beamer} for
-the standard \cs{label} is also done for it.  And it works by setting the
-\texttt{anchor} to the \emph{label} so as to be able to speak the
-``\cls{beamer}-lingo'' of anchors.
-
-A couple of caveats though.  First, there's probably still some work to be
-done there in defining and setting reference types for \cls{beamer} specific
-document objects, e.g. overlays.  But it can be done by the standard user
-interface of \pkg{zref-clever}.  Second, since \cls{beamer}'s anchoring system
-does not provide for uniqueness of anchors as \pkg{hyperref} does, if you
-(need to) use \cs{label} to set both \cs{label} and \cs{zlabel}, relying on
-the \opt{labelhook} option, this will result in duplicate anchors for labels
-set in them, with corresponding \pkg{hyperref} warnings of ``destination with
-the same identifier has been already used, duplicate ignored''.  The warning
-is actually harmless in this case, since both labels are set in the same
-place, and thus have identical anchors, it is nevertheless there.
-
-
 \section{Acknowledgments}
 
 \pkg{zref-clever} would not be possible without other people's previous work
@@ -2472,6 +2458,8 @@
   % 2023-01-02: https://tex.stackexchange.com/q/670399 (comments)
   % 2023-06-01: https://github.com/latex3/latex2e/pull/956
   % 2023-07-27: https://chat.stackexchange.com/transcript/message/64067726#64067726
+  % 2024-11-14: https://tex.stackexchange.com/a/730792
+  % 2024-11-14: https://github.com/josephwright/beamer/issues/917
   Phelype Oleinik,
   % 2021-08-20: https://tex.stackexchange.com/q/611370 (comments)
   % 2021-09-09: https://tex.stackexchange.com/a/614704
@@ -2503,6 +2491,7 @@
   \username{samcarter},
   % 2021-10-14: https://chat.stackexchange.com/transcript/message/59361777#59361777
   % 2021-10-21: https://chat.stackexchange.com/transcript/message/59418309#59418309
+  % 2024-11-14: https://github.com/josephwright/beamer/issues/917
   Alan Munn,
   % 2021-10-14: https://chat.stackexchange.com/transcript/message/59364073#59364073
   % 2021-10-21: https://chat.stackexchange.com/transcript/message/59418189#59418189

Modified: trunk/Master/texmf-dist/source/latex/zref-clever/zref-clever.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/zref-clever/zref-clever.dtx	2024-11-17 21:17:56 UTC (rev 72875)
+++ trunk/Master/texmf-dist/source/latex/zref-clever/zref-clever.dtx	2024-11-17 21:18:07 UTC (rev 72876)
@@ -172,7 +172,7 @@
 %
 % Identify the package.
 %    \begin{macrocode}
-\ProvidesExplPackage {zref-clever} {2024-11-07} {0.4.8}
+\ProvidesExplPackage {zref-clever} {2024-11-16} {0.4.9}
   {Clever LaTeX cross-references based on zref}
 %    \end{macrocode}
 %
@@ -5393,7 +5393,7 @@
 % Store label types sequence.
 %    \begin{macrocode}
     \seq_clear:N \l_@@_label_types_seq
-    \tl_if_eq:NnF \l_@@_ref_propserty_tl { page }
+    \tl_if_eq:NnF \l_@@_ref_property_tl { page }
       {
         \seq_map_function:NN \l_@@_zcref_labels_seq
           \@@_label_type_put_new_right:n
@@ -8384,7 +8384,54 @@
 %    \end{macrocode}
 %
 %
+% \subsection{\opt{beamer}}
+%
+% FIXME When \cls{beamer} releases fixes for these issues, remove this
+% compatibility module.  See
+% \url{https://github.com/josephwright/beamer/issues/917}.
+%
+% \cls{beamer} does some really atypical things with regard to
+% cross-references.  To start with, it redefines \cs{label} to receive an
+% optional \texttt{<\meta{overlay specification}>} argument.  Then, presumably
+% to support overlays, it goes on and hijacks \pkg{hyperref}'s anchoring
+% system, sets anchors (\cs{hypertarget}s) to each \emph{label} in the
+% \file{.snm} file, while letting every standard label's anchor in the
+% \file{.aux} file default to \texttt{Doc-Start}.  Of course, having rendered
+% useless \pkg{hyperref}'s anchoring, it has to redefine \cs{ref} so that it
+% uses its own \file{.snm} provided ``label anchors'' to make hyperlinks.  In
+% particular, from our perspective, there is no support at all for \pkg{zref}
+% provided by \cls{beamer}.  Which is specially unfortunate since the above
+% procedures also appear to break \pkg{cleveref}.  See, for example,
+% \url{https://tex.stackexchange.com/q/266080},
+% \url{https://tex.stackexchange.com/q/668998}, and
+% \url{https://github.com/josephwright/beamer/issues/750}.  The work-around
+% provided at \url{https://tex.stackexchange.com/a/266109} is not general
+% enough since it breaks \pkg{cleveref}'s ability to receive a list of labels
+% as argument.  Finally, \cls{beamer} also does not set \cs{@currentcounter}
+% for the frames, making it hard for \pkg{zref-clever} to assign the proper
+% type to labels set in that scope.
+%
+% The technique to set proper anchors is is thanks to \contributor{Ulrike
+% Fischer} at \url{https://tex.stackexchange.com/a/730792}.
+%
 %    \begin{macrocode}
+\@@_compat_module:nn { beamer }
+  {
+    \@@_if_class_loaded:nT { beamer }
+      {
+        \AddToHookWithArguments { label } [ zref-clever/compat/beamer ]
+          { \xdef\@currentHref{#1} }
+        \DeclareHookRule { label }
+          { zref-clever/compat/beamer } { before } { zref-clever }
+        \AddToHookWithArguments { cmd/refcounter/before }
+          [ zref-clever/compat/beamer ]
+          { \edef\@currentcounter{#1} }
+      }
+  }
+%    \end{macrocode}
+%
+%
+%    \begin{macrocode}
 %</package>
 %    \end{macrocode}
 %

Modified: trunk/Master/texmf-dist/tex/latex/zref-clever/zref-clever.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/zref-clever/zref-clever.sty	2024-11-17 21:17:56 UTC (rev 72875)
+++ trunk/Master/texmf-dist/tex/latex/zref-clever/zref-clever.sty	2024-11-17 21:18:07 UTC (rev 72876)
@@ -52,7 +52,7 @@
         'zref-clever' requires a LaTeX kernel \zrefclever at required@kernel\space or newer.%
       }%
   }%
-\ProvidesExplPackage {zref-clever} {2024-11-07} {0.4.8}
+\ProvidesExplPackage {zref-clever} {2024-11-16} {0.4.9}
   {Clever LaTeX cross-references based on zref}
 \RequirePackage { zref-base }
 \RequirePackage { zref-user }
@@ -3518,7 +3518,7 @@
 \cs_new_protected:Npn \__zrefclever_sort_labels:
   {
     \seq_clear:N \l__zrefclever_label_types_seq
-    \tl_if_eq:NnF \l__zrefclever_ref_propserty_tl { page }
+    \tl_if_eq:NnF \l__zrefclever_ref_property_tl { page }
       {
         \seq_map_function:NN \l__zrefclever_zcref_labels_seq
           \__zrefclever_label_type_put_new_right:n
@@ -5701,6 +5701,19 @@
           }
       }
   }
+\__zrefclever_compat_module:nn { beamer }
+  {
+    \__zrefclever_if_class_loaded:nT { beamer }
+      {
+        \AddToHookWithArguments { label } [ zref-clever/compat/beamer ]
+          { \xdef\@currentHref{#1} }
+        \DeclareHookRule { label }
+          { zref-clever/compat/beamer } { before } { zref-clever }
+        \AddToHookWithArguments { cmd/refcounter/before }
+          [ zref-clever/compat/beamer ]
+          { \edef\@currentcounter{#1} }
+      }
+  }
 \zcDeclareLanguage { english }
 \zcDeclareLanguageAlias { american   } { english }
 \zcDeclareLanguageAlias { australian } { english }



More information about the tex-live-commits mailing list.