Skip to content

Commit

Permalink
move gather, maketag@@@ into amsmath file
Browse files Browse the repository at this point in the history
  • Loading branch information
u-fischer committed Jan 31, 2025
1 parent 3b519ca commit 0a20867
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 49 deletions.
25 changes: 22 additions & 3 deletions base/lttagging.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -643,12 +643,14 @@
%
% \begin{socketdecl}{tagsupport/math/luamml/mtable/finalizecol}
% This sockets is used at the end of alignment cells and adds them to
% the row.
% the row. The argument passes a type like \texttt{last} or \texttt{box}.
% \begin{macrocode}
\NewSocket{tagsupport/math/luamml/mtable/finalizecol}{0}
\NewSocket{tagsupport/math/luamml/mtable/finalizecol}{1}
\AssignSocketPlug{tagsupport/math/luamml/mtable/finalizecol}{noop}
% \end{macrocode}
% \end{socketdecl}

%
%
% \begin{socketdecl}{tagsupport/math/luamml/mtable/finalize}
% This sockets is used at the end of alignment environment to finalize the
% mtable code. It should be used normally with \cs{UseExpandableTaggingSocket}.
Expand All @@ -658,6 +660,23 @@
% \end{macrocode}
% \end{socketdecl}
%
% \begin{socketdecl}{tagsupport/math/luamml/mtable/tag/save}
% This socket is used to save a tag for later use.
% has been save before.
% \begin{macrocode}
\NewSocket{tagsupport/math/luamml/mtable/tag/save}{0}
% \end{macrocode}
% \end{socketdecl}
%
%
% \begin{socketdecl}{tagsupport/math/luamml/mtable/tag/set}
% This socket should be used when a tag is placed. It inserts a tag that
% has been save before.
% \begin{macrocode}
\NewSocket{tagsupport/math/luamml/mtable/tag/set}{0}
% \end{macrocode}
% \end{socketdecl}
%
% \paragraph{mbox socket}
%
% \begin{socketdecl}{tagsupport/math/luamml/hbox}
Expand Down
42 changes: 41 additions & 1 deletion required/latex-lab/latex-lab-amsmath.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
% \subsection{File declaration}
% \begin{macrocode}
\ProvidesFile{latex-lab-amsmath.ltx}
[2024-12-03 v0.1d amsmath adaptions]
[2025-01-31 v0.1e amsmath adaptions]
% \end{macrocode}
% \subsection{Tagpdf support}
% To make the code independent from tagging being loaded and active
Expand All @@ -80,6 +80,46 @@
\ExplSyntaxOn
% \end{macrocode}
%
% \subsection{Display environments}
%
% \changes{0.1e}{2025-01-31}{moved redefinitions from latex-lab-math and luamml into this file}
%
% \begin{macrocode}
\AddToHook{package/amsmath/after}
{
% \end{macrocode}
% Tag.
% TODO: tagging is unclear and must be corrected.
% \begin{macrocode}
\@namedef{maketag @ @ @} #1
{%
\ifmeasuring@
\hbox{\m@th\normalfont#1}%
\else
\tagmcend \tagstructbegin{tag=Lbl}%
\tagmcbegin{tag=Lbl}%
\hbox{\m@th\normalfont#1
\UseTaggingSocket{math/luamml/mtable/tag/save}
}%
\tagmcend \tagstructend \tagmcbegin{}%
\fi
}
% \end{macrocode}
% the gather environment
% \begin{macrocode}
\def\endgather
{
\math@cr
\black@ \totwidth@
\UseExpandableTaggingSocket{math/luamml/mtable/finalize} {gather}
\egroup
$$
\ignorespacesafterend
}
\math_register_halign_env:nn {gather}{}
}
% \end{macrocode}
%
% \subsection{\cs{intertext}}
% The \cs{intertext} command errors with active tagging as it is processed twice
% which leads to duplicated structures.
Expand Down
12 changes: 0 additions & 12 deletions required/latex-lab/latex-lab-math.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -2797,25 +2797,13 @@
\math_register_halign_env:nn {alignat*}{}
\math_register_halign_env:nn {flalign}{}
\math_register_halign_env:nn {flalign*}{}
\math_register_halign_env:nn {gather}{}
\math_register_halign_env:nn {gather*}{}
\math_register_halign_env:nn {multline}{}
\math_register_halign_env:nn {multline*}{}
\math_register_halign_env:nn {xalignat}{}
\math_register_halign_env:nn {xalignat*}{}
\math_register_halign_env:nn {xxalignat}{}
%
\@namedef{maketag @ @ @} #1{%
% \typeout{--->maketag @ @ @}
\ifmeasuring@
\hbox{\m@th\normalfont#1}%
\else
\tagmcend \tagstructbegin{tag=Lbl}%
\tagmcbegin{tag=Lbl}%
\hbox{\m@th\normalfont#1}%
\tagmcend \tagstructend \tagmcbegin{}%
\fi
}
% \end{macrocode}
%
%
Expand Down
70 changes: 40 additions & 30 deletions texmf/tex/lualatex/luamml/luamml-patches-amsmath.sty
Original file line number Diff line number Diff line change
Expand Up @@ -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
$
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -132,7 +132,7 @@
{ \place@tag@gather }
{
\place@tag@gather
\__luamml_amsmath_set_tag:
\UseTaggingSocket{math/luamml/mtable/tag/set}
}
\tabskip \iftagsleft@
\gdisplaywidth@
Expand All @@ -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 {
Expand All @@ -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
Expand All @@ -205,7 +208,7 @@
\ifmeasuring@
\savefieldlength@
\else
\__luamml_amsmath_add_box_to_row:
\UseTaggingSocket{math/luamml/mtable/finalizecol}{box}
\fi
\set@field
\hfil
Expand All @@ -230,7 +233,7 @@
{ \make@display@tag }
}
\place@tag
\__luamml_amsmath_set_tag:
\UseTaggingSocket{math/luamml/mtable/tag/set}
\fi
\ifst@rred
\else
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -322,7 +332,7 @@
\hskip \multlinetaggap
\make@display@tag
\fi
\__luamml_amsmath_set_tag:
\UseTaggingSocket{math/luamml/mtable/tag/set}
\else
\hskip \multlinegap
\fi
Expand Down Expand Up @@ -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
Expand All @@ -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
}{%
Expand Down
7 changes: 6 additions & 1 deletion texmf/tex/lualatex/luamml/luamml-pdf.sty
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,18 @@
}
\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}
}
\str_if_exist:cF { l__socket_tagsupport/math/luamml/mtable/finalize_plug_str }
{
\NewSocket{tagsupport/math/luamml/mtable/finalize}{1}
\AssignSocketPlug{tagsupport/math/luamml/mtable/finalize}{noop}
}
\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}
}
\str_if_exist:cF { l__socket_tagsupport/math/luamml/hbox_plug_str }
{
\NewSocket{tagsupport/math/luamml/hbox}{2}
Expand Down
20 changes: 18 additions & 2 deletions texmf/tex/lualatex/luamml/luamml.sty
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,11 @@
\AssignSocketPlug{tagsupport/math/luamml/array/finalizecol}{luamml}
\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}
}
\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}

Expand All @@ -193,6 +193,22 @@
\__luamml_amsmath_finalize_table:n {#1}
}
\AssignSocketPlug{tagsupport/math/luamml/mtable/finalize}{luamml}
\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}
}
\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}

\str_if_exist:cF { l__socket_tagsupport/math/luamml/hbox_plug_str }
{
\NewSocket{tagsupport/math/luamml/hbox}{2}
Expand Down

0 comments on commit 0a20867

Please sign in to comment.