[latex3-commits] [latex3/latex2e] array: move \endarry ; add \ar at crcr (310d126a)

github at latex-project.org github at latex-project.org
Thu Dec 7 00:16:37 CET 2023


Repository : https://github.com/latex3/latex2e
On branch  : array
Link       : https://github.com/latex3/latex2e/commit/310d126abdc804df9ba6a9d07a8cbcb40b5f9229

>---------------------------------------------------------------

commit 310d126abdc804df9ba6a9d07a8cbcb40b5f9229
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date:   Thu Dec 7 00:16:37 2023 +0100

    move \endarry ; add \ar at crcr


>---------------------------------------------------------------

310d126abdc804df9ba6a9d07a8cbcb40b5f9229
 required/latex-lab/latex-lab-table.dtx | 53 --------------------------
 required/tools/array.dtx               | 68 ++++++++++++++++++++++++++++++++--
 2 files changed, 64 insertions(+), 57 deletions(-)

diff --git a/required/latex-lab/latex-lab-table.dtx b/required/latex-lab/latex-lab-table.dtx
index a25fbca6..ce005588 100644
--- a/required/latex-lab/latex-lab-table.dtx
+++ b/required/latex-lab/latex-lab-table.dtx
@@ -1049,59 +1049,6 @@
 %
 %
 %
-% \begin{macro}{\endarray}
-%    If tables are nested into another then  it is necessary to
-%    restore information about the cell the inner table started
-%    in. Otherwise, \cs{g_@@_row_int}, \cs{g_@@_col_int}, and
-%    \cs{g_@@_span_tl} reflect the status in the outer table as they
-%    are globally manipulated. We restore in all cases even if we are
-%    not in a nesting situation as that makes the code simpler (and
-%    probably faster).
-%
-%    \cs{endtabular} and \cs{endtabular*} inherit from \cs{endarray}
-%    so we only need to change that. \texttt{tabularx} is handled
-%    below.
-  %    \begin{macrocode}
-
-\def\ar at crcr #1 {  
-    \int_compare:nNnT \g_@@_col_int > 0
-        {
-          \UseSocket{tbl/celldata/missingcount} {#1}
-          \cr
-        }
-}
-
-
-\def\endarray{
-  \ar at crcr{endarray} \egroup
-  \UseTaggingSocket{tbl/finalize}
-%    \end{macrocode}
-%    
-%    \begin{macrocode}
-  \int_gset:Nn \g_@@_col_int { \l_@@_saved_col_tl }
-  \int_gset:Nn \g_@@_row_int { \l_@@_saved_row_tl }
-  \tl_gset_eq:NN \g_@@_span_tl \l_@@_saved_span_tl
-  \tl_gset_eq:NN \g_@@_table_cols_tl   \l_@@_saved_table_cols_tl
-  \typeout{==>~ restored~cell~data:~
-                \int_use:N \g_@@_row_int,
-                \int_use:N \g_@@_col_int,
-                \l_@@_saved_span_tl \space
-                (
-                \int_compare:nNnTF \g_@@_table_cols_tl = 0
-                    { outer~ level }
-                    { max:~ \g_@@_table_cols_tl }
-                )
-          }
-%    \end{macrocode}
-%    
-%    \begin{macrocode}
-  \egroup
-  \@arrayright \gdef\@preamble{}%
-}
-%    \end{macrocode}
-% \end{macro}
-%
-%
 %
 %
 %
diff --git a/required/tools/array.dtx b/required/tools/array.dtx
index 9aaeadf4..17dec3a7 100644
--- a/required/tools/array.dtx
+++ b/required/tools/array.dtx
@@ -2856,10 +2856,71 @@ Bug reports can be opened (category \texttt{#1}) at\\%
 %    =\@preamble=
 %    because its replacement text isn't longer needed.
 %    \begin{macrocode}
-%\def\endarray{\crcr \egroup \egroup \gdef\@preamble{}}
+\def\endarray {
+  \ar at crcr{endarray} \egroup
+  \UseTaggingSocket{tbl/finalize}
+%    \end{macrocode}
+%    
+%    If tables are nested into another then  it is necessary to
+%    restore information about the cell the inner table started
+%    in. Otherwise, \cs{g_@@_row_int}, \cs{g_@@_col_int}, and
+%    \cs{g_@@_span_tl} reflect the status in the outer table as they
+%    are globally manipulated. We restore in all cases even if we are
+%    not in a nesting situation as that makes the code simpler (and
+%    probably faster).
+%
+%    \cs{endtabular} and \cs{endtabular*} inherit from \cs{endarray}
+%    so we only need to change that. \texttt{tabularx} uses a similar method.
+%    \begin{macrocode}
+  \int_gset:Nn \g_@@_col_int { \l_@@_saved_col_tl }
+  \int_gset:Nn \g_@@_row_int { \l_@@_saved_row_tl }
+  \tl_gset_eq:NN \g_@@_span_tl \l_@@_saved_span_tl
+  \tl_gset_eq:NN \g_@@_table_cols_tl   \l_@@_saved_table_cols_tl
+  \typeout{==>~ restored~cell~data:~
+                \int_use:N \g_@@_row_int,
+                \int_use:N \g_@@_col_int,
+                \l_@@_saved_span_tl \space
+                (
+                \int_compare:nNnTF \g_@@_table_cols_tl = 0
+                    { outer~ level }
+                    { max:~ \g_@@_table_cols_tl }
+                )
+          }
+%    \end{macrocode}
+%    
+%    \begin{macrocode}
+  \egroup
+  \@arrayright \gdef\@preamble{}%
+}
 %    \end{macrocode}
 % \end{macro}
 %
+%
+%
+%  \begin{macro}{\ar at crcr}
+%    This macro is used instead of the usual \cs{crcr} at the end of a
+%    table. It is deliberately defined without protection because it
+%    may get expanded by the scanning mechanism of low-level \TeX{}
+%    after a final \cs{cr} (aka \verb=\\=) in the table. In that case
+%    it shouldn't stop the expansion and the conditional inside will
+%    be false this it just vanishes without doing anything. If there
+%    are missing cells (in which case we also haven't see \cs{cr} yet)
+%    the socket \texttt{tbl/celldata/missingcount} is executed and
+%    then the row is finished with a final \cs{cr}.
+%    \begin{macrocode}
+\def\ar at crcr #1 {  
+    \int_compare:nNnT \g_@@_col_int > 0
+        {
+          \UseSocket{tbl/celldata/missingcount} {#1}
+          \cr
+        }
+}
+%    \end{macrocode}
+%  \end{macro}
+%
+%
+%
+%
 % \begin{macro}{\endtabular}
 % \begin{macro}{\endtabular*}
 %    To end a \textsf{tabular} or \textsf{tabular$*$} environment we
@@ -3331,13 +3392,12 @@ Bug reports can be opened (category \texttt{#1}) at\\%
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\endarray}
+% \begin{macro}{\@arrrayleft}
 % \begin{macro}{\@arrayright}
 %    We have to declare the hook we put into "\@array" above.
-%    A similar hook `"\@arrayright"' will be inserted into the
+%    A similar hook \cs{@arrayright} will be inserted into the
 %    "\endarray" to gain control. Both defaults to empty.
 %    \begin{macrocode}
-\def\endarray{\crcr \egroup \egroup \@arrayright \gdef\@preamble{}}
 \let\@arrayleft\@empty
 \let\@arrayright\@empty
 %    \end{macrocode}





More information about the latex3-commits mailing list.