From baa3e10650110291de10e0e8e6a1e48ac4579afe Mon Sep 17 00:00:00 2001
From: Norbert Preining <norbert@preining.info>
Date: Sun, 18 Sep 2022 03:08:21 +0000
Subject: CTAN sync 202209180308

---
 macros/latex/contrib/nicematrix/nicematrix.dtx | 141 +++++++++++++++++++++++--
 1 file changed, 131 insertions(+), 10 deletions(-)

(limited to 'macros/latex/contrib/nicematrix/nicematrix.dtx')

diff --git a/macros/latex/contrib/nicematrix/nicematrix.dtx b/macros/latex/contrib/nicematrix/nicematrix.dtx
index 1884212f42..659e7fa56a 100644
--- a/macros/latex/contrib/nicematrix/nicematrix.dtx
+++ b/macros/latex/contrib/nicematrix/nicematrix.dtx
@@ -17,8 +17,8 @@
 %
 % \fi
 % \iffalse
-\def\myfileversion{6.13}
-\def\myfiledate{2022/08/24}
+\def\myfileversion{6.13a}
+\def\myfiledate{2022/09/17}
 %
 %
 %<*batchfile>
@@ -1200,7 +1200,7 @@ version 2005/12/01 or later.
 % It's also possible to define commands and letters for customized rules with
 % the key |custom-line| available in |\NiceMatrixOptions| and in the options of
 % individual environments. That key takes in as argument a list of
-% \textsl{key=value} pairs. First, there is two keys to define the tools which
+% \textsl{key=value} pairs. First, there is three keys to define the tools which
 % will be used to use that new type of rule.
 % 
 % \begin{itemize}
@@ -1754,7 +1754,6 @@ version 2005/12/01 or later.
 % arguments for the colors, this command takes in an argument which is a
 % (comma-separated) list of colors. In that list, the symbol |=| represent a
 % color identical to the previous one.
-% \end{itemize}
 %
 % \smallskip
 % \begin{BVerbatim}[boxwidth=10cm,baseline=c]
@@ -1784,8 +1783,49 @@ version 2005/12/01 or later.
 % Alexandra \\
 % \end{NiceTabular}
 %
+% \bigskip
+% It's also possible to use in the command |\rowlistcolors| a color series
+% defined by the command |\definecolorseries| of \pkg{xcolor} (and initialized
+% with the command |\resetcolorseries|\footnote{For the initialization, in the
+% following example, you have used the counter |iRow| which, when used in the
+% |\CodeBefore| (and in the |\CodeAfter|) corresponds to the number of rows of
+% the array: cf.~p~\pageref{iRow}. That leads to an adjustement of the gradation
+% of the colors to the size of the tabular.}).
 %
-% \medskip
+% \smallskip
+% \begin{BVerbatim}[boxwidth=12cm,baseline=c]
+% \begin{NiceTabular}{c}
+% \CodeBefore
+%    ~emphase#\definecolorseries{BlueWhite}{rgb}{last}{blue}{white}@
+%    ~emphase#\resetcolorseries{\value{iRow}}{BlueWhite}@
+%    ~emphase#\rowlistcolors{1}{BlueWhite!!+}@
+% \Body
+% Peter \\
+% James \\
+% Abigail \\
+% Elisabeth \\
+% Claudius \\
+% Jane \\
+% Alexandra \\
+% \end{NiceTabular}
+% \end{BVerbatim}
+% \begin{NiceTabular}{c}
+% \CodeBefore
+%    \definecolorseries{BlueWhite}{rgb}{last}{blue}{white}
+%    \resetcolorseries[\value{iRow}]{BlueWhite}
+%    \rowlistcolors{1}{BlueWhite!!+}
+% \Body
+% Peter \\
+% James \\
+% Abigail \\
+% Elisabeth \\
+% Claudius \\
+% Jane \\
+% Alexandra \\
+% \end{NiceTabular}
+% \end{itemize}
+%
+% \vspace{1cm}
 % We recall that all the color commands we have described don't color the cells
 % which are in the ``corners''. In the following example, we use the key
 % |corners| to require the determination of the corner \emph{north east} (NE).
@@ -3876,6 +3916,8 @@ version 2005/12/01 or later.
 %
 % \subsection{The counters iRow and jCol}
 %
+% \label{iRow}
+% 
 % In the cells of the array, it's possible to use the LaTeX counters |iRow| and
 % |jCol| which represent the number of the current row and the number of the
 % current column\footnote{We recall that the exterior ``first row'' (if it
@@ -5888,6 +5930,77 @@ version 2005/12/01 or later.
   }
 %    \end{macrocode}
 %
+% \bigskip
+% \subsection*{Security test}
+%
+% Within the package \pkg{nicematrix}, we will have to test whether a cell of a
+% |{NiceTabular}| is empty. For the cells of the columns of type |p|, |b|, |m|,
+% |X| and |V|, we will test whether the cell is syntactically empty (that is to
+% say that there is only spaces between the ampersands |&|). That test will be
+% done with the command |\@@_test_if_empty:| by testing if the two first tokens
+% in the cells are (during the TeX process) are |\ignorespaces| and |\unskip|.
+%
+% However, if, one day, there is a changement in the implementation of
+% \pkg{array}, maybe that this test will be broken (and \pkg{nicematrix} also).
+%
+% That's why, by security, we will take a test in a small |{tabular}| composed
+% in the box |\l_tmpa_box| used as sandbox.
+% 
+%   \begin{macrocode}
+\@@_msg_new:nn { Internal~error }
+  { 
+    A~fatal~internal~error~have~occurred.\\
+    If~you~see~this~message,~contact~the~author~of~the~package~'nicematrix'~
+    because~this~error~should~not~have~occurred.
+  }
+%    \end{macrocode}
+% 
+% \bigskip
+%    \begin{macrocode}
+\@@_msg_new:nn { mdwtab~loaded }
+  { 
+    The~packages~'mdwtab'~and~'nicematrix'~are~incompatible.~
+    This~error~is~fatal.
+  }
+%    \end{macrocode}
+% 
+% \bigskip
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_security_test:n #1 
+  {
+    \peek_meaning:NTF \ignorespaces
+      { \@@_security_test_i:w }
+      { \@@_fatal:n { Internal~error } }
+    #1 
+  }
+%    \end{macrocode}
+%
+% \bigskip
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_security_test_i:w \ignorespaces #1
+  {
+    \peek_meaning:NF \unskip { \@@_fatal:n { Internal~error } }
+    #1 
+  }
+%    \end{macrocode}
+%
+% \bigskip
+% Here, the box |\l_tmpa_box| will be used as sandbox to take our security test. 
+%    \begin{macrocode}
+\hook_gput_code:nnn { begindocument } { . }
+  {
+    \@ifpackageloaded { mdwtab }
+      { \@@_fatal:n { mdwtab~loaded } }
+      {
+        \hbox_set:Nn \l_tmpa_box
+          {
+            \begin { tabular } { c > { \@@_security_test:n } c c }
+            text & & text
+            \end { tabular }
+          }
+      } 
+  }
+%    \end{macrocode}
 % 
 % \bigskip
 % \subsection*{Technical  definitions}
@@ -8497,7 +8610,7 @@ version 2005/12/01 or later.
 % we use the following technic:
 % \begin{itemize}
 % \item for the columns of type |p|, |m|, |b|, |V| (of \pkg{varwidth}) or |X|,
-% we test whether the cell is syntacticly empty with |\@@_test_if_empty:| and
+% we test whether the cell is syntactically empty with |\@@_test_if_empty:| and
 % |\@@_test_if_empty_for_S:| 
 % \item if the width of the box |\l_@@_cell_box| (created with the content of
 % the cell) is equal to zero, we consider the cell as empty (however,
@@ -10580,7 +10693,14 @@ version 2005/12/01 or later.
     \peek_meaning:NT \unskip 
       {
         \tl_gput_right:Nn \g_@@_cell_after_hook_tl 
-          { \box_set_wd:Nn \l_@@_cell_box \c_zero_dim }
+          { 
+            \box_set_wd:Nn \l_@@_cell_box \c_zero_dim 
+%    \end{macrocode}
+% We put the following code in order to have a column with the correct width
+% even when all the cells of the column are empty.
+%    \begin{macrocode}
+            \skip_horizontal:N \l_@@_col_width_dim 
+          }
       }
     #1
   }
@@ -11031,8 +11151,9 @@ version 2005/12/01 or later.
     \@whilesw \if@tempswa \fi { \@tempswafalse \the \NC@list }
     \tl_gclear:N \g_@@_preamble_tl 
     \exp_after:wN \@@_patch_m_preamble:n \the \@temptokena \q_stop
-    \tl_gset_eq:NN #1 \g_@@_preamble_tl 
     \group_end:
+    \tl_set_eq:NN #1 \g_@@_preamble_tl 
+    % \group_end:
   }
 %    \end{macrocode}
 % 
@@ -12434,7 +12555,7 @@ version 2005/12/01 or later.
         \bool_if:NTF \l_@@_in_code_after_bool
           { \@@_error_or_warning:n { TabularNote~in~CodeAfter } }
           {
-            \tl_if_empty:NF \g_@@_taublarnote_tl
+            \tl_if_empty:NF \g_@@_tabularnote_tl
               { \tl_gput_right:Nn \g_@@_tabularnote_tl { \par } }
             \tl_gput_right:Nn \g_@@_tabularnote_tl { ##1 } 
           }
@@ -17359,7 +17480,7 @@ version 2005/12/01 or later.
               {
                 { \int_compare_p:nNn { #2 } = 1 }
                 { \dim_compare_p:n { \l_@@_col_width_dim >= \c_zero_dim } }
-                { ! \l_@@_respect_arraystretch_bool }
+                { ! \g_@@_rotate_bool } % added 2022/09/16
               }
 %    \end{macrocode}
 % When the block is mono-column in a column with a fixed width (eg |p{3cm}|).
-- 
cgit v1.2.3

