summaryrefslogtreecommitdiff
path: root/macros/latex/required/amsmath/amsmath.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/required/amsmath/amsmath.dtx')
-rw-r--r--macros/latex/required/amsmath/amsmath.dtx37
1 files changed, 33 insertions, 4 deletions
diff --git a/macros/latex/required/amsmath/amsmath.dtx b/macros/latex/required/amsmath/amsmath.dtx
index 8857861101..a5cf333e79 100644
--- a/macros/latex/required/amsmath/amsmath.dtx
+++ b/macros/latex/required/amsmath/amsmath.dtx
@@ -86,7 +86,7 @@ Bug reports can be opened (category \texttt{#1}) at\\%
% \end{macrocode}
%
% \begin{macrocode}
-\ProvidesPackage{amsmath}[2021/04/20 v2.17j AMS math features]
+\ProvidesPackage{amsmath}[2021/10/15 v2.17l AMS math features]
% \end{macrocode}
%
% \section{Catcode defenses}
@@ -2627,7 +2627,9 @@ ill-advised in LaTeX.%
%
% \begin{macro}{\numberwithin}
% Provide a convenient way to specify that equations should be
-% numbered within sections.
+% numbered within sections. The \LaTeX{} kernel contains a similar command
+% \cs{counterwithin} (with a slightly extended syntax) that can be used
+% as a drop-in replacement for \cs{numberwithin}.
% \begin{macrocode}
\newcommand{\numberwithin}[3][\arabic]{%
\@ifundefined{c@#2}{\@nocounterr{#2}}{%
@@ -3010,7 +3012,13 @@ ill-advised in LaTeX.%
% the \cs{maketag@@} macro above.
% \begin{macrocode}
\let\df@tag\@empty
-\def\make@df@tag{\@ifstar\make@df@tag@@\make@df@tag@@@}
+\def\make@df@tag{%
+% \end{macrocode}
+% We set \cs{@currentcounter} here so that it applies to both branches.
+%\changes{v2.17l}{2021/10/15}{Explicitly set \cs{@currentcounter} (gh/687)}
+% \begin{macrocode}
+ \def\@currentcounter{equation}%
+ \@ifstar\make@df@tag@@\make@df@tag@@@}
% \end{macrocode}
% \cs{make@df@tag} sets \cs{@currentlabel} and defines
% \cs{df@tag} appropriately.
@@ -6500,8 +6508,17 @@ Cannot use `split' here;\MessageBreak trying to recover with `aligned'}%
\let\mathdisplay@pop\@empty
\def\mathdisplay@@pop{\the\mathdisplay@stack}
% \end{macrocode}
-%
+%\changes{v2.17k}{2021/08/24}{Move the counter inside the equation and guard
+% with a mathopen for better compability with hyperref, issue gh/652}
+% As with hyperref incrementing the counter creates a box to raise the anchor
+% it should be in a place where is doesn't affect spacing.
+% Currently the code from hyperref is used to avoid this problem:
+% If fleqn isn't active the counter is set inside the equation and the potential
+% box guarded by a mathopen to avoid side effects on following unary symbols.
+% If fleqn is activated it has to be outside to avoid problems with labels.
+% This solution is temporary and not necessarly the best.
% \begin{macrocode}
+\if@fleqn
\renewenvironment{equation}{%
\incr@eqnum
\mathdisplay@push
@@ -6512,6 +6529,18 @@ Cannot use `split' here;\MessageBreak trying to recover with `aligned'}%
\mathdisplay@pop
\ignorespacesafterend
}
+\else
+\renewenvironment{equation}{%
+ \mathdisplay@push
+ \st@rredfalse \global\@eqnswtrue
+ \mathdisplay{equation}%
+ \incr@eqnum\mathopen{}%
+}{%
+ \endmathdisplay{equation}%
+ \mathdisplay@pop
+ \ignorespacesafterend
+}
+\fi
% \end{macrocode}
%
% \begin{macrocode}