[latex3-commits] [latex3/hyperref] develop: allow command names in counter, issue #330 (a577d53)

github at latex-project.org github at latex-project.org
Wed Feb 14 11:42:57 CET 2024


Repository : https://github.com/latex3/hyperref
On branch  : develop
Link       : https://github.com/latex3/hyperref/commit/a577d5372bb403da646eae5efc0b0bf90bfebafe

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

commit a577d5372bb403da646eae5efc0b0bf90bfebafe
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Wed Feb 14 11:42:57 2024 +0100

    allow command names in counter, issue #330


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

a577d5372bb403da646eae5efc0b0bf90bfebafe
 ChangeLog.txt                       |  4 ++++
 hyperref.dtx                        |  7 +++++--
 testfiles-pdftex/gh303-Hcounter.lvt | 13 +++++++++++++
 testfiles-pdftex/gh303-Hcounter.tlg |  9 +++++++++
 testfiles-pdftex/patch.tlg          |  2 +-
 5 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/ChangeLog.txt b/ChangeLog.txt
index 28d6ff9..5501058 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -1,3 +1,7 @@
+2024-02-14 Ulrike Fischer
+	* hyperref.dtx: allow commands in counter names
+issue #330
+
 2024-01-20 Ulrike Fischer
 	* hyperref.dtx: alias for \deferred at thm@head to allow patching if czech is used,
 issue #324
diff --git a/hyperref.dtx b/hyperref.dtx
index 2c6347a..104c1a6 100644
--- a/hyperref.dtx
+++ b/hyperref.dtx
@@ -12035,14 +12035,17 @@
 % The whole theorem business makes up new counters on the fly;
 % we are going to intercept this. Sigh. Do it at the level where
 % new counters are defined.
+% change 2024-02-14: use a csname to handle counter names with commands,
+% see issue \#330
 %    \begin{macrocode}
 \@ifundefined{hyper at nopatch@counter}
   {
    \let\H at definecounter\@definecounter
    \def\@definecounter#1{%
      \H at definecounter{#1}%
-     \expandafter\gdef\csname theH#1\endcsname{\arabic{#1}}%
-   }
+     \expandafter
+     \gdef\csname theH#1\expandafter\endcsname\expandafter
+          {\expandafter\@arabic\csname c@#1\endcsname}}%
   }{} 
 %    \end{macrocode}
 % But what if they have used the optional argument to e.g. |\newtheorem|
diff --git a/testfiles-pdftex/gh303-Hcounter.lvt b/testfiles-pdftex/gh303-Hcounter.lvt
new file mode 100644
index 0000000..5c53e34
--- /dev/null
+++ b/testfiles-pdftex/gh303-Hcounter.lvt
@@ -0,0 +1,13 @@
+\documentclass[11pt]{article}
+\input{regression-test}
+\usepackage{hyperref}
+\START
+\def\blub{duck}
+\newcounter{\blub}
+\show\theduck
+\show\theHduck
+\OMIT
+\begin{document}
+\refstepcounter{duck}
+xxx
+\end{document}
\ No newline at end of file
diff --git a/testfiles-pdftex/gh303-Hcounter.tlg b/testfiles-pdftex/gh303-Hcounter.tlg
new file mode 100644
index 0000000..be87c04
--- /dev/null
+++ b/testfiles-pdftex/gh303-Hcounter.tlg
@@ -0,0 +1,9 @@
+This is a generated file for the l3build validation system.
+Don't change this file in any respect.
+\c at duck=\count...
+> \theduck=macro:
+->\@arabic \c at duck .
+l. ...\show\theduck
+> \theHduck=macro:
+->\@arabic \c at duck .
+l. ...\show\theHduck
diff --git a/testfiles-pdftex/patch.tlg b/testfiles-pdftex/patch.tlg
index f68aa74..a185b4e 100644
--- a/testfiles-pdftex/patch.tlg
+++ b/testfiles-pdftex/patch.tlg
@@ -41,7 +41,7 @@ l. ...\ShowCommand\@caption
 <argument> \addcontentsline 
 l. ...\ShowCommand\addcontentsline
 > \@definecounter=macro:
-#1->\H at definecounter {#1}\expandafter \gdef \csname theH#1\endcsname {\arabic {#1}}.
+#1->\H at definecounter {#1}\expandafter \gdef \csname theH#1\expandafter \endcsname \expandafter {\expandafter \@arabic \csname c@#1\endcsname }.
 <argument> \@definecounter 
 l. ...\ShowCommand\@definecounter
 > \@newctr=macro:





More information about the latex3-commits mailing list.