summaryrefslogtreecommitdiff
path: root/macros/latex-dev/required/tools/array.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex-dev/required/tools/array.dtx')
-rw-r--r--macros/latex-dev/required/tools/array.dtx105
1 files changed, 84 insertions, 21 deletions
diff --git a/macros/latex-dev/required/tools/array.dtx b/macros/latex-dev/required/tools/array.dtx
index f4c8ab28d8..74c78d0273 100644
--- a/macros/latex-dev/required/tools/array.dtx
+++ b/macros/latex-dev/required/tools/array.dtx
@@ -1,6 +1,6 @@
% \iffalse meta-comment
%
-% Copyright (C) 1993-2024
+% Copyright (C) 1993-2025
%
% The LaTeX Project and any individual authors listed elsewhere
% in this file.
@@ -39,7 +39,7 @@
% \begin{macrocode}
%<+package>\NeedsTeXFormat{LaTeX2e}[2024/06/01]
%<+package>\ProvidesPackage{array}
-%<+package> [2024/10/17 v2.6g Tabular extension package (FMi)]
+%<+package> [2025/02/18 v2.6h Tabular extension package (FMi)]
%
% \fi
%
@@ -1862,7 +1862,19 @@ Bug reports can be opened (category \texttt{#1}) at\\%
% \end{macrocode}
% \end{macro}
%
-%
+% \changes{v2.6h}{2024/12/02}{Add tagging sockets for luamml support}
+% Until the sockets are in the release we test for existence
+% and declare them
+% \begin{macrocode}
+\str_if_exist:cF { l__socket_tagsupport/math/luamml/array/save_plug_str }
+ {
+ \NewSocket{tagsupport/math/luamml/array/save}{0}
+ \NewSocket{tagsupport/math/luamml/array/finalize}{0}
+ \NewSocket{tagsupport/math/luamml/array/initcol}{0}
+ \NewSocket{tagsupport/math/luamml/array/finalizecol}{1}
+ \AssignSocketPlug{tagsupport/math/luamml/array/finalizecol}{noop}
+ }
+% \end{macrocode}
% \begin{macro}{\@classz}
% If the character class of the last \textsf{token} is $0$ we have
% \texttt{c}, \texttt{l}, \texttt{r} or an argument of \texttt{m},
@@ -1918,7 +1930,7 @@ Bug reports can be opened (category \texttt{#1}) at\\%
% Now we insert the contents of the two \textsf{token} registers
% and the symbol
% for the column entry (i.e.\ =#= or
-% more precise =\@sharp=) using =\insert@column=.
+% more precise =\@sharp=) using =\insert@column=.
% \begin{macrocode}
\insert@column
% \end{macrocode}
@@ -1927,7 +1939,8 @@ Bug reports can be opened (category \texttt{#1}) at\\%
% The strut to enforce a regular row height is placed between the two.
% \changes{v2.4e}{2016/10/07}{Fixing SX68732}
% \begin{macrocode}
- \d@llarend \do@row@strut \hfil \or
+ \d@llarend
+ \do@row@strut \hfil \or
% \end{macrocode}
% The templates for \texttt{l} and \texttt{r} (i.e.\ =\@chnum= $1$
% or $2$) are generated the same way. Since one =\hfil= is
@@ -1944,8 +1957,10 @@ Bug reports can be opened (category \texttt{#1}) at\\%
% {Change both \cs{kern}\cs{z@} to \cs{hskip}1sp for latex/2160}
% \changes{v2.4e}{2016/10/07}{Fixing SX68732}
% \begin{macrocode}
- \hskip1sp\d@llarbegin \insert@column \d@llarend \do@row@strut \hfil \or
- \hfil\hskip1sp\d@llarbegin \insert@column \d@llarend \do@row@strut \or
+ \hskip1sp\d@llarbegin\insert@column\d@llarend
+ \do@row@strut \hfil \or
+ \hfil\hskip1sp\d@llarbegin\insert@column\d@llarend
+ \do@row@strut \or
% \end{macrocode}
% The templates for \texttt{p}, \texttt{m} and \texttt{b} mainly
% consist of a \textsf{box}. In case of \texttt{m} it is generated
@@ -2242,7 +2257,7 @@ Bug reports can be opened (category \texttt{#1}) at\\%
%
%
%
-% \begin{macro}{\@startpbox}
+% \begin{macro}{\@startpbox,\@startpbox@action}
% In =\@classz= the macro =\@startpbox= is used.
% The width of the \textsf{parbox} is passed as an argument.
% =\vcenter=, =\vtop= or =\vbox= are already in the
@@ -2286,6 +2301,19 @@ Bug reports can be opened (category \texttt{#1}) at\\%
\everypar{}}%
}
% \end{macrocode}
+%
+% \changes{v2.6h}{2024/12/17}{New \cs{@startpbox@action} to do the real work
+% after the preamble is built (gh/1585)}
+% Starting with 2.6h, \cs{@startpbox} is used only during the
+% built-up of the preamble and then changed to \cs{@startpbox@action}
+% which does the real work. For an explanation of this code see
+% the documentation in \cs{@mkpream}. We keep the \cs{@startpbox}
+% definition on top-level in case there are tabular packages that
+% built the preamble differently and expect that it contains
+% \cs{@startpbox} (\pkg{longtable} at the moment).
+% \begin{macrocode}
+\let\@startpbox@action\@startpbox
+% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@endpbox}
@@ -2817,9 +2845,23 @@ Bug reports can be opened (category \texttt{#1}) at\\%
% Our new definition of =\array= then reads:
% \changes{v2.0d}{1990/08/20}{`d@llar local to preamble.}
% \changes{v2.4d}{2016/10/06}{\cs{@halignto} set locally (pr/4488)}
+% In math mode we additionally add also the tagging sockets for luamml.
+% \changes{v2.6h}{2024/12/02}{Add tagging sockets for luamml support}.
+% The =math/luamml/array/finalizecol= takes as argument a number (0, 1, 2)
+% that should represent the alignment (c,l,r).
+% TODO: instead of =\the\@chnum= a proper tl should be used.
+% TODO: the w and W columntypes must be redefined - currently they
+% insert stray mtext columns.
% \begin{macrocode}
\def\array{\col@sep\arraycolsep
- \def\d@llarbegin{$}\let\d@llarend\d@llarbegin\def\@halignto{}%
+ \def\d@llarbegin{$\tag_socket_use:n { math/luamml/array/initcol }}
+ \def\d@llarend
+ {
+ \tag_socket_use:nn { math/luamml/save/nn }{{}{mtd}}
+ $
+ \tag_socket_use:nn { math/luamml/array/finalizecol}{\the\@chnum}
+ }
+ \def\@halignto{}%
% \end{macrocode}
% Since there might be an optional argument we call another
% macro which is also used by the other environments.
@@ -2868,6 +2910,9 @@ Bug reports can be opened (category \texttt{#1}) at\\%
% \begin{macro}{\@tabular}
% The rest of the job is carried out by the =\@tabular= macro:
% \begin{macrocode}
+\providecommand\MathCollectTrue{}
+\providecommand\MathCollectFalse{}
+\providecommand\@kernel@tabular@init{}
\def\@tabular{%
% \end{macrocode}
% First of all we have to make sure that we start out in
@@ -2887,10 +2932,17 @@ Bug reports can be opened (category \texttt{#1}) at\\%
% insert a =$= and then assign the correct values to =\col@sep= and
% =\d@llar...=.
% \changes{v2.0d}{1990/08/20}{`d@llar local to preamble.}
+% \changes{v2.6h}{2025/02/18}{Surround dollar with \cs{MathCollectTrue}/\cs{MathCollectFalse}}%
% \begin{macrocode}
- \hbox \bgroup $\col@sep\tabcolsep \let\d@llarbegin\begingroup
+ \hbox \bgroup
+ \MathCollectFalse$\MathCollectTrue
+ \col@sep\tabcolsep \let\d@llarbegin\begingroup
\let\d@llarend\endgroup
% \end{macrocode}
+% \changes{v2.6h}{2025/02/18}{Add internal kernel hook to switch math collection method}%
+% \begin{macrocode}
+ \@kernel@tabular@init
+% \end{macrocode}
% Now everything \textsf{tabular} specific is done and we are able to
% call the =\@tabarray= macro.
% \begin{macrocode}
@@ -2899,10 +2951,6 @@ Bug reports can be opened (category \texttt{#1}) at\\%
% \end{macro}
%
% \begin{macro}{\endarray}
-% \emph{The code below has been replaced long time ago by an
-% extended version further down but the code and its documentation
-% was left here for reference. It is now commented out to avoid
-% confusion.}
%
% When the processing of \textsf{array} is finished we have to
% close the =\halign=
@@ -2914,10 +2962,13 @@ Bug reports can be opened (category \texttt{#1}) at\\%
% To handle cell indexes, we do not use \cs{crcr} but a variant
% that also handles missing cells as necessary.
% \changes{v2.6a}{2023/12/11}{Support for tagged PDF}
+% \changes{v2.6h}{2024/12/02}{Add tagging sockets for luamml support}%
% \begin{macrocode}
\def\endarray {
- \tbl_crcr:n{endarray} \egroup
- \UseTaggingSocket{tbl/finalize}
+ \tbl_crcr:n{endarray}
+ \tag_socket_use_expandable:n { math/luamml/array/save }
+ \egroup
+ \tag_socket_use:n { tbl/finalize }
% \end{macrocode}
%
% If tables are nested into another then it is necessary to
@@ -2937,6 +2988,7 @@ Bug reports can be opened (category \texttt{#1}) at\\%
%
% \begin{macrocode}
\egroup
+ \tag_socket_use:n { math/luamml/array/finalize }
\@arrayright \gdef\@preamble{}%
}
% \end{macrocode}
@@ -3277,20 +3329,31 @@ Bug reports can be opened (category \texttt{#1}) at\\%
\let\@sharp\relax
% \end{macrocode}
%
-% \changes{v2.4j}{2018/11/13}{Do not expand argument of
-% \cs{@startpbox} while building the tabular preamble (sx/459285)}
% The "\@startpbox" (which is called for "p", "m" or "b" columns)
% receives a user supplied argument: the width of the
% paragraph-column. Normally that is something harmless like a length or a
% simple length expression, but with the calc package involved it
% could break under an "\edef" operation, which is how the preamble
% is constructed. We now make use of "\unexpanded" here to prevent that. The
-% "\expandafter" gymnastics is necessary to expand the "#1" at least
+% "\expandafter" gymnastics are necessary to expand the "#1" exactly
% once (since it will get "\@nextchar" as its value and need its
-% content!
+% content). However, once added to the preamble, no further
+% expansion should happen if the preamble is extended. Therefore we
+% change from \cs{@startpbox} to \cs{@startpbox@action}. The latter
+% then has a trivial definition and expands (including its
+% argument) to itself while the preamble is being built. Outside of this
+% preamble build up \cs{@startpbox@action} does the actual work.
+%
+% \changes{v2.4j}{2018/11/13}{Do not expand argument of
+% \cs{@startpbox} while building the tabular preamble (sx/459285)}
+% \changes{v2.6h}{2024/12/17}{Expand argument of \cs{@startpbox}
+% exactly once while the preamble is being built, and use
+% \cs{@startpbox@action} later to do the real work (gh/1585)}
% \begin{macrocode}
\def\@startpbox##1{\unexpanded\expandafter{\expandafter
- \@startpbox\expandafter{##1}}}\let\@endpbox\relax
+ \@startpbox@action\expandafter{##1}}}%
+ \def\@startpbox@action##1{\unexpanded{\@startpbox@action{##1}}}%
+ \let\@endpbox\relax
\let\do@row@strut\relax
\let\ar@align@mcell\relax
% \end{macrocode}