From e1741b13d58aee0c386a19017e6d84663db800e5 Mon Sep 17 00:00:00 2001 From: Ulrike Fischer Date: Fri, 31 Jan 2025 19:48:05 +0100 Subject: [PATCH] more sockets, start to move amsmath env --- luamml-patches-amsmath.sty | 70 ++++++++++++++++++++++---------------- luamml.dtx | 28 +++++++++++++-- 2 files changed, 65 insertions(+), 33 deletions(-) diff --git a/luamml-patches-amsmath.sty b/luamml-patches-amsmath.sty index 9a8ccee..5adedcd 100644 --- a/luamml-patches-amsmath.sty +++ b/luamml-patches-amsmath.sty @@ -40,7 +40,7 @@ {##} \UseTaggingSocket{math/luamml/save/nNn}{ {} \displaystyle {mtd}} $ - \UseTaggingSocket{math/luamml/mtable/finalizecol} + \UseTaggingSocket{math/luamml/mtable/finalizecol}{last} \tabskip \z@skip & \column@plus $ @@ -52,7 +52,7 @@ } \UseTaggingSocket{math/luamml/save/nNn}{ {} \displaystyle {mtd}} $ - \UseTaggingSocket{math/luamml/mtable/finalizecol} + \UseTaggingSocket{math/luamml/mtable/finalizecol}{last} \hfil \tabskip\alignsep@ \crcr @@ -79,7 +79,7 @@ ## \UseTaggingSocket{math/luamml/save/nNn}{ {} \displaystyle {mtd}} $ - \UseTaggingSocket{math/luamml/mtable/finalizecol} + \UseTaggingSocket{math/luamml/mtable/finalizecol}{last} \hfil \crcr \ams@return@opt@arg @@ -117,7 +117,7 @@ \UseTaggingSocket{math/luamml/save/nNn}{ {} \displaystyle {mtd}} $ } - \__luamml_amsmath_add_box_to_row: + \UseTaggingSocket{math/luamml/mtable/finalizecol}{box} \calc@shift@gather \set@gather@field \tabskip\@centering @@ -132,7 +132,7 @@ { \place@tag@gather } { \place@tag@gather - \__luamml_amsmath_set_tag: + \UseTaggingSocket{math/luamml/mtable/tag/set} } \tabskip \iftagsleft@ \gdisplaywidth@ @@ -150,15 +150,18 @@ { \luamml_ignore: } { \__luamml_amsmath_original_gmeasure:n {#1} } } - -\cs_set:Npn \endgather { - \math@cr - \black@ \totwidth@ - \UseExpandableTaggingSocket{math/luamml/mtable/finalize} {gather} - \egroup - $$ - \ignorespacesafterend -} +\IfPackageAtLeastTF{latex-lab-testphase-math}{2025-01-24} + {} + { \PackageInfo{luamml}{patching~\string\endgather} + \cs_set:Npn \endgather { + \math@cr + \black@ \totwidth@ + \UseExpandableTaggingSocket{math/luamml/mtable/finalize} {gather} + \egroup + $$ + \ignorespacesafterend + } + } % align and friends \cs_set:Npn \align@preamble { @@ -181,7 +184,7 @@ \ifmeasuring@ \savefieldlength@ \else - \__luamml_amsmath_add_box_to_row: + \UseTaggingSocket{math/luamml/mtable/finalizecol}{box} \fi \set@field \tabskip\z@skip @@ -205,7 +208,7 @@ \ifmeasuring@ \savefieldlength@ \else - \__luamml_amsmath_add_box_to_row: + \UseTaggingSocket{math/luamml/mtable/finalizecol}{box} \fi \set@field \hfil @@ -230,7 +233,7 @@ { \make@display@tag } } \place@tag - \__luamml_amsmath_set_tag: + \UseTaggingSocket{math/luamml/mtable/tag/set} \fi \ifst@rred \else @@ -240,14 +243,21 @@ \cr } -\cs_set:Npn \maketag@@@ #1 { - \hbox { - \m@th - \normalfont - #1 - \__luamml_amsmath_save_tag: - } -} +% This was lost anyway, as the latex-lab code overwrites +% the definition again. +\IfPackageAtLeastTF{latex-lab-testphase-math}{2025-01-24} + {} + { \PackageInfo{luamml}{patching~\string\maketag@@@} + \cs_set:Npn \maketag@@@ #1 + { + \hbox { + \m@th + \normalfont + #1 + \UseTaggingSocket{math/luamml/mtable/tag/save} + } + } + } \cs_set:Npn \endalign { \math@cr @@ -294,14 +304,14 @@ \cs_set:Npn \endmultline@math { \luamml_save:nNn {} \displaystyle {mtd} $ - \UseTaggingSocket{math/luamml/mtable/finalizecol} + \UseTaggingSocket{math/luamml/mtable/finalizecol}{last} } \cs_set:Npn \rendmultline@ { \iftag@ \luamml_save:nNn {} \displaystyle {mtd} $ - \UseTaggingSocket{math/luamml/mtable/finalizecol} + \UseTaggingSocket{math/luamml/mtable/finalizecol}{last} \let \endmultline@math \relax \ifshifttag@ \hskip \multlinegap @@ -322,7 +332,7 @@ \hskip \multlinetaggap \make@display@tag \fi - \__luamml_amsmath_set_tag: + \UseTaggingSocket{math/luamml/mtable/tag/set} \else \hskip \multlinegap \fi @@ -363,7 +373,7 @@ % No \scriptsize here since we want to add the mstyle nodes \UseTaggingSocket{math/luamml/save/nn}{ {} {mtd}} $ - \UseTaggingSocket{math/luamml/mtable/finalizecol} + \UseTaggingSocket{math/luamml/mtable/finalizecol}{last} \hfil && \thickspace @@ -375,7 +385,7 @@ % No \scriptsize here since we want to add the mstyle nodes \UseTaggingSocket{math/luamml/save/nn}{ {} {mtd}} $ - \UseTaggingSocket{math/luamml/mtable/finalizecol} + \UseTaggingSocket{math/luamml/mtable/finalizecol}{last} \hfil \crcr }{% diff --git a/luamml.dtx b/luamml.dtx index 5dde284..b0ae894 100644 --- a/luamml.dtx +++ b/luamml.dtx @@ -650,14 +650,14 @@ % \begin{macrocode} \str_if_exist:cF { l__socket_tagsupport/math/luamml/mtable/finalizecol_plug_str } { - \NewSocket{tagsupport/math/luamml/mtable/finalizecol}{0} + \NewSocket{tagsupport/math/luamml/mtable/finalizecol}{1} } % \end{macrocode} % \begin{macrocode} %<*luatex> \NewSocketPlug{tagsupport/math/luamml/mtable/finalizecol}{luamml} { - \__luamml_amsmath_add_last_to_row: + \use:c{__luamml_amsmath_add_#1_to_row:} } \AssignSocketPlug{tagsupport/math/luamml/mtable/finalizecol}{luamml} @@ -685,7 +685,29 @@ % % \end{macrocode} % -% +% These sockets save and set tags and labels in alignments. +% \begin{macrocode} +\str_if_exist:cF { l__socket_tagsupport/math/luamml/mtable/tag/save_plug_str } + { + \NewSocket{tagsupport/math/luamml/mtable/tag/save}{0} + \NewSocket{tagsupport/math/luamml/mtable/tag/set}{0} + } +% \end{macrocode} +% \begin{macrocode} +%<*luatex> +\NewSocketPlug{tagsupport/math/luamml/mtable/tag/save}{luamml} + { + \__luamml_amsmath_save_tag: + } +\AssignSocketPlug{tagsupport/math/luamml/mtable/tag/save}{luamml} +\NewSocketPlug{tagsupport/math/luamml/mtable/tag/set}{luamml} + { + \__luamml_amsmath_set_tag: + } +\AssignSocketPlug{tagsupport/math/luamml/mtable/tag/set}{luamml} + +% +% \end{macrocode} % \subsubsection{Horizontal boxes} % This socket annotates an \cs{hbox} inside box commands used in math. % We test for the socket until the release 2025-06-01.