Skip to content

Commit

Permalink
Gh 1265 (#1424)
Browse files Browse the repository at this point in the history
* fix for #1265 (draft version)

* fix docu

* corrections

* add an ltnews entry

* changes entry

* typo

* fix typos

* one more

---------

Co-authored-by: David Carlisle <[email protected]>
  • Loading branch information
FrankMittelbach and davidcarlisle authored Aug 3, 2024
1 parent bce64cd commit 01a49aa
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 7 deletions.
20 changes: 19 additions & 1 deletion base/doc/ltnews40.tex
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ \section{Improvement to \XeTeX\ \cs{showhyphens}}
%
\githubissue{1380}


\section{Avoid code duplication in rollback}

When the kernel uses \cs{AddToHook} in a region that might be
Expand All @@ -302,7 +303,24 @@ \section{Avoid code duplication in rollback}
\githubissue{1407}


%\section{Changes to packages in the \pkg{amsmath} category}


\section{Changes to packages in the \pkg{amsmath} category}

\section{Extend support for \cs{dots}}

The implementation of \cs{dots} in \pkg{amsmath} has the feature that
it selects different dots depending on the symbol that follows: e.g.,
dots between commas would normally be on the baseline, while dots
between binary or relational symols would be raised. However, when symbols such
as \cs{cong} were protected from expansion in moving arguments (so
that they worked in places such as headings) it had the unfortunate
side-effect that the \cs{dots} magic stopped working for them. This
has now been corrected.
%
\githubissue{1265}



%\section{Changes to packages in the \pkg{graphics} category}

Expand Down
51 changes: 45 additions & 6 deletions required/amsmath/amsmath.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Bug reports can be opened (category \texttt{#1}) at\\%
% \end{macrocode}
%
% \begin{macrocode}
\ProvidesPackage{amsmath}[2024/07/01 v2.17q AMS math features]
\ProvidesPackage{amsmath}[2024/07/01 v2.17r AMS math features]
% \end{macrocode}
%
% \section{Catcode defenses}
Expand Down Expand Up @@ -1087,6 +1087,14 @@ Foreign command \@backslashchar#1;\MessageBreak
\ifx9#2 \@xp\@xp\@xp\zap@to@space\fi}}}
\def\zap@to@space#1 {}
% \end{macrocode}
%
% \changes{v2.17r}{2024/06/29}{macro added to strip \cs{protected} (gh/1265)}
% \begin{macrocode}
{\uccode`9=`\p %
\uppercase{\gdef\stripprotected@#1#2#3\relax{%
\ifx9#2 \@xp\@xp\@xp\zap@to@space\fi}}}
% \end{macrocode}
%
% \begin{macrocode}
\def\keybin@{\gtest@true
\ifx\@let@token+\else\ifx\@let@token=\else
Expand Down Expand Up @@ -1139,15 +1147,37 @@ Foreign command \@backslashchar#1;\MessageBreak
\gdef\thedots@{\dotsb@}%
\else
% \end{macrocode}
% \changes{v2.15d}{2016/06/28}{Add space token to prevent runaway argument error}
% \begin{macrocode}
\xdef\meaning@{\meaning\@let@token. .........}%
% \end{macrocode}
% In previous versions \verb|\long| macros were not seen by the lokkahead.
% In case \cs{\@let@token} is a robust \LaTeXe{} command, i.e.,
% expands to \cs{protect}
% \verb*=\somename =, we save the \cs{meaning} of
% \verb*=\somename = in \cs{meaning@} (possibly followed by some dots that have
% not been consumed as arguments during the expansion).
% Otherwise, we save the
% \cs{meaning} of \cs{@let@token} in \cs{meaning@}. The dots at the end
% as well as the space are
% used in later parts of the checking (this could probably be cleaned up a bit).
% \changes{v2.15d}{2016/06/28}{Add space token to prevent runaway
% argument error}
% \changes{v2.17r}{2024/06/29}{Drop \cs{protect} if present (gh/1265)}
% \begin{macrocode}
\begingroup
\def\protect{\protect}% % make it a quark
\xdef\meaning@{\@xp\stripprotect@\@let@token.........\stripprotect@. .........}%
\endgroup
% \end{macrocode}
% In previous versions \verb|\long| macros were not seen by the lookahead.
% That was bad as this file uses \verb|\(re)newcommand| for \verb|\implies| etc.
% \begin{macrocode}
\xdef\meaning@@{\@xp\striplong@\meaning@\relax\meaning@}%
% \end{macrocode}
% Until now \cs{protected} macros also stopped the lookahead, e.g.,
% $\cong$ wasn't recognized correctly for that reason.
%
% \changes{v2.17r}{2024/06/29}{Handle \cs{protected} macros in
% lookahead for dots (gh/1265)}
% \begin{macrocode}
\xdef\meaning@@{\@xp\stripprotected@\meaning@@\relax\meaning@@}%
% \end{macrocode}
% \begin{macrocode}
\@xp\math@\meaning@\math@
\ifgtest@ % if \mathxxx test
Expand Down Expand Up @@ -1208,6 +1238,15 @@ Foreign command \@backslashchar#1;\MessageBreak
\thedots@}
% \end{macrocode}
%
% The helper to generate the meaning of \cs{\@let@token}, or of its
% first-level expansion with \cs{protect} removed.
% \changes{v2.17r}{2024/06/29}{Drop \cs{protect} if present (gh/1265)}
% \begin{macrocode}
\def\stripprotect@#1#2\stripprotect@{\ifx#1\protect
\meaning#2\else \meaning\@let@token \fi}

% \end{macrocode}
%
% The \qc{\=} character is necessary in the two \cs{let} assignments
% in \cs{boldsymboldots@}, because the symbol we are making
% bold might be an \qc{\=} sign.
Expand Down
6 changes: 6 additions & 0 deletions required/amsmath/changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
All changes above are only part of the development branch for the next release.
================================================================================

2024-08-02 Frank Mittelbach <[email protected]>

* amsmath.dtx (section{Ellipsis dots}):
Support special \dots magic in case of robust symbols protected with
\protected or via \DeclareRobustCommand (gh/1265)

#########################
# 2024-06-01 Release
#########################
Expand Down
27 changes: 27 additions & 0 deletions required/amsmath/testfiles/github-1265.lvt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
\documentclass{article}

\input{test2e}

% Any preamble code goes here
\usepackage{amsmath}

\showoutput

\newbox\testbox

\begin{document}

% Demonstration of issue here

\START

\savebox\testbox{$\equiv\dots\equiv$}

\box\testbox

\savebox\testbox{$\cong\dots\cong$}

\box\testbox

\END

2 changes: 2 additions & 0 deletions required/amsmath/testfiles/github-1265.tlg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This is a generated file for the LaTeX2e validation system.
Don't change this file in any respect.

0 comments on commit 01a49aa

Please sign in to comment.