[latex3-commits] [git/LaTeX3-latex3-hyperref] cleanup-patches: allow to suppress counter patches (0d2d48f)

Ulrike Fischer fischer at troubleshooting-tex.de
Tue Feb 7 00:17:51 CET 2023


Repository : https://github.com/latex3/hyperref
On branch  : cleanup-patches
Link       : https://github.com/latex3/hyperref/commit/0d2d48ff3040ef1e50d3a930c350ef4df290e365

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

commit 0d2d48ff3040ef1e50d3a930c350ef4df290e365
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Tue Feb 7 00:17:51 2023 +0100

    allow to suppress counter patches


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

0d2d48ff3040ef1e50d3a930c350ef4df290e365
 doc/hyperref-doc.tex | 18 ++++++++---
 hyperref.dtx         | 88 +++++++++++++++++++++++++++++-----------------------
 2 files changed, 63 insertions(+), 43 deletions(-)

diff --git a/doc/hyperref-doc.tex b/doc/hyperref-doc.tex
index 0685117..824af5a 100644
--- a/doc/hyperref-doc.tex
+++ b/doc/hyperref-doc.tex
@@ -537,11 +537,19 @@ Check the \xpackage{nameref} documentation about a way to suppress these patches
 \item \emph{All} those redefinitions can be suppressed by defining \cs{hyper at nopatch@footnote}. Be aware that this can suppress links but also make unwanted links appear.
 \end{itemize}
 
-\item[amsmath tags] hyperref defines two internal commands of amsmath related the |\tag| command to add
-   an anchor. This code can be suppressed by defining \cs{hyper at nopatch@amsmath at tag}. 
-   (This normally make not sense in packages will probably be needed when math environments are change to allow tagging.)
-   
-
+\item[amsmath tags] hyperref defines two internal commands of amsmath 
+    related the |\tag| command to add an anchor. This code can be 
+    suppressed by defining \cs{hyper at nopatch@amsmath at tag}. (This normally 
+    makes no sense in packages but will probably be needed when math 
+    environments are changed to allow tagging.) 
+   
+\item[counters] hyperref patches the kernel command \cs{@definecounter}, 
+    \cs{@newctr}, \cs{@addtoreset} and \cs{numberwithin} from amsmath to 
+    ensure that for every counter the correct \cs{theHcounter} 
+    representation is created or reset. This code can be suppressed by 
+    defining \cs{hyper at nopatch@counter}. (This normally makes no sense in 
+    packages but will probably be needed when kernel commands are changed 
+    to allow tagging.)  
 \end{description}
 
 \section{Package options}
diff --git a/hyperref.dtx b/hyperref.dtx
index ec6fd44..2c257fe 100644
--- a/hyperref.dtx
+++ b/hyperref.dtx
@@ -12100,22 +12100,28 @@
 % we are going to intercept this. Sigh. Do it at the level where
 % new counters are defined.
 %    \begin{macrocode}
-\let\H at definecounter\@definecounter
-\def\@definecounter#1{%
-  \H at definecounter{#1}%
-  \expandafter\gdef\csname theH#1\endcsname{\arabic{#1}}%
-}
+\@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}}%
+   }
+  }{} 
 %    \end{macrocode}
 % But what if they have used the optional argument to e.g. |\newtheorem|
 % to determine when the numbering is reset? OK, we'll trap that too.
 %    \begin{macrocode}
-\let\H at newctr\@newctr
-\def\@newctr#1[#2]{%
-  \H at newctr#1[{#2}]%
-  \expandafter\gdef\csname theH#1\endcsname{%
-    \csname the\@ifundefined{theH#2}{}{H}#2\endcsname.\arabic{#1}%
-  }%
-}
+\@ifundefined{hyper at nopatch@counter}
+  {
+    \let\H at newctr\@newctr
+    \def\@newctr#1[#2]{%
+      \H at newctr#1[{#2}]%
+      \expandafter\gdef\csname theH#1\endcsname{%
+        \csname the\@ifundefined{theH#2}{}{H}#2\endcsname.\arabic{#1}%
+      }%
+    }
+   }{} 
 %    \end{macrocode}
 % \section{AMS\LaTeX\ compatibility}\label{ams}
 % Oh, no, they don't use anything as simple as |\refstepcounter|
@@ -12178,15 +12184,18 @@
 %    \cs{theHcounter} is redefined in order to add the
 %    parent counter.
 %    \begin{macrocode}
-\let\HyOrg at addtoreset\@addtoreset
-\def\@addtoreset#1#2{%
-  \HyOrg at addtoreset{#1}{#2}%
-  \expandafter\xdef\csname theH#1\endcsname{%
-    \expandafter\noexpand
-        \csname the\@ifundefined{theH#2}{}H#2\endcsname
-    .\noexpand\the\noexpand\value{#1}%
-  }%
-}
+\@ifundefined{hyper at nopatch@counter}
+  {
+   \let\HyOrg at addtoreset\@addtoreset
+   \def\@addtoreset#1#2{%
+     \HyOrg at addtoreset{#1}{#2}%
+     \expandafter\xdef\csname theH#1\endcsname{%
+       \expandafter\noexpand
+           \csname the\@ifundefined{theH#2}{}H#2\endcsname
+       .\noexpand\the\noexpand\value{#1}%
+     }%
+   }
+  }{} 
 %    \end{macrocode}
 %
 %    \begin{macro}{\numberwithin}
@@ -12208,23 +12217,26 @@
 }%
 %</check>
 %<*packageEnd>
-\@ifpackageloaded{amsmath}{%
-  \renewcommand*{\numberwithin}[3][\arabic]{%
-    \@ifundefined{c@#2}{\@nocounterr{#2}}{%
-      \@ifundefined{c@#3}{\@nocnterr{#3}}{%
-        \HyOrg at addtoreset{#2}{#3}%
-        \@xp\xdef\csname the#2\endcsname{%
-          \@xp\@nx\csname the#3\endcsname .\@nx#1{#2}%
-        }%
-        \@xp\xdef\csname theH#2\endcsname{%
-          \@xp\@nx
-          \csname the\@ifundefined{theH#3}{}H#3\endcsname
-          .\@nx#1{#2}%
-        }%
-      }%
-    }%
-  }%
-}{}
+\@ifundefined{hyper at nopatch@counter}
+  {
+   \@ifpackageloaded{amsmath}{%
+     \renewcommand*{\numberwithin}[3][\arabic]{%
+       \@ifundefined{c@#2}{\@nocounterr{#2}}{%
+         \@ifundefined{c@#3}{\@nocnterr{#3}}{%
+           \HyOrg at addtoreset{#2}{#3}%
+           \@xp\xdef\csname the#2\endcsname{%
+             \@xp\@nx\csname the#3\endcsname .\@nx#1{#2}%
+           }%
+           \@xp\xdef\csname theH#2\endcsname{%
+             \@xp\@nx
+             \csname the\@ifundefined{theH#3}{}H#3\endcsname
+             .\@nx#1{#2}%
+           }%
+         }%
+       }%
+     }%
+   }{}
+  }{} 
 %    \end{macrocode}
 %    \end{macro}
 %





More information about the latex3-commits mailing list.