[latex3-commits] [latex3/hyperref] amsmath: make amsmath patches independent of loading order (19abb83)
github at latex-project.org
github at latex-project.org
Wed Jun 14 15:49:08 CEST 2023
Repository : https://github.com/latex3/hyperref
On branch : amsmath
Link : https://github.com/latex3/hyperref/commit/19abb836ebfd002e0491303e0558907ea23065a3
>---------------------------------------------------------------
commit 19abb836ebfd002e0491303e0558907ea23065a3
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Wed Jun 14 15:49:08 2023 +0200
make amsmath patches independent of loading order
>---------------------------------------------------------------
19abb836ebfd002e0491303e0558907ea23065a3
ChangeLog.txt | 3 +++
hyperref.dtx | 80 ++++++++++++++++++++++++++++++-----------------------------
2 files changed, 44 insertions(+), 39 deletions(-)
diff --git a/ChangeLog.txt b/ChangeLog.txt
index f471e51..0931b1c 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -1,3 +1,6 @@
+2023-06-14 Ulrike Fischer
+ * changed various patches for amsmath to make them independent of loading order.
+
2023-05-16 Ulrike Fischer
* remove puenc-greekbasic.def and load definitions from greek-fontenc instead.
* xr-hyper: unified and simplified the brace handling: all defined references have now
diff --git a/hyperref.dtx b/hyperref.dtx
index df20f32..197f21c 100644
--- a/hyperref.dtx
+++ b/hyperref.dtx
@@ -10416,7 +10416,12 @@
% that the hyper stuff is not executed twice, so we use the AMS
% |\ifmeasuring@|, initialized if AMS math is not used.
% \begin{macrocode}
-\@ifpackageloaded{amsmath}{}{\newif\ifmeasuring@\measuring at false}
+\newcommand\Hy at ifnotmeasuring[1]{#1}
+\AddToHook{package/amsmath/after}
+ {
+ \renewcommand\Hy at ifnotmeasuring[1]
+ {\ifmeasuring@ \else #1\fi}
+ }
% \end{macrocode}
%
% \begin{macro}{\hyper at refstepcounter}
@@ -10424,12 +10429,10 @@
\def\hyper at refstepcounter#1{%
\HyCnt at ProvideTheHCounter{#1}%
\hyper at makecurrent{#1}%
- \ifmeasuring@
- \else
- \Hy at raisedlink{%
+ \Hy at ifnotmeasuring
+ {\Hy at raisedlink{%
\hyper at anchorstart{\@currentHref}\hyper at anchorend
- }%
- \fi
+ }}%
}
% \end{macrocode}
% \end{macro}
@@ -10797,9 +10800,11 @@
% Overload equation, temporarily reverting to original
% |\refstepcounter|. If, however, it is in AMS math, we do not
% do anything, as the tag mechanism is used there (see section \ref{ams}).
-% 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.
+% change 2023-06-14: previously hyperref contained code that moved
+% the equation incrementation inside the math environment to
+% avoid specials outside and a wrong vertical spacing of equation environments.
+% Since 2021/08/24 this code is now in amsmath directly and so has been removed here.
+%
% This and more math related patches can be suppressed with
% |\hyper at nopatch@mathenv|
% \begin{macrocode}
@@ -10810,26 +10815,14 @@
%
% \begin{macrocode}
\@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
- }{%
+% \end{macrocode}
+% If amsmath was loaded before the following does nothing.
+% If amsmath is loaded later it will overwrite the definition again,
+% which is what is wanted here.
+% If it is not loaded the new definition of equation
+% will be used.
+% \begin{macrocode}
+ \@ifpackageloaded{amsmath}{}{%
\def\equation{%
\let\refstepcounter\H at refstepcounter
\H at equation
@@ -10942,18 +10935,23 @@
% \end{macrocode}
%
% Support for amsmath's \texttt{subequations}:
+% change 2023-06-14: we use hooks to no longer depend on
+% amsmath being loaded before hyperref.
+% Once amsmath sets the theH-representation itself this
+% can go completely.
% \begin{macrocode}
-\ifcsname subequations\endcsname
- \let\HyOrg at subequations\subequations
- \def\subequations{%
+\AddToHook{cmd/subequations/before}
+ {%
\stepcounter{equation}%
\protected at edef\theHparentequation{\theHequation}%
\addtocounter{equation}{-1}%
- \HyOrg at subequations
- \def\theHequation{\theHparentequation\alph{equation}}%
- \ignorespaces
- }%
-\fi
+ }
+
+\AddToHook{cmd/subequations/after}
+ {%
+ \def\theHequation{\theHparentequation\alph{equation}}%
+ \ignorespaces
+ }
% \end{macrocode}
%
% Support for theorems. We move the target into the para hook to
@@ -12007,10 +12005,11 @@
%
% If |\hyper at nopatch@amsmath at tag| is defined we don't patch but assume
% that kernel code adds anchors to equations.
+% change 2023-06-14: use a hook to make it independent of loading order.
% \begin{macrocode}
\@ifundefined{hyper at nopatch@amsmath at tag}
{%
- \@ifpackageloaded{amsmath}{%
+ \AddToHook{package/amsmath/after}{%
\def\Hy at make@anchor{%
\Hy at MakeCurrentHrefAuto{AMS}%
\Hy at raisedlink{\hyper at anchorstart{\@currentHref}\hyper at anchorend}%
@@ -12088,10 +12087,13 @@
}%
}%
%</check>
+% \end{macrocode}
+% change 2023-06-14: use hook to make independent of loading order
+% \begin{macrocode}
%<*packageEnd>
\@ifundefined{hyper at nopatch@counter}
{
- \@ifpackageloaded{amsmath}{%
+ \AddToHook{package/amsmath/after}{%
\renewcommand*{\numberwithin}[3][\arabic]{%
\@ifundefined{c@#2}{\@nocounterr{#2}}{%
\@ifundefined{c@#3}{\@nocnterr{#3}}{%
More information about the latex3-commits
mailing list.