[latex3-commits] [git/LaTeX3-latex3-hyperref] cleanup-patches: allow to suppress math patches (ead51a6)

Ulrike Fischer fischer at troubleshooting-tex.de
Tue Feb 7 15:11:05 CET 2023


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

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

commit ead51a63f33cba09c408ab796a553ceaa44dbacf
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Tue Feb 7 15:11:05 2023 +0100

    allow to suppress math patches


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

ead51a63f33cba09c408ab796a553ceaa44dbacf
 doc/hyperref-doc.tex |  10 +++--
 hyperref.dtx         | 116 ++++++++++++++++++++++++++-------------------------
 2 files changed, 67 insertions(+), 59 deletions(-)

diff --git a/doc/hyperref-doc.tex b/doc/hyperref-doc.tex
index 824af5a..8a9e647 100644
--- a/doc/hyperref-doc.tex
+++ b/doc/hyperref-doc.tex
@@ -537,19 +537,23 @@ 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 
+\item[amsmath tags] hyperref redefines 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} 
+    \cs{@newctr}, \cs{@addtoreset} and the amsmath command \cs{numberwithin} 
+    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.)  
+    
+\item[math environments] hyperref patches \cs{equation}/\cs{endequation}, \cs{eqnarray},    
+    \cs{endeqnarray}. This code can be suppressed by 
+    defining \cs{hyper at nopatch@mathenv}. 
 \end{description}
 
 \section{Package options}
diff --git a/hyperref.dtx b/hyperref.dtx
index 5dc5c94..f8bfc92 100644
--- a/hyperref.dtx
+++ b/hyperref.dtx
@@ -10799,6 +10799,8 @@
 % The exception is that we move the equation incrementation inside
 % the math environment to avoid specials outside and a wrong vertical
 % spacing of equation environments.
+% This and more math related patches can be suppressed with 
+% |\hyper at nopatch@mathenv|
 %    \begin{macrocode}
 \let\new at refstepcounter\refstepcounter
 \let\H at equation\equation
@@ -10806,48 +10808,50 @@
 %    \end{macrocode}
 %
 %    \begin{macrocode}
-\@ifpackageloaded{amsmath}{%
-  \long\def\Hy at temp{%
-    \incr at eqnum
-    \mathdisplay at push
-    \st at rredfalse \global\@eqnswtrue
-    \mathdisplay{equation}%
-  }%
-  \ifx\Hy at temp\equation
-    \expandafter\ifx\csname if at fleqn\expandafter\endcsname
-                    \csname iftrue\endcsname
-    \else
-      \long\def\equation{%
-        \mathdisplay at push
-        \st at rredfalse \global\@eqnswtrue
-        \mathdisplay{equation}%
-        \incr at eqnum
-      }%
+\@ifundefined{hyper at nopatch@mathenv}{%
+  \@ifpackageloaded{amsmath}{%
+    \long\def\Hy at temp{%
+      \incr at eqnum
+      \mathdisplay at push
+      \st at rredfalse \global\@eqnswtrue
+      \mathdisplay{equation}%
+    }%
+    \ifx\Hy at temp\equation
+      \expandafter\ifx\csname if at fleqn\expandafter\endcsname
+                      \csname iftrue\endcsname
+      \else
+        \long\def\equation{%
+          \mathdisplay at push
+          \st at rredfalse \global\@eqnswtrue
+          \mathdisplay{equation}%
+          \incr at eqnum
+        }%
+      \fi
     \fi
-  \fi
-}{%
-  \def\equation{%
-    \let\refstepcounter\H at refstepcounter
-    \H at equation
-    \hyper at makecurrent{equation}%
+  }{%
+    \def\equation{%
+      \let\refstepcounter\H at refstepcounter
+      \H at equation
+      \hyper at makecurrent{equation}%
 %    \end{macrocode}
 %    \cs{mathopen} is needed in case the equation starts with
 %    an unary minus, for example.
 %    \begin{macrocode}
-    \mathopen{%
-      \Hy at raisedlink{\hyper at anchorstart{\@currentHref}}%
+      \mathopen{%
+        \Hy at raisedlink{\hyper at anchorstart{\@currentHref}}%
+      }%
+      \let\refstepcounter\new at refstepcounter
     }%
-    \let\refstepcounter\new at refstepcounter
-  }%
-  \def\endequation{%
-    \ifx\Hy at raisedlink\ltx at empty
-      \hyper at anchorend
-    \else
-      \mathclose{\Hy at raisedlink{\hyper at anchorend}}%
-    \fi
-    \H at endequation
-  }%
-}
+    \def\endequation{%
+      \ifx\Hy at raisedlink\ltx at empty
+        \hyper at anchorend
+      \else
+        \mathclose{\Hy at raisedlink{\hyper at anchorend}}%
+      \fi
+      \H at endequation
+    }%
+  }
+}{}  
 %    \end{macrocode}
 % My goodness, why can't \LaTeX{} be consistent? Why is |\eqnarray|
 % set up differently from other objects?
@@ -10861,26 +10865,28 @@
 \@eqnstarfalse
 \let\H at eqnarray\eqnarray
 \let\H at endeqnarray\endeqnarray
-\def\eqnarray{%
-  \let\Hy at reserved@a\relax
-  \def\@currentHref{}%
-  \H at eqnarray
-  \if at eqnstar
-  \else
-    \ifx\\\@currentHref\\%
+\@ifundefined{hyper at nopatch@mathenv}{%
+  \def\eqnarray{%
+    \let\Hy at reserved@a\relax
+    \def\@currentHref{}%
+    \H at eqnarray
+    \if at eqnstar
     \else
-      \hyper at makecurrent{equation}%
-      \mathopen{%
-        \Hy at raisedlink{%
-          \hyper at anchorstart{\@currentHref}\hyper at anchorend
+      \ifx\\\@currentHref\\%
+      \else
+        \hyper at makecurrent{equation}%
+        \mathopen{%
+          \Hy at raisedlink{%
+            \hyper at anchorstart{\@currentHref}\hyper at anchorend
+          }%
         }%
-      }%
+      \fi
     \fi
-  \fi
-}
-\def\endeqnarray{%
-  \H at endeqnarray
-}
+  }
+  \def\endeqnarray{%
+    \H at endeqnarray
+  }
+}{}  
 %    \end{macrocode}
 % This is quite heavy-handed, but it works for now. If its an |eqnarray*|
 % we need to disable the hyperref actions. There may well be a cleaner
@@ -10936,9 +10942,7 @@
 %
 % Support for amsmath's \texttt{subequations}:
 %    \begin{macrocode}
-\begingroup\expandafter\expandafter\expandafter\endgroup
-\expandafter\ifx\csname subequations\endcsname\relax
-\else
+\ifcsname subequations\endcsname
   \let\HyOrg at subequations\subequations
   \def\subequations{%
     \stepcounter{equation}%





More information about the latex3-commits mailing list.