texlive[68870] Master/texmf-dist: nicematrix (16nov23)

commits+karl at tug.org commits+karl at tug.org
Thu Nov 16 22:01:12 CET 2023


Revision: 68870
          https://tug.org/svn/texlive?view=revision&revision=68870
Author:   karl
Date:     2023-11-16 22:01:12 +0100 (Thu, 16 Nov 2023)
Log Message:
-----------
nicematrix (16nov23)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix-code.pdf
    trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf
    trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex
    trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf
    trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix.tex
    trunk/Master/texmf-dist/source/latex/nicematrix/nicematrix-code.dtx
    trunk/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty

Modified: trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix-code.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex	2023-11-16 18:39:12 UTC (rev 68869)
+++ trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex	2023-11-16 21:01:12 UTC (rev 68870)
@@ -1875,9 +1875,8 @@
 \index{arraycolor@\texttt{\textbackslash arraycolor} (commande du \texttt{\textbackslash
   CodeBefore)}}
 
-Les noms de ces commandes sont inspirés des noms des commandes de \pkg{colortbl}.
+Les noms de certaines de ces commandes sont inspirés des noms des commandes de \pkg{colortbl}.
 
-
 \medskip
 Ces commandes ne colorient pas les cases qui se trouvent dans les «coins» si la
 clé |corners| a été utilisée. La description de cette clé a été faite
@@ -2290,6 +2289,56 @@
 \end{NiceTabular}
 \end{scope}
 
+\medskip
+L'exemple précédent utilise les clés |first-row| et |first-col| qui sont
+décrites dans la partie sur les rangées et colonnes «extérieures» (cf.~p.~\pageref{exterior}).
+
+Comme on le voit, \emph{par défaut}, les commandes de coloriage décrites précédemment ne
+s'appliquent pas dans ces rangées et colonnes «extérieures».  
+
+Mais on peut \emph{quand même} colorier dans ces rangées et colonnes en
+donnant aux commandes précédentes les numéros explicites de ces rangées et
+colonnes extérieures.
+
+Dans l'exemple suivant, on demande explicitement le coloriage de la colonne~$0$
+(qui est la «première colonne» et qui existe du fait de la clé |first-col|).
+
+\medskip
+\begin{scope}
+\hfuzz=11cm
+\begin{BVerbatim}[boxwidth=9cm,baseline=c]
+\begin{NiceTabular}{cccccc}[~emphase#corners=NE@,margin,hvlines,first-row,first-col]
+\CodeBefore
+  \rowlistcolors{1}{blue!15, }
+  ~emphase#\columncolor{red!15}{0}@
+\Body
+  & 0 & 1 & 2 & 3 & 4 & 5 & 6 \\
+0 & 1 \\
+1 & 1 & 1 \\
+2 & 1 & 2 & 1 \\
+3 & 1 & 3 & 3 & 1 \\
+4 & 1 & 4 & 6 & 4 & 1 \\
+5 & 1 & 5 & 10 & 10 & 5 & 1 \\
+6 & 1 & 6 & 15 & 20 & 15 & 6 & 1 \\
+\end{NiceTabular}
+\end{BVerbatim}
+\begin{NiceTabular}{ccccccc}[corners=NE,margin,hvlines,first-row,first-col]
+\CodeBefore
+  \rowlistcolors{1}{blue!15, }
+  \columncolor{red!15}{0}
+\Body
+  & 0 & 1 & 2 & 3 & 4 & 5 & 6 \\
+0 & 1 \\
+1 & 1 & 1 \\
+2 & 1 & 2 & 1 \\
+3 & 1 & 3 & 3 & 1 \\
+4 & 1 & 4 & 6 & 4 & 1 \\
+5 & 1 & 5 & 10 & 10 & 5 & 1 \\
+6 & 1 & 6 & 15 & 20 & 15 & 6 & 1 \\
+\end{NiceTabular}
+\end{scope}
+
+
 \bigskip
 On remarquera que ces commandes sont compatibles avec les commandes de
 \pkg{booktabs} (|\toprule|, |\midrule|, |\bottomrule|, etc). Néanmoins,
@@ -2344,7 +2393,7 @@
 \index{S (les colonnes S de \pkg{siunitx})|textit}
 
 \medskip
-On a utilisé le type de colonne |S| de \pkg{siunitx}.
+On a utilisé le type de colonne |S| de \pkg{siunitx} (qu'il faut avoir chargé).
 
 
 \subsection{Outils de coloriage en tableau}

Modified: trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix.tex	2023-11-16 18:39:12 UTC (rev 68869)
+++ trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix.tex	2023-11-16 21:01:12 UTC (rev 68870)
@@ -2227,7 +2227,56 @@
 \end{NiceTabular}
 \end{scope}
 
+\medskip
+The previous example uses the keys |first-row| and |first-col| which are
+described in the chapter concerning the «exterior» rows and columns
+(cf.~p.~\pageref{exterior}). 
 
+As one can see, \emph{by default}, the coloring commands that we have described
+don't apply in those exterior rows and columns.
+
+However, it may still be possible to color in those rows and columns by
+providing explicity the numbers of those rows and columns.
+
+In the following example, we require a color in the column~$0$ (which is the
+«first column» and which exists because the key |first-col| has been used).
+
+\medskip
+\begin{scope}
+\hfuzz=11cm
+\begin{BVerbatim}[boxwidth=9cm,baseline=c]
+\begin{NiceTabular}{cccccc}[~emphase#corners=NE@,margin,hvlines,first-row,first-col]
+\CodeBefore
+  \rowlistcolors{1}{blue!15, }
+  ~emphase#\columncolor{red!15}{0}@
+\Body
+  & 0 & 1 & 2 & 3 & 4 & 5 & 6 \\
+0 & 1 \\
+1 & 1 & 1 \\
+2 & 1 & 2 & 1 \\
+3 & 1 & 3 & 3 & 1 \\
+4 & 1 & 4 & 6 & 4 & 1 \\
+5 & 1 & 5 & 10 & 10 & 5 & 1 \\
+6 & 1 & 6 & 15 & 20 & 15 & 6 & 1 \\
+\end{NiceTabular}
+\end{BVerbatim}
+\begin{NiceTabular}{ccccccc}[corners=NE,margin,hvlines,first-row,first-col]
+\CodeBefore
+  \rowlistcolors{1}{blue!15, }
+  \columncolor{red!15}{0}
+\Body
+  & 0 & 1 & 2 & 3 & 4 & 5 & 6 \\
+0 & 1 \\
+1 & 1 & 1 \\
+2 & 1 & 2 & 1 \\
+3 & 1 & 3 & 3 & 1 \\
+4 & 1 & 4 & 6 & 4 & 1 \\
+5 & 1 & 5 & 10 & 10 & 5 & 1 \\
+6 & 1 & 6 & 15 & 20 & 15 & 6 & 1 \\
+\end{NiceTabular}
+\end{scope}
+
+
 \bigskip
 One should remark that all the previous commands are compatible with the
 commands of \pkg{booktabs} (|\toprule|, |\midrule|, |\bottomrule|, etc).

Modified: trunk/Master/texmf-dist/source/latex/nicematrix/nicematrix-code.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/nicematrix/nicematrix-code.dtx	2023-11-16 18:39:12 UTC (rev 68869)
+++ trunk/Master/texmf-dist/source/latex/nicematrix/nicematrix-code.dtx	2023-11-16 21:01:12 UTC (rev 68870)
@@ -17,8 +17,8 @@
 %
 % \fi
 % \iffalse
-\def\myfileversion{6.25a}
-\def\myfiledate{2023/11/03}
+\def\myfileversion{6.25b}
+\def\myfiledate{2023/11/16}
 %
 %
 %<*batchfile>  
@@ -2294,7 +2294,7 @@
 % array). 
 %    \begin{macrocode}
 \tl_new:N \l_@@_baseline_tl 
-\tl_set:Nn \l_@@_baseline_tl c
+\tl_set:Nn \l_@@_baseline_tl { c }
 %    \end{macrocode}
 % 
 % \bigskip
@@ -3795,6 +3795,7 @@
     \cs_set_eq:NN \multicolumn \@@_multicolumn:nnn
     \hook_gput_code:nnn { env / tabular / begin } { . }
       { \cs_set_eq:NN \multicolumn \@@_old_multicolumn }
+    \@@_revert_colortbl:
 %    \end{macrocode}
 % If there is one or several commands |\tabularnote| in the caption specified
 % by the key |caption| and if that caption has to be composed above the tabular, 
@@ -4027,7 +4028,10 @@
 %    \begin{macrocode}
 \cs_new_protected_nopar:Npn \@@_CodeBefore_Body:w #1 \Body
   {
-    \tl_gput_left:Nn \g_@@_pre_code_before_tl { #1 }
+    \tl_set:Nn \l_tmpa_tl { #1 }
+    \int_compare:nNnT { \char_value_catcode:n { 60 } } = { 13 }
+      { \@@_rescan_for_spanish:N \l_tmpa_tl }
+    \tl_gput_left:NV \g_@@_pre_code_before_tl \l_tmpa_tl
     \bool_set_true:N \l_@@_code_before_bool
 %    \end{macrocode}
 % We go on with |\@@_pre_array:| which will (among other) execute the
@@ -4040,6 +4044,7 @@
 %    \end{macrocode}
 %
 % 
+% 
 % \bigskip
 % \section{The \textbackslash CodeBefore}
 % 
@@ -4156,11 +4161,8 @@
 % \textsc{ascci} 60) and |>| are activated and Tikz is not able to solve the
 % problem (even with the Tikz library \pkg{babel}).
 %    \begin{macrocode}
-        \int_compare:nNnT { \char_value_catcode:n { 60 } } = { 13 }
-          { 
-            \@@_rescan_for_spanish:N \g_@@_pre_code_before_tl
-            \@@_rescan_for_spanish:N \l_@@_code_before_tl 
-          }
+      \int_compare:nNnT { \char_value_catcode:n { 60 } } = { 13 }
+        { \@@_rescan_for_spanish:N \l_@@_code_before_tl }
 %    \end{macrocode}
 % 
 % Here is the |\CodeBefore|. The construction is a bit complicated because
@@ -5951,7 +5953,8 @@
     \multispan { #1 }
     \cs_set_eq:NN \@@_update_max_cell_width: \prg_do_nothing: % added 2023-10-04
     \begingroup
-    \cs_set:Npn \@addamp { \if at firstamp \@firstampfalse \else \@preamerr 5 \fi } 
+    \cs_set:Npn \@addamp 
+      { \legacy_if:nTF { @firstamp } { \@firstampfalse } { \@preamerr 5 } } 
 %    \end{macrocode}
 %
 % \medskip
@@ -7049,6 +7052,7 @@
         \hbox_overlap_right:n
           {
             \skip_horizontal:N \g_@@_width_last_col_dim 
+            \skip_horizontal:N \col at sep % added 2023-11-05
             \bool_if:NT \l_@@_code_before_bool
               { 
                 \pgfsys at markposition 
@@ -9880,6 +9884,47 @@
 % \bigskip
 % \section{The command \textbackslash RowStyle}
 % 
+%
+%  |\g_@@_row_style_tl| may contain several instructions of the form:
+% 
+% \qquad |\@@_if_row_less_than:nn { number } { instructions }|
+%
+% \smallskip
+% Then, |\g_@@_row_style_tl| will be inserted in all the cells of the array (and
+% also in both components of a |\diagbox| in a cell of in a mono-row block). 
+%
+% The test |\@@_if_row_less_then:nn| ensures that the instructions are inserted
+% only if you are in a row which is (still) in the scope of that instructions
+% (which depends on the value of the key |nb-rows| of |\RowStyle|). 
+%
+% That test will be active even in an expandable context because
+% |\@@_if_row_less_then:nn| is \emph{not} protected.
+%
+% |#1| is the first row \emph{after} the scope of the instructions in |#2|
+%    \begin{macrocode}
+\cs_new:Npn \@@_if_row_less_than:nn #1 #2
+  { \int_compare:nNnT { \int_use:N \c at iRow } < { #1 } { #2 } }  
+%    \end{macrocode}
+%
+% \bigskip
+% |\@@_put_in_row_style| will be used several times by |\RowStyle|.
+%    \begin{macrocode}
+\cs_set_protected:Npn \@@_put_in_row_style:n #1
+  {
+    \tl_gput_right:Nx \g_@@_row_style_tl 
+      { 
+%    \end{macrocode}
+% Be careful, |\exp_not:N \@@_if_row_less_than:nn| can't be replaced by a
+% protected version of |\@@_if_row_less_than:nn|.
+%    \begin{macrocode}
+        \exp_not:N 
+        \@@_if_row_less_than:nn  
+          { \int_eval:n { \c at iRow + \l_@@_key_nb_rows_int } } 
+          { \exp_not:n { #1 } }
+      }
+  }
+\cs_generate_variant:Nn \@@_put_in_row_style:n { e }
+%    \end{macrocode}
 % \medskip
 %    \begin{macrocode}
 \keys_define:nn { NiceMatrix / RowStyle }
@@ -9954,21 +9999,21 @@
               }
           }
       }
-    \tl_gput_right:Nn \g_@@_row_style_tl { \ifnum \c at iRow < }
-    \tl_gput_right:Nx \g_@@_row_style_tl 
-      { \int_eval:n { \c at iRow + \l_@@_key_nb_rows_int } } 
-    \tl_gput_right:Nn \g_@@_row_style_tl { #2 }
+    \@@_put_in_row_style:n { \exp_not:n { #2 } }
 %    \end{macrocode}
 % |\l_tmpa_dim| is the value of the key |cell-space-top-limit| of |\RowStyle|.
 %    \begin{macrocode}
     \dim_compare:nNnT \l_tmpa_dim > \c_zero_dim
       {
-        \tl_gput_right:Nx \g_@@_row_style_tl 
+        \@@_put_in_row_style:n 
           {
-            \tl_gput_right:Nn \exp_not:N \g_@@_cell_after_hook_tl 
-              { 
-                \dim_set:Nn \l_@@_cell_space_top_limit_dim 
-                  { \dim_use:N \l_tmpa_dim } 
+            \exp_not:n
+              {
+                \tl_gput_right:Nn \g_@@_cell_after_hook_tl 
+                  { 
+                    \dim_set:Nn \l_@@_cell_space_top_limit_dim 
+                      { \dim_use:N \l_tmpa_dim } 
+                  }
               }
           }
       }
@@ -9977,12 +10022,15 @@
 %    \begin{macrocode}
     \dim_compare:nNnT \l_tmpb_dim > \c_zero_dim
       {
-        \tl_gput_right:Nx \g_@@_row_style_tl 
+        \@@_put_in_row_style:n 
           {
-            \tl_gput_right:Nn \exp_not:N \g_@@_cell_after_hook_tl 
-              { 
-                \dim_set:Nn \l_@@_cell_space_bottom_limit_dim 
-                  { \dim_use:N \l_tmpb_dim } 
+            \exp_not:n 
+              {
+                \tl_gput_right:Nn \g_@@_cell_after_hook_tl 
+                  { 
+                    \dim_set:Nn \l_@@_cell_space_bottom_limit_dim 
+                      { \dim_use:N \l_tmpb_dim } 
+                  }
               }
           }
       }
@@ -9991,7 +10039,7 @@
 %    \begin{macrocode}
     \tl_if_empty:NF \l_@@_color_tl
       {
-        \tl_gput_right:Nx \g_@@_row_style_tl
+        \@@_put_in_row_style:e
           { 
             \mode_leave_vertical: 
             \@@_color:n { \l_@@_color_tl }
@@ -10002,18 +10050,20 @@
 %    \begin{macrocode}
     \bool_if:NT \l_tmpa_bool
       {
-        \tl_gput_right:Nn \g_@@_row_style_tl
+        \@@_put_in_row_style:n
           {
-            \if_mode_math:
-              \c_math_toggle_token
-              \bfseries \boldmath 
-              \c_math_toggle_token
-            \else:
-              \bfseries \boldmath
-            \fi:
+            \exp_not:n
+              {
+                \if_mode_math:
+                  \c_math_toggle_token
+                  \bfseries \boldmath 
+                  \c_math_toggle_token
+                \else:
+                  \bfseries \boldmath
+                \fi:
+              }
           }
       }
-    \tl_gput_right:Nn \g_@@_row_style_tl { \fi } 
     \group_end:
     \g_@@_row_style_tl
     \ignorespaces
@@ -10020,6 +10070,7 @@
   }
 %    \end{macrocode}
 %
+% 
 % \bigskip
 % \section{Colors of cells, rows and columns}
 %
@@ -10578,8 +10629,8 @@
           { \tl_if_blank_p:V \l_tmpb_tl }
           { \str_if_eq_p:Vn \l_tmpb_tl { * } }
           { \tl_set:Nx \l_tmpb_tl { \int_use:N \c at jCol } }
-        \int_compare:nNnT \l_tmpb_tl > \c at jCol
-          { \tl_set:Nx \l_tmpb_tl { \int_use:N \c at jCol } }
+        \int_compare:nNnT \l_tmpb_tl > \g_@@_col_total_int
+          { \tl_set:Nx \l_tmpb_tl { \int_use:N \g_@@_col_total_int } }
 %    \end{macrocode}
 % |\l_@@_tmpc_tl| will contain the number of column.
 %    \begin{macrocode}
@@ -10608,8 +10659,8 @@
             \tl_if_empty:NT \l_tmpa_tl { \tl_set:Nn \l_tmpa_tl { 1 } }  
             \tl_if_empty:NT \l_tmpb_tl
               { \tl_set:Nx \l_tmpb_tl { \int_use:N \c at iRow } }
-            \int_compare:nNnT \l_tmpb_tl > \c at iRow
-              { \tl_set:Nx \l_tmpb_tl { \int_use:N \c at iRow } }
+            \int_compare:nNnT \l_tmpb_tl > \g_@@_row_total_int
+              { \tl_set:Nx \l_tmpb_tl { \int_use:N \g_@@_row_total_int } }
 %    \end{macrocode}
 % Now, the numbers of both rows are in |\l_tmpa_tl| and |\l_tmpb_tl|.
 %    \begin{macrocode}
@@ -10858,6 +10909,26 @@
 %    \end{macrocode}
 %
 % 
+% \bigskip
+%    \begin{macrocode}
+\hook_gput_code:nnn { begindocument } { . } 
+  { 
+    \IfPackageLoadedTF { colortbl }
+      { 
+        \cs_set_eq:NN \@@_old_cellcolor \cellcolor
+        \cs_set_eq:NN \@@_old_rowcolor \rowcolor
+        \cs_new_protected:Npn \@@_revert_colortbl:
+          {
+            \hook_gput_code:nnn { env / tabular / begin } { . }
+              { 
+                \cs_set_eq:NN \cellcolor \@@_old_cellcolor 
+                \cs_set_eq:NN \rowcolor \@@_old_rowcolor 
+              }
+          }    
+      }
+      { \cs_new_protected:Npn \@@_revert_colortbl: { } }
+  }
+%    \end{macrocode}
 % 
 % \bigskip
 % \section{The vertical and horizontal rules}
@@ -12840,8 +12911,8 @@
               { \int_use:N \c at jCol }
               { \int_eval:n { \c at iRow + #1 - 1 } }
               { \int_eval:n { \c at jCol + #2 - 1 } }
-              { \exp_not:n { ##1 } } 
-              { \exp_not:n { ##2 } }
+              { \g_@@_row_style_tl \exp_not:n { ##1 } } 
+              { \g_@@_row_style_tl \exp_not:n { ##2 } }
           }
       }  
     \box_gclear_new:c 
@@ -12848,7 +12919,7 @@
       { g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box }
 %    \end{macrocode}
 % Now, we will actually compose the content of the |\Block| in a TeX box.
-% \emph{Be careful}: if after, the construction of the box, the boolean
+% \emph{Be careful}: if after the construction of the box, the boolean
 % |\g_@@_rotate_bool| is raised (which means that the command |\rotate| was
 % present in the content of the |\Block|) we will rotate the box but also,
 % maybe, change the position of the baseline!
@@ -14296,8 +14367,17 @@
           { \int_use:N \c at jCol } 
           { \int_use:N \c at iRow } 
           { \int_use:N \c at jCol } 
-          { \exp_not:n { #1 } } 
-          { \exp_not:n { #2 } }
+%    \end{macrocode}
+% |\g_@@_row_style_tl| contains several instructions of the form:
+% 
+% \qquad |\@@_if_row_less_than:nn { number } { instructions }|
+%
+% The command |\@@_if_row_less:nn| is fully expandable and, thus, the
+% instructions will be inserted in the |\g_@@_pre_code_after_tl| only if
+% |\diagbox| is used in a row which is the scope of that chunck of instructions.
+%    \begin{macrocode}
+          { \g_@@_row_style_tl \exp_not:n { #1 } } 
+          { \g_@@_row_style_tl \exp_not:n { #2 } }
       }
 %    \end{macrocode}
 % We put the cell with |\diagbox| in the sequence |\g_@@_pos_of_blocks_seq|
@@ -16448,6 +16528,7 @@
     Block~too~large.\\
     You~try~to~draw~a~block~in~the~cell~#1-#2~of~your~matrix~but~the~matrix~is~
     too~small~for~that~block. \\
+    This~block~and~maybe~others~will~be~ignored.
   }
 %    \end{macrocode}
 %
@@ -16459,8 +16540,7 @@
     \g_@@_static_num_of_col_int\
     columns~but~you~use~only~\int_use:N \c at jCol\ and~that's~why~a~block~
     specified~in~the~cell~#1-#2~can't~be~drawn.~You~should~add~some~ampersands~
-    (&)~at~the~end~of~the~first~row~of~your~
-    \@@_full_name_env:.\\
+    (&)~at~the~end~of~the~first~row~of~your~\@@_full_name_env:.\\
     This~block~and~maybe~others~will~be~ignored.
   }
 %    \end{macrocode}

Modified: trunk/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty	2023-11-16 18:39:12 UTC (rev 68869)
+++ trunk/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty	2023-11-16 21:01:12 UTC (rev 68870)
@@ -18,8 +18,8 @@
 %% and version 1.3 or later is part of all distributions of
 %% LaTeX version 2005/12/01 or later.
 %% 
-\def\myfileversion{6.25a}
-\def\myfiledate{2023/11/03}
+\def\myfileversion{6.25b}
+\def\myfiledate{2023/11/16}
 \RequirePackage{pgfcore}
 \usepgfmodule{shapes}
 \RequirePackage{l3keys2e}
@@ -788,7 +788,7 @@
 \tl_set_eq:NN \l__nicematrix_xdots_line_style_tl \c__nicematrix_standard_tl
 \bool_new:N \l__nicematrix_light_syntax_bool
 \tl_new:N \l__nicematrix_baseline_tl
-\tl_set:Nn \l__nicematrix_baseline_tl c
+\tl_set:Nn \l__nicematrix_baseline_tl { c }
 \bool_new:N \l__nicematrix_exterior_arraycolsep_bool
 \bool_new:N \l__nicematrix_parallelize_diags_bool
 \bool_set_true:N \l__nicematrix_parallelize_diags_bool
@@ -1630,6 +1630,7 @@
     \cs_set_eq:NN \multicolumn \__nicematrix_multicolumn:nnn
     \hook_gput_code:nnn { env / tabular / begin } { . }
       { \cs_set_eq:NN \multicolumn \__nicematrix_old_multicolumn }
+    \__nicematrix_revert_colortbl:
     \tl_if_exist:NT \l__nicematrix_note_in_caption_tl
       {
         \tl_if_empty:NF \l__nicematrix_note_in_caption_tl
@@ -1714,7 +1715,10 @@
   }
 \cs_new_protected_nopar:Npn \__nicematrix_CodeBefore_Body:w #1 \Body
   {
-    \tl_gput_left:Nn \g__nicematrix_pre_code_before_tl { #1 }
+    \tl_set:Nn \l_tmpa_tl { #1 }
+    \int_compare:nNnT { \char_value_catcode:n { 60 } } = { 13 }
+      { \__nicematrix_rescan_for_spanish:N \l_tmpa_tl }
+    \tl_gput_left:NV \g__nicematrix_pre_code_before_tl \l_tmpa_tl
     \bool_set_true:N \l__nicematrix_code_before_bool
     \__nicematrix_pre_array:
   }
@@ -1772,11 +1776,8 @@
     \bool_gset_false:N \g__nicematrix_recreate_cell_nodes_bool
     \group_begin:
     \bool_if:NT \l__nicematrix_tabular_bool \c_math_toggle_token
-        \int_compare:nNnT { \char_value_catcode:n { 60 } } = { 13 }
-          {
-            \__nicematrix_rescan_for_spanish:N \g__nicematrix_pre_code_before_tl
-            \__nicematrix_rescan_for_spanish:N \l__nicematrix_code_before_tl
-          }
+      \int_compare:nNnT { \char_value_catcode:n { 60 } } = { 13 }
+        { \__nicematrix_rescan_for_spanish:N \l__nicematrix_code_before_tl }
     \exp_last_unbraced:NV \__nicematrix_CodeBefore_keys:
       \g__nicematrix_pre_code_before_tl
       \__nicematrix_actually_color:
@@ -2780,7 +2781,8 @@
     \multispan { #1 }
     \cs_set_eq:NN \__nicematrix_update_max_cell_width: \prg_do_nothing: % added 2023-10-04
     \begingroup
-    \cs_set:Npn \@addamp { \if at firstamp \@firstampfalse \else \@preamerr 5 \fi }
+    \cs_set:Npn \@addamp
+      { \legacy_if:nTF { @firstamp } { \@firstampfalse } { \@preamerr 5 } }
     \tl_gclear:N \g__nicematrix_preamble_tl
     \__nicematrix_make_m_preamble:n #2 \q_stop
     \exp_args:NV \@mkpream \g__nicematrix_preamble_tl
@@ -3453,6 +3455,7 @@
         \hbox_overlap_right:n
           {
             \skip_horizontal:N \g__nicematrix_width_last_col_dim
+            \skip_horizontal:N \col at sep % added 2023-11-05
             \bool_if:NT \l__nicematrix_code_before_bool
               {
                 \pgfsys at markposition
@@ -5246,6 +5249,19 @@
     \dim_set_eq:NN \l__nicematrix_y_final_dim \pgf at y
     \__nicematrix_draw_line:
   }
+\cs_new:Npn \__nicematrix_if_row_less_than:nn #1 #2
+  { \int_compare:nNnT { \int_use:N \c at iRow } < { #1 } { #2 } }
+\cs_set_protected:Npn \__nicematrix_put_in_row_style:n #1
+  {
+    \tl_gput_right:Nx \g__nicematrix_row_style_tl
+      {
+        \exp_not:N
+        \__nicematrix_if_row_less_than:nn
+          { \int_eval:n { \c at iRow + \l__nicematrix_key_nb_rows_int } }
+          { \exp_not:n { #1 } }
+      }
+  }
+\cs_generate_variant:Nn \__nicematrix_put_in_row_style:n { e }
 \keys_define:nn { NiceMatrix / RowStyle }
   {
     cell-space-top-limit .dim_set:N = \l_tmpa_dim ,
@@ -5301,35 +5317,38 @@
               }
           }
       }
-    \tl_gput_right:Nn \g__nicematrix_row_style_tl { \ifnum \c at iRow < }
-    \tl_gput_right:Nx \g__nicematrix_row_style_tl
-      { \int_eval:n { \c at iRow + \l__nicematrix_key_nb_rows_int } }
-    \tl_gput_right:Nn \g__nicematrix_row_style_tl { #2 }
+    \__nicematrix_put_in_row_style:n { \exp_not:n { #2 } }
     \dim_compare:nNnT \l_tmpa_dim > \c_zero_dim
       {
-        \tl_gput_right:Nx \g__nicematrix_row_style_tl
+        \__nicematrix_put_in_row_style:n
           {
-            \tl_gput_right:Nn \exp_not:N \g__nicematrix_cell_after_hook_tl
+            \exp_not:n
               {
-                \dim_set:Nn \l__nicematrix_cell_space_top_limit_dim
-                  { \dim_use:N \l_tmpa_dim }
+                \tl_gput_right:Nn \g__nicematrix_cell_after_hook_tl
+                  {
+                    \dim_set:Nn \l__nicematrix_cell_space_top_limit_dim
+                      { \dim_use:N \l_tmpa_dim }
+                  }
               }
           }
       }
     \dim_compare:nNnT \l_tmpb_dim > \c_zero_dim
       {
-        \tl_gput_right:Nx \g__nicematrix_row_style_tl
+        \__nicematrix_put_in_row_style:n
           {
-            \tl_gput_right:Nn \exp_not:N \g__nicematrix_cell_after_hook_tl
+            \exp_not:n
               {
-                \dim_set:Nn \l__nicematrix_cell_space_bottom_limit_dim
-                  { \dim_use:N \l_tmpb_dim }
+                \tl_gput_right:Nn \g__nicematrix_cell_after_hook_tl
+                  {
+                    \dim_set:Nn \l__nicematrix_cell_space_bottom_limit_dim
+                      { \dim_use:N \l_tmpb_dim }
+                  }
               }
           }
       }
     \tl_if_empty:NF \l__nicematrix_color_tl
       {
-        \tl_gput_right:Nx \g__nicematrix_row_style_tl
+        \__nicematrix_put_in_row_style:e
           {
             \mode_leave_vertical:
             \__nicematrix_color:n { \l__nicematrix_color_tl }
@@ -5337,18 +5356,20 @@
       }
     \bool_if:NT \l_tmpa_bool
       {
-        \tl_gput_right:Nn \g__nicematrix_row_style_tl
+        \__nicematrix_put_in_row_style:n
           {
-            \if_mode_math:
-              \c_math_toggle_token
-              \bfseries \boldmath
-              \c_math_toggle_token
-            \else:
-              \bfseries \boldmath
-            \fi:
+            \exp_not:n
+              {
+                \if_mode_math:
+                  \c_math_toggle_token
+                  \bfseries \boldmath
+                  \c_math_toggle_token
+                \else:
+                  \bfseries \boldmath
+                \fi:
+              }
           }
       }
-    \tl_gput_right:Nn \g__nicematrix_row_style_tl { \fi }
     \group_end:
     \g__nicematrix_row_style_tl
     \ignorespaces
@@ -5656,8 +5677,8 @@
           { \tl_if_blank_p:V \l_tmpb_tl }
           { \str_if_eq_p:Vn \l_tmpb_tl { * } }
           { \tl_set:Nx \l_tmpb_tl { \int_use:N \c at jCol } }
-        \int_compare:nNnT \l_tmpb_tl > \c at jCol
-          { \tl_set:Nx \l_tmpb_tl { \int_use:N \c at jCol } }
+        \int_compare:nNnT \l_tmpb_tl > \g__nicematrix_col_total_int
+          { \tl_set:Nx \l_tmpb_tl { \int_use:N \g__nicematrix_col_total_int } }
         \tl_set_eq:NN \l__nicematrix_tmpc_tl \l_tmpa_tl
         \__nicematrix_qpoint:n { col - \l_tmpa_tl }
         \int_compare:nNnTF \l__nicematrix_first_col_int = \l_tmpa_tl
@@ -5674,8 +5695,8 @@
             \tl_if_empty:NT \l_tmpa_tl { \tl_set:Nn \l_tmpa_tl { 1 } }
             \tl_if_empty:NT \l_tmpb_tl
               { \tl_set:Nx \l_tmpb_tl { \int_use:N \c at iRow } }
-            \int_compare:nNnT \l_tmpb_tl > \c at iRow
-              { \tl_set:Nx \l_tmpb_tl { \int_use:N \c at iRow } }
+            \int_compare:nNnT \l_tmpb_tl > \g__nicematrix_row_total_int
+              { \tl_set:Nx \l_tmpb_tl { \int_use:N \g__nicematrix_row_total_int } }
             \seq_if_in:NxF \l__nicematrix_corners_cells_seq
               { \l_tmpa_tl - \l__nicematrix_tmpc_tl }
               {
@@ -5796,6 +5817,23 @@
           }
       }
   }
+\hook_gput_code:nnn { begindocument } { . }
+  {
+    \IfPackageLoadedTF { colortbl }
+      {
+        \cs_set_eq:NN \__nicematrix_old_cellcolor \cellcolor
+        \cs_set_eq:NN \__nicematrix_old_rowcolor \rowcolor
+        \cs_new_protected:Npn \__nicematrix_revert_colortbl:
+          {
+            \hook_gput_code:nnn { env / tabular / begin } { . }
+              {
+                \cs_set_eq:NN \cellcolor \__nicematrix_old_cellcolor
+                \cs_set_eq:NN \rowcolor \__nicematrix_old_rowcolor
+              }
+          }
+      }
+      { \cs_new_protected:Npn \__nicematrix_revert_colortbl: { } }
+  }
 \cs_set_eq:NN \OnlyMainNiceMatrix \use:n
 \cs_new_protected:Npn \__nicematrix_OnlyMainNiceMatrix:n #1
   {
@@ -6968,8 +7006,8 @@
               { \int_use:N \c at jCol }
               { \int_eval:n { \c at iRow + #1 - 1 } }
               { \int_eval:n { \c at jCol + #2 - 1 } }
-              { \exp_not:n { ##1 } }
-              { \exp_not:n { ##2 } }
+              { \g__nicematrix_row_style_tl \exp_not:n { ##1 } }
+              { \g__nicematrix_row_style_tl \exp_not:n { ##2 } }
           }
       }
     \box_gclear_new:c
@@ -7942,8 +7980,8 @@
           { \int_use:N \c at jCol }
           { \int_use:N \c at iRow }
           { \int_use:N \c at jCol }
-          { \exp_not:n { #1 } }
-          { \exp_not:n { #2 } }
+          { \g__nicematrix_row_style_tl \exp_not:n { #1 } }
+          { \g__nicematrix_row_style_tl \exp_not:n { #2 } }
       }
     \seq_gput_right:Nx \g__nicematrix_pos_of_blocks_seq
       {
@@ -9433,6 +9471,7 @@
     Block~too~large.\\
     You~try~to~draw~a~block~in~the~cell~#1-#2~of~your~matrix~but~the~matrix~is~
     too~small~for~that~block. \\
+    This~block~and~maybe~others~will~be~ignored.
   }
 \__nicematrix_msg_new:nn { Block~too~large~2 }
   {
@@ -9441,8 +9480,7 @@
     \g__nicematrix_static_num_of_col_int\
     columns~but~you~use~only~\int_use:N \c at jCol\ and~that's~why~a~block~
     specified~in~the~cell~#1-#2~can't~be~drawn.~You~should~add~some~ampersands~
-    (&)~at~the~end~of~the~first~row~of~your~
-    \__nicematrix_full_name_env:.\\
+    (&)~at~the~end~of~the~first~row~of~your~\__nicematrix_full_name_env:.\\
     This~block~and~maybe~others~will~be~ignored.
   }
 \__nicematrix_msg_new:nn { unknown~column~type }



More information about the tex-live-commits mailing list.