summaryrefslogtreecommitdiff
path: root/macros/latex-dev/required/amsmath/amsmath.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex-dev/required/amsmath/amsmath.dtx')
-rw-r--r--macros/latex-dev/required/amsmath/amsmath.dtx29
1 files changed, 26 insertions, 3 deletions
diff --git a/macros/latex-dev/required/amsmath/amsmath.dtx b/macros/latex-dev/required/amsmath/amsmath.dtx
index 8857861101..eec51f50cb 100644
--- a/macros/latex-dev/required/amsmath/amsmath.dtx
+++ b/macros/latex-dev/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/08/28 v2.17k 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}}{%
@@ -6500,8 +6502,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 +6523,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}