texlive[59105] Master/texmf-dist: nicematrix (6may21)

commits+karl at tug.org commits+karl at tug.org
Thu May 6 22:23:55 CEST 2021


Revision: 59105
          http://tug.org/svn/texlive?view=revision&revision=59105
Author:   karl
Date:     2021-05-06 22:23:54 +0200 (Thu, 06 May 2021)
Log Message:
-----------
nicematrix (6may21)

Modified Paths:
--------------
    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/source/latex/nicematrix/nicematrix.dtx
    trunk/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty

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	2021-05-06 20:23:37 UTC (rev 59104)
+++ trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex	2021-05-06 20:23:54 UTC (rev 59105)
@@ -4207,6 +4207,10 @@
 Si vous souhaitez utiliser \pkg{nicematrix} with \cls{aastex63}, envoyez-moi un
 courrier électronique et j'essaierai de résoudre les incompatibilités.
 
+\bigskip
+L'extension \pkg{nicematrix} n'est pas compatible avec la classe \cls{ieeeaccess}
+(car cette classe n'est pas compatible avec PGF/Tikz).
+
 \section{Exemples}
 
 \subsection{Notes dans les tableaux}
@@ -4937,11 +4941,22 @@
 %
 %
 %
+\tikzset{highlight/.style={rectangle,
+                           fill=red!15,
+                           rounded corners = 0.5 mm, 
+                           inner sep=1pt,
+                           fit=#1}}%
+%
+%
 \[\begin{NiceArray}{*{6}{c}@{\hspace{6mm}}*{5}{c}}[nullify-dots]
-\CodeBefore
+\CodeBefore [create-cell-nodes]
   \SubMatrix({2-7}{6-11})
   \SubMatrix({7-2}{11-6})
   \SubMatrix({7-7}{11-11})
+  \begin{tikzpicture}
+    \node [highlight = (9-2) (9-6)] { } ; 
+    \node [highlight = (2-9) (6-9)] { } ;
+  \end{tikzpicture}
 \Body
     &        &        &        &        &        &        &        & \color{blue}\scriptstyle C_j \\
     &        &        &        &        &        & b_{11} & \Cdots & b_{1j} & \Cdots & b_{1n} \\
@@ -4956,15 +4971,12 @@
     & \Vdots &        &        &        & \Vdots \\
     & a_{n1} & \Cdots &        &        & a_{nn}  \\
 \CodeAfter
-\begin{tikzpicture}
-\node [highlight = (9-2) (9-6)] { } ; 
-\node [highlight = (2-9) (6-9)] { } ;
-\draw [gray,shorten > = 1mm, shorten < = 1mm] (9-4.north) to [bend left] (4-9.west) ;
-\end{tikzpicture}
+\tikz \draw [gray,shorten > = 1mm, shorten < = 1mm] (9-4.north) to [bend left] (4-9.west) ;
 \end{NiceArray}\]
 
 
 
+
 \section*{Autre documentation}
 
 Le document |nicematrix.pdf| (fourni avec l'extension \pkg{nicematrix}) contient

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

Modified: trunk/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx	2021-05-06 20:23:37 UTC (rev 59104)
+++ trunk/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx	2021-05-06 20:23:54 UTC (rev 59105)
@@ -15,8 +15,8 @@
 %
 % \fi
 % \iffalse
-\def\myfileversion{5.15}
-\def\myfiledate{2021/04/25}
+\def\myfileversion{5.15a}
+\def\myfiledate{2021/05/06}
 %
 %
 %<*batchfile>
@@ -26,6 +26,8 @@
 \usedir{tex/latex/nicematrix}
 \preamble
 
+
+
 Copyright (C) 2018-2021 by F. Pantigny
 -----------------------------------
 
@@ -4136,6 +4138,11 @@
 % \cls{aastex63}. If you want to use \pkg{nicematrix} with \cls{aastex63}, send
 % me an email and I will try to solve the incompatibilies.
 % 
+%
+% \bigskip
+% the package \pkg{nicematrix} is not compatible with the class \cls{ieeeaccess}
+% (because that class is not compatible with PGF/Tikz).
+% 
 % \section{Examples}
 %
 % \subsection{Notes in the tabulars}
@@ -4855,12 +4862,20 @@
 %
 % You will find the LaTeX code of that figure in the source file of this
 % document.
-%
+% \tikzset{highlight/.style={rectangle,
+%                            fill=red!15,
+%                            rounded corners = 0.5 mm, 
+%                            inner sep=1pt,
+%                            fit=#1}}%
 % \[\begin{NiceArray}{*{6}{c}@{\hspace{6mm}}*{5}{c}}[nullify-dots]
-% \CodeBefore
+% \CodeBefore [create-cell-nodes]
 %   \SubMatrix({2-7}{6-11})
 %   \SubMatrix({7-2}{11-6})
 %   \SubMatrix({7-7}{11-11})
+%   \begin{tikzpicture}
+%     \node [highlight = (9-2) (9-6)] { } ; 
+%     \node [highlight = (2-9) (6-9)] { } ;
+%   \end{tikzpicture}
 % \Body
 %     &        &        &        &        &        &        &        & \color{blue}\scriptstyle C_j \\
 %     &        &        &        &        &        & b_{11} & \Cdots & b_{1j} & \Cdots & b_{1n} \\
@@ -4875,12 +4890,9 @@
 %     & \Vdots &        &        &        & \Vdots \\
 %     & a_{n1} & \Cdots &        &        & a_{nn}  \\
 % \CodeAfter
-%   \begin{tikzpicture}
-%   \node [highlight = (9-2) (9-6)] { } ; 
-%   \node [highlight = (2-9) (6-9)] { } ;
-%   \draw [gray,shorten > = 1mm, shorten < = 1mm] (9-4.north) to [bend left] (4-9.west) ;
-%   \end{tikzpicture}
+% \tikz \draw [gray,shorten > = 1mm, shorten < = 1mm] (9-4.north) to [bend left] (4-9.west) ;
 % \end{NiceArray}\]
+%
 % 
 %\section{Implementation}
 %
@@ -5477,6 +5489,14 @@
 %    \end{macrocode}
 %
 % \bigskip
+% The following counters will be used to count the numbers of rows and columns
+% of the array.
+%    \begin{macrocode}
+\int_new:N \g_@@_row_total_int
+\int_new:N \g_@@_col_total_int
+%    \end{macrocode}
+% 
+% \bigskip
 % The following token list will contain the type of the current cell (|l|, |c|
 % or |r|). It will be used by the blocks.
 %    \begin{macrocode}
@@ -5519,9 +5539,9 @@
 %
 % \bigskip
 % If the user uses |{NiceArray}| or |{NiceTabular}| the flag
-% |\g_@@_NiceArray_bool| will be raised. 
+% |\l_@@_NiceArray_bool| will be raised. 
 %    \begin{macrocode}
-\bool_new:N \g_@@_NiceArray_bool
+\bool_new:N \l_@@_NiceArray_bool
 %    \end{macrocode}
 % In fact, if there is delimiters in the preamble of |{NiceArray}| (eg:
 % |[cccc]|), this boolean will be set to false.
@@ -6121,7 +6141,7 @@
 %    \begin{macrocode}
         \NewDocumentCommand \tabularnote { m }
           {
-            \bool_if:nTF { ! \g_@@_NiceArray_bool && \l_@@_in_env_bool }
+            \bool_if:nTF { ! \l_@@_NiceArray_bool && \l_@@_in_env_bool }
               { \@@_error:n { tabularnote~forbidden } }
               {
 %    \end{macrocode}
@@ -6190,7 +6210,6 @@
 % 
 % 
 % \subsection*{Command for creation of rectangle nodes}
-%
 % 
 % The following command should be used in a |{pgfpicture}|. It creates a
 % rectangle (empty but with a name).
@@ -6257,7 +6276,7 @@
   }
 %    \end{macrocode}
 %
-%
+% 
 % \bigskip 
 % \subsection*{The options}
 % 
@@ -6398,8 +6417,14 @@
 %    \begin{macrocode}
 \bool_new:N \l_@@_auto_columns_width_bool
 %    \end{macrocode}
+%
+% \bigskip
+% The following boolean corresponds to the key |create-cell-nodes| of the
+% keyword |\CodeBefore|.
+%    \begin{macrocode}
+\bool_new:N \g_@@_recreate_cell_nodes_bool 
+%    \end{macrocode}
 % 
-% 
 % \bigskip
 % The string |\l_@@_name_str| will contain the optional name of the
 % environment: this name can be used to access to the Tikz nodes created in the
@@ -6531,6 +6556,9 @@
 %    \begin{macrocode}
 \keys_define:nn { NiceMatrix / Global }
   {
+    delimiters .code:n = 
+      \keys_set:nn { NiceMatrix / delimiters } { #1 } ,
+    delimiters .value_required:n = true , 
     rules .code:n = \keys_set:nn { NiceMatrix / rules } { #1 } ,
     rules .value_required:n = true ,
     standard-cline .bool_set:N = \l_@@_standard_cline_bool ,
@@ -6613,7 +6641,7 @@
 %    \begin{macrocode}
 \keys_define:nn { NiceMatrix / Env } 
   { 
-    delimiters/max-width .bool_set:N = \l_@@_delimiters_max_width_bool ,
+    
 %    \end{macrocode}
 % The key |hvlines-except-corners| is now deprecated.
 %    \begin{macrocode}
@@ -6727,7 +6755,17 @@
     unknown .code:n  = \@@_error:n { Unknown~key~for~notes } 
   }
 %    \end{macrocode}  
-% 
+%
+%    \begin{macrocode} 
+\keys_define:nn { NiceMatrix / delimiters }
+  {
+    max-width .bool_set:N = \l_@@_delimiters_max_width_bool ,
+    max-width .default:n = true ,
+    color .tl_set:N = \l_@@_delimiters_color_tl ,
+    color .value_required:n = true ,
+  }
+%    \end{macrocode}
+%
 % \bigskip
 % We begin the construction of the major sets of keys (used by the different
 % user commands and environments). 
@@ -6739,6 +6777,7 @@
     NiceMatrixOptions / xdots .inherit:n = NiceMatrix / xdots ,
     NiceMatrixOptions / rules .inherit:n = NiceMatrix / rules ,
     NiceMatrixOptions / notes .inherit:n = NiceMatrix / notes ,
+    NiceMatrixOptions / delimiters .inherit:n = NiceMatrix / delimiters ,
     NiceMatrixOptions / sub-matrix .inherit:n = NiceMatrix / sub-matrix ,  
     SubMatrix / rules .inherit:n = NiceMatrix / rules ,  
     CodeAfter / xdots .inherit:n = NiceMatrix / xdots ,
@@ -6749,6 +6788,7 @@
       } ,
     NiceMatrix / xdots .inherit:n = NiceMatrix / xdots ,
     NiceMatrix / rules .inherit:n = NiceMatrix / rules ,
+    NiceMatrix / delimiters .inherit:n = NiceMatrix / delimiters ,
     NiceTabular .inherit:n = 
       {
         NiceMatrix / Global ,
@@ -6756,6 +6796,7 @@
       } ,
     NiceTabular / xdots .inherit:n = NiceMatrix / xdots ,
     NiceTabular / rules .inherit:n = NiceMatrix / rules ,
+    NiceTabular / delimiters .inherit:n = NiceMatrix / delimiters ,
     NiceArray .inherit:n = 
       { 
         NiceMatrix / Global ,
@@ -6763,6 +6804,7 @@
       } ,
     NiceArray / xdots .inherit:n = NiceMatrix / xdots ,
     NiceArray / rules .inherit:n = NiceMatrix / rules ,
+    NiceArray / delimiters .inherit:n = NiceMatrix / delimiters ,
     pNiceArray .inherit:n = 
       { 
         NiceMatrix / Global ,
@@ -6770,6 +6812,7 @@
       } ,
     pNiceArray / xdots .inherit:n = NiceMatrix / xdots ,
     pNiceArray / rules .inherit:n = NiceMatrix / rules ,
+    pNiceArray / delimiters .inherit:n = NiceMatrix / delimiters ,
   }
 %    \end{macrocode}
 % 
@@ -6781,13 +6824,6 @@
 %    \begin{macrocode}
 \keys_define:nn { NiceMatrix / NiceMatrixOptions }
   { 
-    delimiters / max-width .bool_set:N = \l_@@_delimiters_max_width_bool ,
-    delimiters / color .tl_set:N = \l_@@_delimiters_color_tl ,
-    delimiters / color .value_required:n = true ,
-    delimiters-color .code:n = 
-      \tl_set:Nn \l_@@_delimiters_color_tl { #1 } 
-      \@@_error:n { delimiters-color deleted } ,
-    delimiters-color .value_required:n = true ,
     last-col .code:n = \tl_if_empty:nF { #1 }
                          { \@@_error:n { last-col~non~empty~for~NiceMatrixOptions } } 
                        \int_zero:N \l_@@_last_col_int ,
@@ -6900,12 +6936,6 @@
     r .code:n = \tl_set:Nn \l_@@_type_of_col_tl r ,
     small .bool_set:N = \l_@@_small_bool ,
     small .value_forbidden:n = true ,
-    delimiters / color .tl_set:N = \l_@@_delimiters_color_tl ,
-    delimiters / color .value_required:n = true ,
-    delimiters-color .code:n = 
-      \tl_set:Nn \l_@@_delimiters_color_tl { #1 } 
-      \@@_error:n { delimiters-color deleted } ,
-    delimiters-color .value_required:n = true ,
     unknown .code:n = \@@_error:n { Unknown~option~for~NiceMatrix } 
   }
 %    \end{macrocode}
@@ -6936,11 +6966,6 @@
     notes / bottomrule .default:n = true ,
     tabularnote .tl_set:N = \l_@@_tabularnote_tl ,
     tabularnote .value_required:n = true ,
-    delimiters-color .code:n = 
-      \tl_set:Nn \l_@@_delimiters_color_tl { #1 } 
-      \@@_error:n { delimiters-color deleted } ,
-    delimiters / color .tl_set:N = \l_@@_delimiters_color_tl ,
-    delimiters / color .value_required:n = true ,
     r .code:n = \@@_error:n { r~or~l~with~preamble } ,
     l .code:n = \@@_error:n { r~or~l~with~preamble } ,
     unknown .code:n = \@@_error:n { Unknown~option~for~NiceArray } 
@@ -7206,7 +7231,7 @@
         \bool_lazy_or:nnTF 
           \g_@@_not_empty_cell_bool
           { \dim_compare_p:nNn { \box_wd:N \l_@@_cell_box } > \c_zero_dim }
-          \@@_node_for_the_cell:
+          \@@_node_for_cell:
           { \box_use_drop:N \l_@@_cell_box }
       }
     \int_gset:Nn \g_@@_col_total_int { \int_max:nn \g_@@_col_total_int \c at jCol }
@@ -7214,12 +7239,12 @@
     \bool_gset_false:N \g_@@_not_empty_cell_bool
   } 
 %    \end{macrocode}
-% 
+%
 % \medskip
 % The following command creates the \textsc{pgf} name of the node with, of
 % course, |\l_@@_cell_box| as the content.
 %    \begin{macrocode}
-\cs_new_protected:Npn \@@_node_for_the_cell:
+\cs_new_protected:Npn \@@_node_for_cell:
   {
     \pgfpicture 
     \pgfsetbaseline \c_zero_dim
@@ -7244,7 +7269,54 @@
     \endpgfpicture
   }
 %    \end{macrocode}
+%
+% \medskip
+% As its name says, the following command is a patch for the command
+% |\@@_node_for_cell:|. This patch will be appended on the left of 
+% |\@@_noce_for_the_cell:| when the construction of the cell nodes (of the forme
+% |(i-j)|) in the |\CodeBefore| is required.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_patch_node_for_cell:n #1
+  {
+    \cs_new_protected:Npn \@@_patch_node_for_cell:
+      {
+        \hbox_set:Nn \l_@@_cell_box 
+          { 
+            \box_move_up:nn { \box_ht:N \l_@@_cell_box} 
+              \hbox_overlap_left:n 
+                { 
+                  \pgfsys at markposition 
+                    { \@@_env: - \int_use:N \c at iRow - \int_use:N \c at jCol - NW } 
+%    \end{macrocode}
+% I don't know why the following adjustement is needed when the compilation is
+% done with XeLaTeX or with the classical way |latex|, |divps|, |ps2pdf| (or
+% Adobe Distiller). However, it seems to work.
+%    \begin{macrocode}
+                  #1 
+                }
+            \box_use:N \l_@@_cell_box 
+            \box_move_down:nn { \box_dp:N \l_@@_cell_box }
+              \hbox_overlap_left:n 
+                { 
+                  \pgfsys at markposition 
+                    { \@@_env: - \int_use:N \c at iRow - \int_use:N \c at jCol - SE } 
+                  #1 
+                }
+          }
+      }
+  } 
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+\bool_lazy_or:nnTF \sys_if_engine_xetex_p: \sys_if_output_dvi_p:
+  {
+    \@@_patch_node_for_cell:n 
+      { \skip_horizontal:n { 0.5 \box_wd:N \l_@@_cell_box } }
+  }
+  { \@@_patch_node_for_cell:n { } }
+%    \end{macrocode}
 % 
+% 
 % \interitem
 % The second argument of the following command |\@@_instruction_of_type:nnn|
 % defined below is the type of the instruction (|Cdots|, |Vdots|, |Ddots|,
@@ -7450,7 +7522,7 @@
     \peek_meaning:NTF [ 
       { \newcol@ #1 }
       { \newcol@ #1 [ 0 ] }
-  }
+  }   
 %    \end{macrocode}
 % 
 %
@@ -7679,139 +7751,14 @@
 %    \end{macrocode}
 % This is the end of |\@@_pre_array_ii:|.
 %
+%
 % \bigskip
-% If the key |code-before| is used, we have to create the |col| nodes and the
-% |row| nodes before the creation of the array. First, we have to test whether
-% the size of the array has been written in the |aux| file in a previous run. In 
-% this case, a command |\@@_size_|{\slshape\ttfamily nb_of_env}|:| has been
-% created. 
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_pre_array:
   {
     \seq_gclear:N \g_@@_submatrix_seq
-    \bool_if:NT \l_@@_code_before_bool
-      { 
+    \bool_if:NT \l_@@_code_before_bool \@@_exec_code_before:
 %    \end{macrocode}
-% The list of the cells which are in the (empty) corners is stored in the |aux|
-% file because we have to know it before the execution of the |\CodeBefore| (the
-% commands which color the cells, row and columns won't color the cells which
-% are in the corners).
-%    \begin{macrocode}
-        \seq_if_exist:cT
-          { c_@@_corners_cells_ \int_use:N \g_@@_env_int _ seq }   
-          { 
-            \seq_set_eq:Nc \l_@@_corners_cells_seq
-              { c_@@_corners_cells_ \int_use:N \g_@@_env_int _ seq }
-          }
-%    \end{macrocode}
-% Now, we have to reconstruct the |row| nodes and the |col| nodes.
-%    \begin{macrocode}
-        \seq_if_exist:cT { @@_size_ \int_use:N \g_@@_env_int _ seq }
-          { 
-%    \end{macrocode}
-% First, we give values to the LaTeX counters |iRow| and |jCol|. We remind that,
-% in the |code-before| (and in the |\CodeAfter|) they represent the numbers of
-% rows and columns of the array (without the potential last row and last column).
-%    \begin{macrocode}
-            \int_zero_new:N \c at iRow
-            \int_set:Nn \c at iRow
-              { \seq_item:cn { @@_size_ \int_use:N \g_@@_env_int _ seq } 2 }
-            \int_zero_new:N \c at jCol
-            \int_set:Nn \c at jCol
-              { \seq_item:cn { @@_size_ \int_use:N \g_@@_env_int _ seq } 4 }
-%    \end{macrocode}
-% We have to adjust the values of |\c at iRow| and |\c at jCol| to take into account
-% the potential last row and last column. A value of $-2$ for
-% |\l_@@_last_row_int| means that there is no last row. Idem for the columns.
-%    \begin{macrocode}
-            \int_compare:nNnF \l_@@_last_row_int = { -2 } 
-              { \int_decr:N \c at iRow } 
-            \int_compare:nNnF \l_@@_last_col_int = { -2 } 
-              { \int_decr:N \c at jCol } 
-%    \end{macrocode}
-%
-% Now, we will create all the |col| nodes and |row| nodes with the informations
-% written in the |aux| file. You use the technique described in the page~1229 of
-% |pgfmanual.pdf|, version~3.1.4b.
-%    \begin{macrocode}
-            \pgfsys at markposition { \@@_env: - position }
-            \pgfsys at getposition { \@@_env: - position } \@@_picture_position: 
-            \pgfpicture
-%    \end{macrocode}
-% First, the creation of the |row| nodes.
-%    \begin{macrocode}
-            \int_step_inline:nnn 
-              { \seq_item:cn { @@_size_ \int_use:N \g_@@_env_int _ seq } 1 }
-              { \seq_item:cn { @@_size_ \int_use:N \g_@@_env_int _ seq } 2 + 1 }
-              {
-                \pgfsys at getposition { \@@_env: - row - ##1 } \@@_node_position:
-                \pgfcoordinate { \@@_env: - row - ##1 }
-                  { \pgfpointdiff \@@_picture_position: \@@_node_position: }
-              }
-%    \end{macrocode}
-% Now, the creation of the |col| nodes.
-%    \begin{macrocode}
-            \int_step_inline:nnn 
-              { \seq_item:cn { @@_size_ \int_use:N \g_@@_env_int _ seq } 3 }
-              { \seq_item:cn { @@_size_ \int_use:N \g_@@_env_int _ seq } 4 + 1 }
-              {
-                \pgfsys at getposition { \@@_env: - col - ##1 } \@@_node_position:
-                \pgfcoordinate { \@@_env: - col - ##1 }
-                  { \pgfpointdiff \@@_picture_position: \@@_node_position: }
-              }
-            \endpgfpicture
-%    \end{macrocode}
-% Now, you create the diagonal nodes by using the |row| nodes and the |col|
-% nodes. If the engine is |xetex| or |luatex| we also create the ``½ nodes''.
-%    \begin{macrocode}
-            \@@_create_diag_nodes:
-%    \end{macrocode}
-%
-% \medskip
-% Now, yet other settings before the execution of the |code-before|.
-%    \begin{macrocode}
-            \group_begin:
-              \bool_if:NT \c_@@_tikz_loaded_bool
-                {  
-                  \tikzset
-                    { 
-                      every~picture / .style = 
-                        { overlay , name~prefix = \@@_env: - }
-                    }  
-                }       
-              \cs_set_eq:NN \cellcolor \@@_cellcolor
-              \cs_set_eq:NN \rectanglecolor \@@_rectanglecolor
-              \cs_set_eq:NN \roundedrectanglecolor \@@_roundedrectanglecolor
-              \cs_set_eq:NN \rowcolor \@@_rowcolor
-              \cs_set_eq:NN \rowcolors \@@_rowcolors
-              \cs_set_eq:NN \arraycolor \@@_arraycolor
-              \cs_set_eq:NN \columncolor \@@_columncolor
-              \cs_set_eq:NN \chessboardcolors \@@_chessboardcolors
-              \cs_set_eq:NN \SubMatrix \@@_SubMatrix_in_code_before
-%    \end{macrocode}
-% We compose the |code-before| in math mode in order to nullify the spaces put
-% by the user between instructions in the |code-before|.
-%    \begin{macrocode}
-              \bool_if:NT \l_@@_NiceTabular_bool \c_math_toggle_token
-              \seq_gclear_new:N \g_@@_colors_seq
-%    \end{macrocode}
-% Here is the |\CodeBefore|. As of now, the keys that may be provided to the
-% keyword |\CodeBefore| are the same as keys that may be provided to
-% |\CodeAfter|, hence the |\@@_CodeAfter_keys:|.
-%    \begin{macrocode}
-              \exp_last_unbraced:NV \@@_CodeAfter_keys: \l_@@_code_before_tl 
-%    \end{macrocode}
-% Now, all the cells which are specified to be colored by instructions in the
-% |\CodeBefore| will actually be colored. It's a two-stages mechanism because we
-% want to draw all the cells with the same color at the same time to absolutely
-% avoid thin white lines in some \textsc{pdf} viewers.
-%    \begin{macrocode}
-              \@@_actually_color:
-              \bool_if:NT \l_@@_NiceTabular_bool \c_math_toggle_token
-            \group_end:
-          }
-      }
-%    \end{macrocode}
 % 
 % A value of $-1$ for the counter |\l_@@_last_row_int| means that the user has
 % used the option |last-row| without value, that is to say without specifying
@@ -7854,7 +7801,6 @@
       }
 %    \end{macrocode}
 %
-%
 % A value of $-1$ for the counter |\l_@@_last_col_int| means that the user has
 % used the option |last-col| without value, that is to say without specifying
 % the number of that last column. In this case, we try to read that value from
@@ -7885,7 +7831,6 @@
 %    \begin{macrocode}
     \@@_pre_array_ii:
 %    \end{macrocode}
-%
 % 
 % \medskip
 % The array will be composed in a box (named |\l_@@_the_array_box|) because we
@@ -7908,7 +7853,6 @@
 %    \begin{macrocode}
     \@@_construct_preamble:
 %    \end{macrocode}
-%
 % Now, the preamble is constructed in |\g_@@_preamble_tl|
 %
 % \medskip
@@ -7918,7 +7862,7 @@
 %    \begin{macrocode}
     \dim_zero_new:N \l_@@_left_delim_dim
     \dim_zero_new:N \l_@@_right_delim_dim
-    \bool_if:NTF \g_@@_NiceArray_bool
+    \bool_if:NTF \l_@@_NiceArray_bool
       { 
         \dim_gset:Nn \l_@@_left_delim_dim { 2 \arraycolsep }
         \dim_gset:Nn \l_@@_right_delim_dim { 2 \arraycolsep }
@@ -7933,8 +7877,6 @@
         \dim_set:Nn \l_@@_right_delim_dim { \box_wd:N \l_tmpa_box }
       }
 %    \end{macrocode}
-%
-%
 % 
 % \bigskip
 % Here is the beginning of the box which will contain the array. The
@@ -7972,8 +7914,228 @@
   }
 %    \end{macrocode}
 %
+%
+% \bigskip
+% \subsection*{The \textbackslash CodeBefore}
 % 
+% The following command will be executed if the |\CodeBefore| has to be actually executed.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_pre_code_before:
+  {
+%    \end{macrocode}
+% First, we give values to the LaTeX counters |iRow| and |jCol|. We remind that,
+% in the |code-before| (and in the |\CodeAfter|) they represent the numbers of
+% rows and columns of the array (without the potential last row and last column).
+%    \begin{macrocode}
+    \int_zero_new:N \c at iRow
+    \int_set:Nn \c at iRow
+      { \seq_item:cn { @@_size_ \int_use:N \g_@@_env_int _ seq } 2 }
+    \int_zero_new:N \c at jCol
+    \int_set:Nn \c at jCol
+      { \seq_item:cn { @@_size_ \int_use:N \g_@@_env_int _ seq } 4 }
+%    \end{macrocode}
+% We have to adjust the values of |\c at iRow| and |\c at jCol| to take into account
+% the potential last row and last column. A value of $-2$ for
+% |\l_@@_last_row_int| means that there is no last row. Idem for the columns.
+%    \begin{macrocode}
+    \int_compare:nNnF \l_@@_last_row_int = { -2 } 
+      { \int_decr:N \c at iRow } 
+    \int_compare:nNnF \l_@@_last_col_int = { -2 } 
+      { \int_decr:N \c at jCol } 
+%    \end{macrocode}
+%
+% Now, we will create all the |col| nodes and |row| nodes with the informations
+% written in the |aux| file. You use the technique described in the page~1229 of
+% |pgfmanual.pdf|, version~3.1.4b.
+%    \begin{macrocode}
+    \pgfsys at markposition { \@@_env: - position }
+    \pgfsys at getposition { \@@_env: - position } \@@_picture_position: 
+    \pgfpicture
+    \pgf at relevantforpicturesizefalse
+%    \end{macrocode}
+% First, the recreation of the |row| nodes.
+%    \begin{macrocode}
+    \int_step_inline:nnn 
+      { \seq_item:cn { @@_size_ \int_use:N \g_@@_env_int _ seq } 1 }
+      { \seq_item:cn { @@_size_ \int_use:N \g_@@_env_int _ seq } 2 + 1 }
+      {
+        \pgfsys at getposition { \@@_env: - row - ##1 } \@@_node_position:
+        \pgfcoordinate { \@@_env: - row - ##1 }
+          { \pgfpointdiff \@@_picture_position: \@@_node_position: }
+      }
+%    \end{macrocode}
+% Now, the recreation of the |col| nodes.
+%    \begin{macrocode}
+    \int_step_inline:nnn 
+      { \seq_item:cn { @@_size_ \int_use:N \g_@@_env_int _ seq } 3 }
+      { \seq_item:cn { @@_size_ \int_use:N \g_@@_env_int _ seq } 4 + 1 }
+      {
+        \pgfsys at getposition { \@@_env: - col - ##1 } \@@_node_position:
+        \pgfcoordinate { \@@_env: - col - ##1 }
+          { \pgfpointdiff \@@_picture_position: \@@_node_position: }
+      }
+%    \end{macrocode}
+% Now, you recreate the diagonal nodes by using the |row| nodes and the |col| 
+% nodes.
+%    \begin{macrocode}
+    \@@_create_diag_nodes:
+%    \end{macrocode}
+%
+% \medskip
+% Now, the creation of the cell nodes |(i-j)|.
+%    \begin{macrocode}
+    \bool_if:NT \g_@@_recreate_cell_nodes_bool \@@_recreate_cell_nodes:
+    \endpgfpicture
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+    \bool_if:NT \c_@@_tikz_loaded_bool
+      {  
+        \tikzset
+          { 
+            every~picture / .style = 
+              { overlay , name~prefix = \@@_env: - }
+          }  
+      }       
+    \cs_set_eq:NN \cellcolor \@@_cellcolor
+    \cs_set_eq:NN \rectanglecolor \@@_rectanglecolor
+    \cs_set_eq:NN \roundedrectanglecolor \@@_roundedrectanglecolor
+    \cs_set_eq:NN \rowcolor \@@_rowcolor
+    \cs_set_eq:NN \rowcolors \@@_rowcolors
+    \cs_set_eq:NN \arraycolor \@@_arraycolor
+    \cs_set_eq:NN \columncolor \@@_columncolor
+    \cs_set_eq:NN \chessboardcolors \@@_chessboardcolors
+    \cs_set_eq:NN \SubMatrix \@@_SubMatrix_in_code_before
+%    \end{macrocode}
+% The list of the cells which are in the (empty) corners is stored in the |aux|
+% file because we have to know it before the execution of the |\CodeBefore| (the
+% commands which color the cells, rows and columns won't color the cells which
+% are in the corners).
+%    \begin{macrocode}
+    \seq_if_exist:cT
+      { c_@@_corners_cells_ \int_use:N \g_@@_env_int _ seq }   
+      { 
+        \seq_set_eq:Nc \l_@@_corners_cells_seq
+          { c_@@_corners_cells_ \int_use:N \g_@@_env_int _ seq }
+      }
+  }
+%    \end{macrocode}
+% 
 % \bigskip
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_exec_code_before:
+  { 
+    \seq_gclear_new:N \g_@@_colors_seq
+    \bool_gset_false:N \g_@@_recreate_cell_nodes_bool
+    \group_begin:
+%    \end{macrocode}
+%
+% We compose the |code-before| in math mode in order to nullify the spaces put
+% by the user between instructions in the |code-before|.
+%    \begin{macrocode}
+    \bool_if:NT \l_@@_NiceTabular_bool \c_math_toggle_token
+%    \end{macrocode}
+%
+% Here is the |\CodeBefore|. The construction is a bit complicated because
+% |\l_@@_code_before_tl| may begin with keys between square brackets. Moreover,
+% after the analyze of those keys, we sometimes have to decide to do \emph{not}
+% execute the rest of |\l_@@_code_before_tl| (when it is asked for the creation
+% of cell nodes in the |\CodeBefore|). That's why we begin with a |\q_stop|: it
+% will be used to discard the rest of |\l_@@_code_before_tl|.
+%    \begin{macrocode}
+    \exp_last_unbraced:NV \@@_CodeBefore_keys: \l_@@_code_before_tl \q_stop 
+%    \end{macrocode}
+% Now, all the cells which are specified to be colored by instructions in the
+% |\CodeBefore| will actually be colored. It's a two-stages mechanism because we
+% want to draw all the cells with the same color at the same time to absolutely
+% avoid thin white lines in some \textsc{pdf} viewers.
+%    \begin{macrocode}
+    \@@_actually_color:
+    \bool_if:NT \l_@@_NiceTabular_bool \c_math_toggle_token
+    \group_end:
+    \bool_if:NT \g_@@_recreate_cell_nodes_bool
+      { \tl_put_left:Nn \@@_node_for_cell: \@@_patch_node_for_cell: } 
+  } 
+%    \end{macrocode}
+%
+% \bigskip 
+%    \begin{macrocode}
+\keys_define:nn { NiceMatrix / CodeBefore }
+  {
+    create-cell-nodes .bool_gset:N = \g_@@_recreate_cell_nodes_bool ,
+    create-cell-nodes .default:n = true ,
+    sub-matrix .code:n = \keys_set:nn { NiceMatrix / sub-matrix } { #1 } , 
+    sub-matrix .value_required:n = true ,
+    delimiters / color .tl_set:N = \l_@@_delimiters_color_tl ,
+    delimiters / color .value_required:n = true ,
+    unknown .code:n = \@@_error:n { Unknown~key~for~CodeAfter }
+  }
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+\NewDocumentCommand \@@_CodeBefore_keys: { O { } }
+  { 
+    \keys_set:nn { NiceMatrix / CodeBefore } { #1 } 
+    \@@_CodeBefore:w 
+  }
+%    \end{macrocode}
+%
+% We have extracted the options of the keyword |\CodeBefore| in order to see
+% whether the key |create-cell-nodes| has been used. Now, you can execute the
+% rest of the |\CodeAfter|, excepted, of course, if we are in the first
+% compilation. 
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_CodeBefore:w #1 \q_stop
+  { 
+    \seq_if_exist:cT { @@_size_ \int_use:N \g_@@_env_int _ seq } 
+      { 
+        \@@_pre_code_before: 
+        #1 
+      } 
+  }
+%    \end{macrocode}
+%
+% \bigskip
+%
+%
+% \bigskip
+% By default, if the user uses the |\CodeBefore|, only the |col| nodes, |row|
+% nodes and |diag| nodes are available in that |\CodeBefore|. With the key
+% |create-cell-nodes|, the cell nodes, that is to say the nodes of the form
+% |(i-j)| (but not the extra nodes) are also available because those nodes also
+% are recreated and that recreation is done by the following command.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_recreate_cell_nodes:
+  {
+    \int_step_inline:nnn 
+      { \seq_item:cn { @@_size_ \int_use:N \g_@@_env_int _ seq } 1 }
+      { \seq_item:cn { @@_size_ \int_use:N \g_@@_env_int _ seq } 2 }
+      {
+        \int_step_inline:nnn 
+          { \seq_item:cn { @@_size_ \int_use:N \g_@@_env_int _ seq } 3 }
+          { \seq_item:cn { @@_size_ \int_use:N \g_@@_env_int _ seq } 4 }
+          {
+            \cs_if_exist:cT
+              { pgf @ sys @ pdf @ mark @ pos @ \@@_env: - ##1 - ####1 - NW }
+              {
+                \pgfsys at getposition 
+                  { \@@_env: - ##1 - ####1 - NW }
+                  \@@_node_position: 
+                \pgfsys at getposition 
+                  { \@@_env: - ##1 - ####1 - SE }
+                  \@@_node_position_i: 
+                \@@_pgf_rect_node:nnn
+                  { \@@_env: - ##1 - ####1 }
+                  { \pgfpointdiff \@@_picture_position: \@@_node_position: }
+                  { \pgfpointdiff \@@_picture_position: \@@_node_position_i: }
+              }
+          }
+      }
+  }
+%    \end{macrocode}
+%
+% 
+% \bigskip
 % \subsection*{The environment \{NiceArrayWithDelims\}}
 %
 %    \begin{macrocode}
@@ -8076,7 +8238,7 @@
 % of |{NiceArray}| (|{pNiceArray}|, |{bNiceArray}|, etc.) because, for
 % |{NiceArray}|, we have the options |t|, |c|, |b| and |baseline|.
 %    \begin{macrocode}
-    \bool_if:NTF \g_@@_NiceArray_bool 
+    \bool_if:NTF \l_@@_NiceArray_bool 
       { \keys_set:nn { NiceMatrix / NiceArray } }
       { \keys_set:nn { NiceMatrix / pNiceArray } }
     { #3 , #5 } 
@@ -8167,7 +8329,7 @@
       }
 %    \end{macrocode}
 %
-% The construction of the real box is different when |\g_@@_NiceArray_bool| is
+% The construction of the real box is different when |\l_@@_NiceArray_bool| is
 % true (|{NiceArray}| or |{NiceTabular}|) and in the other environments because,
 % in |{NiceArray}| or |{NiceTabular}|, we have no delimiter to put (but we have
 % tabular notes to put). We begin with this case. 
@@ -8174,7 +8336,7 @@
 %
 % Remark that, in all cases, |@@_use_arraybox_with_notes_c:| is used.
 %    \begin{macrocode}
-    \bool_if:NTF \g_@@_NiceArray_bool
+    \bool_if:NTF \l_@@_NiceArray_bool
       { 
         \str_case:VnF \l_@@_baseline_tl 
           { 
@@ -8338,9 +8500,9 @@
 % the end).
 %    \begin{macrocode}
     \bool_if:NF \l_@@_Matrix_bool
-      {
-        \@@_newcolumntype w [ 2 ] { \@@_w: { ##1 } { ##2 } }
-        \@@_newcolumntype W [ 2 ] { \@@_W: { ##1 } { ##2 } }
+     {
+       \@@_newcolumntype w [ 2 ] { \@@_w: { ##1 } { ##2 } }
+       \@@_newcolumntype W [ 2 ] { \@@_W: { ##1 } { ##2 } }
 %    \end{macrocode}
 %
 % First, we have to store our preamble in the token register |\@temptokena|
@@ -8394,18 +8556,10 @@
 %    \begin{macrocode}
         \int_zero:N \l_tmpa_int
 %    \end{macrocode}
-% We will raise |\l_tmpa_bool| if we are in |{NiceArray}| and that the first
-% letter of the preamble is a opening delimiter (|[|, |(| of |\{|). In that
-% case, the environment |{NiceArray}| will be transformed to an environment of
-% the form |{xNiceArray}| after the construction of the preamble.
-%    \begin{macrocode}
-        \bool_set_false:N \l_tmpa_bool
-%    \end{macrocode}
 % Now, we actually patch the preamble (and it is constructed in
 % |\g_@@_preamble_tl|). 
 %    \begin{macrocode}
         \exp_after:wN \@@_patch_preamble:n \the \@temptokena \q_stop
-        \bool_if:NT \l_tmpa_bool { \bool_gset_false:N \g_@@_NiceArray_bool } 
         \int_gset_eq:NN \g_@@_static_num_of_col_int \c at jCol
       }
 %    \end{macrocode}
@@ -8421,6 +8575,23 @@
           \g_@@_preamble_tl
       }
 %    \end{macrocode}
+%
+% \medskip
+% Now, we can close the TeX group which was opened for the redefinition of
+% the columns of type |w| and |W|. 
+%    \begin{macrocode}
+    \group_end:
+%    \end{macrocode}
+%
+% \medskip
+% If there was delimiters at the beginning or at the end of the preamble, the
+% environment |{NiceArray}| is transformed into an environment |{xNiceMatrix}|.
+%    \begin{macrocode}
+    \bool_lazy_or:nnT 
+      { ! \str_if_eq_p:Vn \g_@@_left_delim_tl { . } }
+      { ! \str_if_eq_p:Vn \g_@@_right_delim_tl { . } }
+      { \bool_set_false:N \l_@@_NiceArray_bool } 
+%    \end{macrocode}
 % 
 % \bigskip
 % We complete the preamble with the potential ``exterior columns''.
@@ -8430,7 +8601,7 @@
       {
         \bool_lazy_all:nT 
           { 
-            \g_@@_NiceArray_bool 
+            \l_@@_NiceArray_bool 
             { \bool_not_p:n \l_@@_NiceTabular_bool }
             { \tl_if_empty_p:N \l_@@_vlines_clist } 
             { \bool_not_p:n \l_@@_exterior_arraycolsep_bool }
@@ -8442,7 +8613,7 @@
       { 
         \bool_lazy_all:nT
           { 
-            \g_@@_NiceArray_bool 
+            \l_@@_NiceArray_bool 
             { \bool_not_p:n \l_@@_NiceTabular_bool }
             { \tl_if_empty_p:N \l_@@_vlines_clist } 
             { \bool_not_p:n \l_@@_exterior_arraycolsep_bool }
@@ -8459,13 +8630,6 @@
         \tl_gput_right:Nn \g_@@_preamble_tl 
           { > { \@@_error_too_much_cols: } l }
       } 
-%    \end{macrocode}
-%
-% \medskip
-% Now, we have to close the TeX group which was opened for the redefinition of
-% the columns of type |w| and |W|. 
-%    \begin{macrocode}
-    \group_end:
   }
 %    \end{macrocode}
 %
@@ -8488,9 +8652,9 @@
         \@@_w: { \@@_patch_preamble_v:nnnn { }                          #1 } 
         \@@_W: { \@@_patch_preamble_v:nnnn { \cs_set_eq:NN \hss \hfil } #1 } 
         \@@_true_c: { \@@_patch_preamble_vi:n #1 }
-        (  { \@@_patch_preamble_vii:n #1 }
-        [  { \@@_patch_preamble_vii:n #1 }
-        \{ { \@@_patch_preamble_vii:n #1 }
+        (  { \@@_patch_preamble_vii:nn #1 }
+        [  { \@@_patch_preamble_vii:nn #1 }
+        \{ { \@@_patch_preamble_vii:nn #1 }
         )  { \@@_patch_preamble_viii:nn #1 }       
         ]  { \@@_patch_preamble_viii:nn #1 }       
         \} { \@@_patch_preamble_viii:nn #1 }       
@@ -8677,10 +8841,9 @@
 % \medskip
 % For |(|, |[| and |\{|.
 %    \begin{macrocode}
-\cs_new_protected:Npn \@@_patch_preamble_vii:n #1 
+\cs_new_protected:Npn \@@_patch_preamble_vii:nn #1 #2
   {
-    \bool_if:NT \l_@@_small_bool
-      { \@@_fatal:n { Delimiter~with~small } }
+    \bool_if:NT \l_@@_small_bool { \@@_fatal:n { Delimiter~with~small } }
 %    \end{macrocode}
 % If we are before the column 1 and not in |{NiceArray}|, we reserve space for
 % the left delimiter. 
@@ -8687,7 +8850,7 @@
 %    \begin{macrocode}
     \int_compare:nNnTF \c at jCol = \c_zero_int 
       { 
-        \bool_if:NTF \g_@@_NiceArray_bool
+        \str_if_eq:VnTF \g_@@_left_delim_tl { . }
           { 
 %    \end{macrocode}
 % In that case, in fact, the firt letter of the preamble must be considered as
@@ -8695,40 +8858,33 @@
 %    \begin{macrocode}
             \tl_gset:Nn \g_@@_left_delim_tl { #1 } 
             \tl_gset:Nn \g_@@_right_delim_tl { . }
-%    \end{macrocode}
-% We raise the boolean |\l_tmpa_bool|, which means that the environment
-% |{NiceArray}| will be transformed to |{xNiceArray}|.
-%    \begin{macrocode}
-            \bool_set_true:N \l_tmpa_bool
-            \@@_patch_preamble:n 
+            \@@_patch_preamble:n #2 
           }
           {  
             \tl_gput_right:Nn \g_@@_preamble_tl { ! { \enskip } } 
             \tl_gput_right:Nx \g_@@_internal_code_after_tl
               { \@@_delimiter:nnn #1 { \@@_succ:n \c at jCol } \c_true_bool }  
-            \@@_patch_preamble_vii_i:n 
+            \tl_if_in:nnTF { ( [ \{ ) ] \} } { #2 }
+              {
+                \@@_error:nn { delimiter~after~opening } { #2 } 
+                \@@_patch_preamble:n
+              }
+              { \@@_patch_preamble:n #2 }
           }
       }
       {
         \tl_gput_right:Nx \g_@@_internal_code_after_tl
           { \@@_delimiter:nnn #1 { \@@_succ:n \c at jCol } \c_true_bool }  
-        \@@_patch_preamble_vii_i:n 
+        \tl_if_in:nnTF { ( [ \{ ) ] \} } { #2 }
+          {
+            \@@_error:nn { delimiter~after~opening } { #2 } 
+            \@@_patch_preamble:n
+          }
+          { \@@_patch_preamble:n #2 }
       }
   }
 %    \end{macrocode}
 %
-% \bigskip
-%    \begin{macrocode}
-\cs_new_protected:Npn \@@_patch_preamble_vii_i:n #1
-  {
-    \tl_if_in:nnTF { ( [ \{ ) ] \} } { #1 }
-      {
-        \@@_error:nn { delimiter~after~opening } { #1 } 
-        \@@_patch_preamble:n
-      }
-      { \@@_patch_preamble:n #1 }
-  }
-%    \end{macrocode}
 % 
 % \bigskip
 % For |)|, |]| and |\}|. We have two arguments for the following command because
@@ -8735,28 +8891,20 @@
 % we directly read the following letter in the preamble (we have to see whether
 % we have a opening delimiter following and we also have to see whether we are
 % at the end of the preamble because, in that case, our letter must be
-% considered as the right delimiter of the environment).
+% considered as the right delimiter of the environment if the environment is
+% |{NiceArray}|). 
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_patch_preamble_viii:nn #1 #2
   {
-    \bool_if:NT \l_@@_small_bool
-      { \@@_fatal:n { Delimiter~with~small } }
+    \bool_if:NT \l_@@_small_bool { \@@_fatal:n { Delimiter~with~small } }
     \tl_if_in:nnTF { ) ] \} } { #2 }
+      { \@@_patch_preamble_viii_i:nnn #1 #2 }
       { 
-        \tl_gput_right:Nx \g_@@_internal_code_after_tl
-          { \@@_delimiter:nnn #1 { \int_use:N \c at jCol } \c_false_bool }
-        \@@_error:nn { double~closing~delimiter } { #2 } 
-        \@@_patch_preamble:n
-      }
-      { 
         \tl_if_eq:nnTF { \q_stop } { #2 }
           {
-            \bool_if:NTF \g_@@_NiceArray_bool 
+            \str_if_eq:VnTF \g_@@_right_delim_tl { . }
+              { \tl_gset:Nn \g_@@_right_delim_tl { #1 } }
               {
-                \tl_gset:Nn \g_@@_right_delim_tl { #1 }
-                \bool_set_true:N \l_tmpa_bool
-              }
-              {
                 \tl_gput_right:Nn \g_@@_preamble_tl { ! { \enskip } } 
                 \tl_gput_right:Nx \g_@@_internal_code_after_tl
                   { \@@_delimiter:nnn #1 { \int_use:N \c at jCol } \c_false_bool }
@@ -8774,8 +8922,35 @@
   }
 %    \end{macrocode}
 %
-%
 %    \begin{macrocode}
+\cs_new_protected:Npn \@@_patch_preamble_viii_i:nnn #1 #2 #3
+  {
+    \tl_if_eq:nnTF { \q_stop } { #3 }
+      {
+        \str_if_eq:VnTF \g_@@_right_delim_tl { . }
+          {
+            \tl_gput_right:Nn \g_@@_preamble_tl { ! { \enskip } } 
+            \tl_gput_right:Nx \g_@@_internal_code_after_tl
+              { \@@_delimiter:nnn #1 { \int_use:N \c at jCol } \c_false_bool }
+            \tl_gset:Nn \g_@@_right_delim_tl { #2 }
+          }
+          {
+            \tl_gput_right:Nn \g_@@_preamble_tl { ! { \enskip } } 
+            \tl_gput_right:Nx \g_@@_internal_code_after_tl
+              { \@@_delimiter:nnn #1 { \int_use:N \c at jCol } \c_false_bool }
+            \@@_error:nn { double~closing~delimiter } { #2 } 
+          }
+      }
+      {
+        \tl_gput_right:Nx \g_@@_internal_code_after_tl
+          { \@@_delimiter:nnn #1 { \int_use:N \c at jCol } \c_false_bool }
+        \@@_error:nn { double~closing~delimiter } { #2 } 
+        \@@_patch_preamble:n #3 
+      }
+  }
+%    \end{macrocode}
+% 
+%    \begin{macrocode}
 \cs_new_protected:Npn \@@_patch_preamble_xi:n #1
   {
     \tl_gput_right:Nn \g_@@_preamble_tl
@@ -9510,7 +9685,7 @@
         \hbox_overlap_left:n
           { 
             \dim_compare:nNnTF { \box_wd:N \l_@@_cell_box } > \c_zero_dim
-              \@@_node_for_the_cell:
+              \@@_node_for_cell:
               { \box_use_drop:N \l_@@_cell_box }
             \skip_horizontal:N \l_@@_left_delim_dim
             \skip_horizontal:N \l_@@_left_margin_dim 
@@ -9591,7 +9766,7 @@
                 \skip_horizontal:N \l_@@_right_delim_dim 
                 \skip_horizontal:N \l_@@_right_margin_dim 
                 \skip_horizontal:N \l_@@_extra_right_margin_dim
-                \@@_node_for_the_cell:
+                \@@_node_for_cell:
               }
           } 
         \bool_gset_false:N \g_@@_empty_cell_bool
@@ -9602,19 +9777,19 @@
 %
 % \interitem
 % The environment |{NiceArray}| is constructed upon the environment
-% |{NiceArrayWithDelims}| but, in fact, there is a flag |\g_@@_NiceArray_bool|.
+% |{NiceArrayWithDelims}| but, in fact, there is a flag |\l_@@_NiceArray_bool|.
 % In |{NiceArrayWithDelims}|, some special code will be executed if this flag is
 % raised. 
 %    \begin{macrocode}
 \NewDocumentEnvironment { NiceArray } { }
   { 
-    \bool_gset_true:N \g_@@_NiceArray_bool
+    \bool_set_true:N \l_@@_NiceArray_bool
     \str_if_empty:NT \g_@@_name_env_str 
       { \str_gset:Nn \g_@@_name_env_str { NiceArray } }  
 %    \end{macrocode}
 % We put . and . for the delimiters but, in fact, that doesn't matter because
 % these arguments won't be used in |{NiceArrayWithDelims}| (because the flag
-% |\g_@@_NiceArray_bool| is raised).
+% |\l_@@_NiceArray_bool| is raised).
 %    \begin{macrocode} 
     \NiceArrayWithDelims . . 
   }
@@ -9803,7 +9978,7 @@
 %    \end{macrocode}
 % 
 % If the key |code-before| is used, we have to write on the |aux| file the actual
-% size of the array.
+% size of the array and other informations.
 %    \begin{macrocode}
     \bool_if:NT \l_@@_code_before_bool
       {
@@ -9837,12 +10012,13 @@
               { c_@@_pos_of_blocks_ \int_use:N \g_@@_env_int _ seq }
               { \seq_use:Nnnn \g_@@_pos_of_blocks_seq , , , }
           }
+        \iow_now:Nn \@mainaux \ExplSyntaxOff
       }
 %    \end{macrocode}
 %
 % \medskip
 % Now, you create the diagonal nodes by using the |row| nodes and the |col|
-% nodes. If the engine is |xetex| or |luatex| we also create the ``½ nodes''.
+% nodes.
 %    \begin{macrocode}
     \@@_create_diag_nodes:
 %    \end{macrocode}
@@ -10020,9 +10196,12 @@
       }
 %    \end{macrocode}
 % 
+%    \begin{macrocode}
+    % \bool_if:NT \l_@@_code_before_bool \@@_write_aux_for_cell_nodes:
+%    \end{macrocode}
+%
 % \medskip
 %    \begin{macrocode}
-    \bool_gset_false:N \g_@@_NiceArray_bool
     \str_gclear:N \g_@@_name_env_str
     \@@_restore_iRow_jCol:
 %    \end{macrocode}
@@ -10040,12 +10219,14 @@
 % \bigskip
 % The following command will extract the potential options (between square
 % brackets) at the beginning of the |\CodeAfter| (that is to say, when
-% |\CodeAfter| is used, the options of that ``command'' |\CodeAfter|).
+% |\CodeAfter| is used, the options of that ``command'' |\CodeAfter|). Idem for
+% the |\CodeBefore.|
 %    \begin{macrocode}
 \NewDocumentCommand \@@_CodeAfter_keys: { O { } }
   { \keys_set:nn { NiceMatrix / CodeAfter } { #1 } }
 %    \end{macrocode}
 %
+%
 % 
 % \bigskip
 % We remind that the first mandatory argument of the command |\Block| is the
@@ -10144,6 +10325,53 @@
   }
 %    \end{macrocode}
 % 
+%
+% \bigskip
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_write_aux_for_cell_nodes:
+  {
+    \pgfpicture
+    \pgfrememberpicturepositiononpagetrue
+    \pgf at relevantforpicturesizefalse
+    \int_step_inline:nnn \l_@@_first_row_int \g_@@_row_total_int
+      {
+        \int_step_inline:nnn \l_@@_first_col_int \g_@@_col_total_int
+          {
+            \cs_if_exist:cT { pgf @ sh @ ns @ \@@_env: - ##1 - ####1 }
+              {
+                \pgfscope
+                \pgftransformshift 
+                  { \pgfpointanchor { \@@_env: - ##1 - ####1 } { north~west } }
+                \pgfnode 
+                  { rectangle } 
+                  { center }
+                  { 
+                    \hbox 
+                      { \pgfsys at markposition { \@@_env: - ##1 - ####1 - NW } }  
+                  }
+                  { } 
+                  { }
+                \endpgfscope
+                \pgfscope
+                \pgftransformshift 
+                  { \pgfpointanchor { \@@_env: - ##1 - ####1 } { south~east } } 
+                \pgfnode
+                  { rectangle }
+                  { center }
+                  { 
+                    \hbox 
+                      { \pgfsys at markposition { \@@_env: - ##1 - ####1 - SE } } 
+                  }
+                  { }
+                  { }
+                \endpgfscope
+              }
+          }
+      }
+    \endpgfpicture
+    \@@_create_extra_nodes:
+  }
+%   \end{macrocode}
 % 
 % \bigskip
 % The following command creates the diagonal nodes (in fact, if the matrix is
@@ -12765,8 +12993,8 @@
 \cs_new_protected:Npn \@@_draw_vlines:
   {
     \int_step_inline:nnn 
-      { \bool_if:NTF \g_@@_NiceArray_bool 1 2 }
-      { \bool_if:NTF \g_@@_NiceArray_bool { \@@_succ:n \c at jCol } \c at jCol }
+      { \bool_if:NTF \l_@@_NiceArray_bool 1 2 }
+      { \bool_if:NTF \l_@@_NiceArray_bool { \@@_succ:n \c at jCol } \c at jCol }
       { 
         \tl_if_eq:NnF \l_@@_vlines_clist { all } 
           { \clist_if_in:NnT \l_@@_vlines_clist { ##1 } }
@@ -12939,8 +13167,8 @@
 \cs_new_protected:Npn \@@_draw_hlines:
   {
     \int_step_inline:nnn 
-      { \bool_if:NTF \g_@@_NiceArray_bool 1 2 }
-      { \bool_if:NTF \g_@@_NiceArray_bool { \@@_succ:n \c at iRow } \c at iRow }  
+      { \bool_if:NTF \l_@@_NiceArray_bool 1 2 }
+      { \bool_if:NTF \l_@@_NiceArray_bool { \@@_succ:n \c at iRow } \c at iRow }  
       { 
         \tl_if_eq:NnF \l_@@_hlines_clist { all } 
           { \clist_if_in:NnT \l_@@_hlines_clist { ##1 } }
@@ -13377,7 +13605,7 @@
 % We do a reduction by |\arraycolsep| for the environments with delimiters (and
 % not for the other).
 %    \begin{macrocode}
-        \bool_if:NTF \g_@@_NiceArray_bool \c_zero_dim \arraycolsep 
+        \bool_if:NTF \l_@@_NiceArray_bool \c_zero_dim \arraycolsep 
         - \l_@@_left_margin_dim 
       } 
     \@@_qpoint:n { col - \@@_succ:n \c at jCol } 
@@ -13384,7 +13612,7 @@
     \dim_set:Nn \l_@@_x_final_dim 
       {            
         \pgf at x - 
-        \bool_if:NTF \g_@@_NiceArray_bool \c_zero_dim \arraycolsep 
+        \bool_if:NTF \l_@@_NiceArray_bool \c_zero_dim \arraycolsep 
         + \l_@@_right_margin_dim 
       }
 %    \end{macrocode}
@@ -13545,7 +13773,8 @@
   }
 %    \end{macrocode}
 %
-% \bigskip
+% 
+%
 % \subsection*{The extra nodes}
 %
 % First, two variants of the functions |\dim_min:nn| and |\dim_max:nn|.
@@ -13558,7 +13787,7 @@
 % \bigskip
 % The following command is called in |\@@_use_arraybox_with_notes_c:| just
 % before the construction of the blocks (if the creation of medium nodes is
-% required, medium nodes are also created for the blocks dans that construction
+% required, medium nodes are also created for the blocks and that construction
 % uses the standard medium nodes).
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_create_extra_nodes:
@@ -14570,7 +14799,7 @@
 % 
 % \medskip
 % If the creation of the ``medium nodes'' is required, we create a ``medium
-% node'' for the block. The function |\@@_pgf_rect_node:nnnnn| takes in as
+% node'' for the block. The function |\@@_pgf_rect_node:nnn| takes in as
 % arguments the name of the node and two \textsc{pgf} points.
 %    \begin{macrocode}
     \bool_if:NT \l_@@_medium_nodes_bool
@@ -15013,13 +15242,14 @@
 %    \end{macrocode}
 %
 % \bigskip
-% We define also an command |\AutoNiceMatrix| similar to the environment |{NiceMatrix}|.
+% We define also a command |\AutoNiceMatrix| similar to the environment |{NiceMatrix}|.
 %    \begin{macrocode}
 \NewDocumentCommand \AutoNiceMatrix { O { } m O { } m ! O { } } 
   {
-    \bool_gset_true:N \g_@@_NiceArray_bool
+    \group_begin:
+    \bool_set_true:N \l_@@_NiceArray_bool
     \AutoNiceMatrixWithDelims . . { #2 } { #4 } [ #1 , #3 , #5 ] 
-    \bool_gset_false: \g_@@_NiceArray_bool
+    \group_end:
   }
 %    \end{macrocode}
 % 
@@ -16010,18 +16240,7 @@
 %    \end{macrocode}
 % 
 %
-% \medskip
-% The following message will be deleted when we will delete the key
-% |delimiters-color| (and keep only the key |delimiters/color|).
 %    \begin{macrocode}
-\@@_msg_new:nn { delimiters-color deleted }
-  { 
-    The~key~'delimiters-color'~has~been~renamed~'delimiters/color'.\\
-    ~However,~you~can~go~on~for~this~time.
-  }
-%    \end{macrocode}
-%
-%    \begin{macrocode}
 \seq_new:N \c_@@_types_of_matrix_seq
 \seq_set_from_clist:Nn \c_@@_types_of_matrix_seq
   { 
@@ -16579,7 +16798,7 @@
     create-extra-nodes,~
     create-medium-nodes,~
     create-large-nodes,~
-    delimiters/color,~
+    delimiters~(several~subkeys),~
     end-of-row,~
     first-col,~
     first-row,~
@@ -16689,7 +16908,7 @@
     create-extra-nodes,~
     create-medium-nodes,~
     create-large-nodes,~
-    delimiters/color,~
+    delimiters~(several~subkeys),~
     extra-left-margin,~
     extra-right-margin,~
     first-col,~
@@ -17271,6 +17490,9 @@
 % It's now possible to specify delimiters for submatrices in the preamble of an
 % environment. 
 % 
+%
+% \subsection*{Changes between versions 5.15 and 5.16}
+%
 % \PrintIndex
 % 
 % \tableofcontents

Modified: trunk/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty	2021-05-06 20:23:37 UTC (rev 59104)
+++ trunk/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty	2021-05-06 20:23:54 UTC (rev 59105)
@@ -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{5.15}
-\def\myfiledate{2021/04/25}
+\def\myfileversion{5.15a}
+\def\myfiledate{2021/05/06}
 \RequirePackage{pgfcore}
 \usepgfmodule{shapes}
 \RequirePackage{l3keys2e}
@@ -256,6 +256,8 @@
   { \pgfpointanchor { \__nicematrix_env: - #1 } { center } }
 \int_new:N \g__nicematrix_NiceMatrixBlock_int
 \dim_new:N \l__nicematrix_columns_width_dim
+\int_new:N \g__nicematrix_row_total_int
+\int_new:N \g__nicematrix_col_total_int
 \tl_new:N \l__nicematrix_cell_type_tl
 \tl_set:Nn \l__nicematrix_cell_type_tl { c }
 \dim_new:N \g__nicematrix_blocks_wd_dim
@@ -263,7 +265,7 @@
 \dim_new:N \g__nicematrix_blocks_dp_dim
 \seq_new:N \g__nicematrix_names_seq
 \bool_new:N \l__nicematrix_in_env_bool
-\bool_new:N \g__nicematrix_NiceArray_bool
+\bool_new:N \l__nicematrix_NiceArray_bool
 \bool_new:N \l__nicematrix_NiceTabular_bool
 \dim_new:N \l__nicematrix_tabular_width_dim
 \bool_new:N \l__nicematrix_Matrix_bool
@@ -386,7 +388,7 @@
           }
         \NewDocumentCommand \tabularnote { m }
           {
-            \bool_if:nTF { ! \g__nicematrix_NiceArray_bool && \l__nicematrix_in_env_bool }
+            \bool_if:nTF { ! \l__nicematrix_NiceArray_bool && \l__nicematrix_in_env_bool }
               { \__nicematrix_error:n { tabularnote~forbidden } }
               {
                 \int_incr:N \l__nicematrix_number_of_notes_int
@@ -490,6 +492,7 @@
 \AtBeginDocument { \dim_set:Nn \l__nicematrix_notes_above_space_dim { 1 mm } }
 \bool_new:N \l__nicematrix_nullify_dots_bool
 \bool_new:N \l__nicematrix_auto_columns_width_bool
+\bool_new:N \g__nicematrix_recreate_cell_nodes_bool
 \str_new:N \l__nicematrix_name_str
 \bool_new:N \l__nicematrix_medium_nodes_bool
 \bool_new:N \l__nicematrix_large_nodes_bool
@@ -531,6 +534,9 @@
   }
 \keys_define:nn { NiceMatrix / Global }
   {
+    delimiters .code:n =
+      \keys_set:nn { NiceMatrix / delimiters } { #1 } ,
+    delimiters .value_required:n = true ,
     rules .code:n = \keys_set:nn { NiceMatrix / rules } { #1 } ,
     rules .value_required:n = true ,
     standard-cline .bool_set:N = \l__nicematrix_standard_cline_bool ,
@@ -600,7 +606,7 @@
   }
 \keys_define:nn { NiceMatrix / Env }
   {
-    delimiters/max-width .bool_set:N = \l__nicematrix_delimiters_max_width_bool ,
+
     hvlines-except-corners .code:n =
       {
         \clist_set:Nn \l__nicematrix_corners_clist { #1 }
@@ -697,6 +703,13 @@
     enumitem-keys-para .value_required:n = true ,
     unknown .code:n  = \__nicematrix_error:n { Unknown~key~for~notes }
   }
+\keys_define:nn { NiceMatrix / delimiters }
+  {
+    max-width .bool_set:N = \l__nicematrix_delimiters_max_width_bool ,
+    max-width .default:n = true ,
+    color .tl_set:N = \l__nicematrix_delimiters_color_tl ,
+    color .value_required:n = true ,
+  }
 \keys_define:nn { NiceMatrix }
   {
     NiceMatrixOptions .inherit:n =
@@ -704,6 +717,7 @@
     NiceMatrixOptions / xdots .inherit:n = NiceMatrix / xdots ,
     NiceMatrixOptions / rules .inherit:n = NiceMatrix / rules ,
     NiceMatrixOptions / notes .inherit:n = NiceMatrix / notes ,
+    NiceMatrixOptions / delimiters .inherit:n = NiceMatrix / delimiters ,
     NiceMatrixOptions / sub-matrix .inherit:n = NiceMatrix / sub-matrix ,
     SubMatrix / rules .inherit:n = NiceMatrix / rules ,
     CodeAfter / xdots .inherit:n = NiceMatrix / xdots ,
@@ -714,6 +728,7 @@
       } ,
     NiceMatrix / xdots .inherit:n = NiceMatrix / xdots ,
     NiceMatrix / rules .inherit:n = NiceMatrix / rules ,
+    NiceMatrix / delimiters .inherit:n = NiceMatrix / delimiters ,
     NiceTabular .inherit:n =
       {
         NiceMatrix / Global ,
@@ -721,6 +736,7 @@
       } ,
     NiceTabular / xdots .inherit:n = NiceMatrix / xdots ,
     NiceTabular / rules .inherit:n = NiceMatrix / rules ,
+    NiceTabular / delimiters .inherit:n = NiceMatrix / delimiters ,
     NiceArray .inherit:n =
       {
         NiceMatrix / Global ,
@@ -728,6 +744,7 @@
       } ,
     NiceArray / xdots .inherit:n = NiceMatrix / xdots ,
     NiceArray / rules .inherit:n = NiceMatrix / rules ,
+    NiceArray / delimiters .inherit:n = NiceMatrix / delimiters ,
     pNiceArray .inherit:n =
       {
         NiceMatrix / Global ,
@@ -735,16 +752,10 @@
       } ,
     pNiceArray / xdots .inherit:n = NiceMatrix / xdots ,
     pNiceArray / rules .inherit:n = NiceMatrix / rules ,
+    pNiceArray / delimiters .inherit:n = NiceMatrix / delimiters ,
   }
 \keys_define:nn { NiceMatrix / NiceMatrixOptions }
   {
-    delimiters / max-width .bool_set:N = \l__nicematrix_delimiters_max_width_bool ,
-    delimiters / color .tl_set:N = \l__nicematrix_delimiters_color_tl ,
-    delimiters / color .value_required:n = true ,
-    delimiters-color .code:n =
-      \tl_set:Nn \l__nicematrix_delimiters_color_tl { #1 }
-      \__nicematrix_error:n { delimiters-color deleted } ,
-    delimiters-color .value_required:n = true ,
     last-col .code:n = \tl_if_empty:nF { #1 }
                          { \__nicematrix_error:n { last-col~non~empty~for~NiceMatrixOptions } }
                        \int_zero:N \l__nicematrix_last_col_int ,
@@ -797,12 +808,6 @@
     r .code:n = \tl_set:Nn \l__nicematrix_type_of_col_tl r ,
     small .bool_set:N = \l__nicematrix_small_bool ,
     small .value_forbidden:n = true ,
-    delimiters / color .tl_set:N = \l__nicematrix_delimiters_color_tl ,
-    delimiters / color .value_required:n = true ,
-    delimiters-color .code:n =
-      \tl_set:Nn \l__nicematrix_delimiters_color_tl { #1 }
-      \__nicematrix_error:n { delimiters-color deleted } ,
-    delimiters-color .value_required:n = true ,
     unknown .code:n = \__nicematrix_error:n { Unknown~option~for~NiceMatrix }
   }
 \keys_define:nn { NiceMatrix / NiceArray }
@@ -818,11 +823,6 @@
     notes / bottomrule .default:n = true ,
     tabularnote .tl_set:N = \l__nicematrix_tabularnote_tl ,
     tabularnote .value_required:n = true ,
-    delimiters-color .code:n =
-      \tl_set:Nn \l__nicematrix_delimiters_color_tl { #1 }
-      \__nicematrix_error:n { delimiters-color deleted } ,
-    delimiters / color .tl_set:N = \l__nicematrix_delimiters_color_tl ,
-    delimiters / color .value_required:n = true ,
     r .code:n = \__nicematrix_error:n { r~or~l~with~preamble } ,
     l .code:n = \__nicematrix_error:n { r~or~l~with~preamble } ,
     unknown .code:n = \__nicematrix_error:n { Unknown~option~for~NiceArray }
@@ -973,7 +973,7 @@
         \bool_lazy_or:nnTF
           \g__nicematrix_not_empty_cell_bool
           { \dim_compare_p:nNn { \box_wd:N \l__nicematrix_cell_box } > \c_zero_dim }
-          \__nicematrix_node_for_the_cell:
+          \__nicematrix_node_for_cell:
           { \box_use_drop:N \l__nicematrix_cell_box }
       }
     \int_gset:Nn \g__nicematrix_col_total_int { \int_max:nn \g__nicematrix_col_total_int \c at jCol }
@@ -980,7 +980,7 @@
     \bool_gset_false:N \g__nicematrix_empty_cell_bool
     \bool_gset_false:N \g__nicematrix_not_empty_cell_bool
   }
-\cs_new_protected:Npn \__nicematrix_node_for_the_cell:
+\cs_new_protected:Npn \__nicematrix_node_for_cell:
   {
     \pgfpicture
     \pgfsetbaseline \c_zero_dim
@@ -1004,6 +1004,36 @@
       }
     \endpgfpicture
   }
+\cs_new_protected:Npn \__nicematrix_patch_node_for_cell:n #1
+  {
+    \cs_new_protected:Npn \__nicematrix_patch_node_for_cell:
+      {
+        \hbox_set:Nn \l__nicematrix_cell_box
+          {
+            \box_move_up:nn { \box_ht:N \l__nicematrix_cell_box}
+              \hbox_overlap_left:n
+                {
+                  \pgfsys at markposition
+                    { \__nicematrix_env: - \int_use:N \c at iRow - \int_use:N \c at jCol - NW }
+                  #1
+                }
+            \box_use:N \l__nicematrix_cell_box
+            \box_move_down:nn { \box_dp:N \l__nicematrix_cell_box }
+              \hbox_overlap_left:n
+                {
+                  \pgfsys at markposition
+                    { \__nicematrix_env: - \int_use:N \c at iRow - \int_use:N \c at jCol - SE }
+                  #1
+                }
+          }
+      }
+  }
+\bool_lazy_or:nnTF \sys_if_engine_xetex_p: \sys_if_output_dvi_p:
+  {
+    \__nicematrix_patch_node_for_cell:n
+      { \skip_horizontal:n { 0.5 \box_wd:N \l__nicematrix_cell_box } }
+  }
+  { \__nicematrix_patch_node_for_cell:n { } }
 \cs_new_protected:Npn \__nicematrix_instruction_of_type:nnn #1 #2 #3
   {
     \bool_if:nTF { #1 } \tl_gput_left:cx \tl_gput_right:cx
@@ -1205,73 +1235,7 @@
 \cs_new_protected:Npn \__nicematrix_pre_array:
   {
     \seq_gclear:N \g__nicematrix_submatrix_seq
-    \bool_if:NT \l__nicematrix_code_before_bool
-      {
-        \seq_if_exist:cT
-          { c__nicematrix_corners_cells_ \int_use:N \g__nicematrix_env_int _ seq }
-          {
-            \seq_set_eq:Nc \l__nicematrix_corners_cells_seq
-              { c__nicematrix_corners_cells_ \int_use:N \g__nicematrix_env_int _ seq }
-          }
-        \seq_if_exist:cT { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq }
-          {
-            \int_zero_new:N \c at iRow
-            \int_set:Nn \c at iRow
-              { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 2 }
-            \int_zero_new:N \c at jCol
-            \int_set:Nn \c at jCol
-              { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 4 }
-            \int_compare:nNnF \l__nicematrix_last_row_int = { -2 }
-              { \int_decr:N \c at iRow }
-            \int_compare:nNnF \l__nicematrix_last_col_int = { -2 }
-              { \int_decr:N \c at jCol }
-            \pgfsys at markposition { \__nicematrix_env: - position }
-            \pgfsys at getposition { \__nicematrix_env: - position } \__nicematrix_picture_position:
-            \pgfpicture
-            \int_step_inline:nnn
-              { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 1 }
-              { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 2 + 1 }
-              {
-                \pgfsys at getposition { \__nicematrix_env: - row - ##1 } \__nicematrix_node_position:
-                \pgfcoordinate { \__nicematrix_env: - row - ##1 }
-                  { \pgfpointdiff \__nicematrix_picture_position: \__nicematrix_node_position: }
-              }
-            \int_step_inline:nnn
-              { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 3 }
-              { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 4 + 1 }
-              {
-                \pgfsys at getposition { \__nicematrix_env: - col - ##1 } \__nicematrix_node_position:
-                \pgfcoordinate { \__nicematrix_env: - col - ##1 }
-                  { \pgfpointdiff \__nicematrix_picture_position: \__nicematrix_node_position: }
-              }
-            \endpgfpicture
-            \__nicematrix_create_diag_nodes:
-            \group_begin:
-              \bool_if:NT \c__nicematrix_tikz_loaded_bool
-                {
-                  \tikzset
-                    {
-                      every~picture / .style =
-                        { overlay , name~prefix = \__nicematrix_env: - }
-                    }
-                }
-              \cs_set_eq:NN \cellcolor \__nicematrix_cellcolor
-              \cs_set_eq:NN \rectanglecolor \__nicematrix_rectanglecolor
-              \cs_set_eq:NN \roundedrectanglecolor \__nicematrix_roundedrectanglecolor
-              \cs_set_eq:NN \rowcolor \__nicematrix_rowcolor
-              \cs_set_eq:NN \rowcolors \__nicematrix_rowcolors
-              \cs_set_eq:NN \arraycolor \__nicematrix_arraycolor
-              \cs_set_eq:NN \columncolor \__nicematrix_columncolor
-              \cs_set_eq:NN \chessboardcolors \__nicematrix_chessboardcolors
-              \cs_set_eq:NN \SubMatrix \__nicematrix_SubMatrix_in_code_before
-              \bool_if:NT \l__nicematrix_NiceTabular_bool \c_math_toggle_token
-              \seq_gclear_new:N \g__nicematrix_colors_seq
-              \exp_last_unbraced:NV \__nicematrix_CodeAfter_keys: \l__nicematrix_code_before_tl
-              \__nicematrix_actually_color:
-              \bool_if:NT \l__nicematrix_NiceTabular_bool \c_math_toggle_token
-            \group_end:
-          }
-      }
+    \bool_if:NT \l__nicematrix_code_before_bool \__nicematrix_exec_code_before:
     \int_compare:nNnT \l__nicematrix_last_row_int > { -2 }
       {
         \tl_put_right:Nn \__nicematrix_update_for_first_and_last_row:
@@ -1325,7 +1289,7 @@
     \__nicematrix_construct_preamble:
     \dim_zero_new:N \l__nicematrix_left_delim_dim
     \dim_zero_new:N \l__nicematrix_right_delim_dim
-    \bool_if:NTF \g__nicematrix_NiceArray_bool
+    \bool_if:NTF \l__nicematrix_NiceArray_bool
       {
         \dim_gset:Nn \l__nicematrix_left_delim_dim { 2 \arraycolsep }
         \dim_gset:Nn \l__nicematrix_right_delim_dim { 2 \arraycolsep }
@@ -1350,6 +1314,128 @@
     \bool_set_true:N \l__nicematrix_code_before_bool
     \__nicematrix_pre_array:
   }
+\cs_new_protected:Npn \__nicematrix_pre_code_before:
+  {
+    \int_zero_new:N \c at iRow
+    \int_set:Nn \c at iRow
+      { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 2 }
+    \int_zero_new:N \c at jCol
+    \int_set:Nn \c at jCol
+      { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 4 }
+    \int_compare:nNnF \l__nicematrix_last_row_int = { -2 }
+      { \int_decr:N \c at iRow }
+    \int_compare:nNnF \l__nicematrix_last_col_int = { -2 }
+      { \int_decr:N \c at jCol }
+    \pgfsys at markposition { \__nicematrix_env: - position }
+    \pgfsys at getposition { \__nicematrix_env: - position } \__nicematrix_picture_position:
+    \pgfpicture
+    \pgf at relevantforpicturesizefalse
+    \int_step_inline:nnn
+      { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 1 }
+      { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 2 + 1 }
+      {
+        \pgfsys at getposition { \__nicematrix_env: - row - ##1 } \__nicematrix_node_position:
+        \pgfcoordinate { \__nicematrix_env: - row - ##1 }
+          { \pgfpointdiff \__nicematrix_picture_position: \__nicematrix_node_position: }
+      }
+    \int_step_inline:nnn
+      { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 3 }
+      { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 4 + 1 }
+      {
+        \pgfsys at getposition { \__nicematrix_env: - col - ##1 } \__nicematrix_node_position:
+        \pgfcoordinate { \__nicematrix_env: - col - ##1 }
+          { \pgfpointdiff \__nicematrix_picture_position: \__nicematrix_node_position: }
+      }
+    \__nicematrix_create_diag_nodes:
+    \bool_if:NT \g__nicematrix_recreate_cell_nodes_bool \__nicematrix_recreate_cell_nodes:
+    \endpgfpicture
+    \bool_if:NT \c__nicematrix_tikz_loaded_bool
+      {
+        \tikzset
+          {
+            every~picture / .style =
+              { overlay , name~prefix = \__nicematrix_env: - }
+          }
+      }
+    \cs_set_eq:NN \cellcolor \__nicematrix_cellcolor
+    \cs_set_eq:NN \rectanglecolor \__nicematrix_rectanglecolor
+    \cs_set_eq:NN \roundedrectanglecolor \__nicematrix_roundedrectanglecolor
+    \cs_set_eq:NN \rowcolor \__nicematrix_rowcolor
+    \cs_set_eq:NN \rowcolors \__nicematrix_rowcolors
+    \cs_set_eq:NN \arraycolor \__nicematrix_arraycolor
+    \cs_set_eq:NN \columncolor \__nicematrix_columncolor
+    \cs_set_eq:NN \chessboardcolors \__nicematrix_chessboardcolors
+    \cs_set_eq:NN \SubMatrix \__nicematrix_SubMatrix_in_code_before
+    \seq_if_exist:cT
+      { c__nicematrix_corners_cells_ \int_use:N \g__nicematrix_env_int _ seq }
+      {
+        \seq_set_eq:Nc \l__nicematrix_corners_cells_seq
+          { c__nicematrix_corners_cells_ \int_use:N \g__nicematrix_env_int _ seq }
+      }
+  }
+\cs_new_protected:Npn \__nicematrix_exec_code_before:
+  {
+    \seq_gclear_new:N \g__nicematrix_colors_seq
+    \bool_gset_false:N \g__nicematrix_recreate_cell_nodes_bool
+    \group_begin:
+    \bool_if:NT \l__nicematrix_NiceTabular_bool \c_math_toggle_token
+    \exp_last_unbraced:NV \__nicematrix_CodeBefore_keys: \l__nicematrix_code_before_tl \q_stop
+    \__nicematrix_actually_color:
+    \bool_if:NT \l__nicematrix_NiceTabular_bool \c_math_toggle_token
+    \group_end:
+    \bool_if:NT \g__nicematrix_recreate_cell_nodes_bool
+      { \tl_put_left:Nn \__nicematrix_node_for_cell: \__nicematrix_patch_node_for_cell: }
+  }
+\keys_define:nn { NiceMatrix / CodeBefore }
+  {
+    create-cell-nodes .bool_gset:N = \g__nicematrix_recreate_cell_nodes_bool ,
+    create-cell-nodes .default:n = true ,
+    sub-matrix .code:n = \keys_set:nn { NiceMatrix / sub-matrix } { #1 } ,
+    sub-matrix .value_required:n = true ,
+    delimiters / color .tl_set:N = \l__nicematrix_delimiters_color_tl ,
+    delimiters / color .value_required:n = true ,
+    unknown .code:n = \__nicematrix_error:n { Unknown~key~for~CodeAfter }
+  }
+\NewDocumentCommand \__nicematrix_CodeBefore_keys: { O { } }
+  {
+    \keys_set:nn { NiceMatrix / CodeBefore } { #1 }
+    \__nicematrix_CodeBefore:w
+  }
+\cs_new_protected:Npn \__nicematrix_CodeBefore:w #1 \q_stop
+  {
+    \seq_if_exist:cT { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq }
+      {
+        \__nicematrix_pre_code_before:
+        #1
+      }
+  }
+\cs_new_protected:Npn \__nicematrix_recreate_cell_nodes:
+  {
+    \int_step_inline:nnn
+      { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 1 }
+      { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 2 }
+      {
+        \int_step_inline:nnn
+          { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 3 }
+          { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 4 }
+          {
+            \cs_if_exist:cT
+              { pgf @ sys @ pdf @ mark @ pos @ \__nicematrix_env: - ##1 - ####1 - NW }
+              {
+                \pgfsys at getposition
+                  { \__nicematrix_env: - ##1 - ####1 - NW }
+                  \__nicematrix_node_position:
+                \pgfsys at getposition
+                  { \__nicematrix_env: - ##1 - ####1 - SE }
+                  \__nicematrix_node_position_i:
+                \__nicematrix_pgf_rect_node:nnn
+                  { \__nicematrix_env: - ##1 - ####1 }
+                  { \pgfpointdiff \__nicematrix_picture_position: \__nicematrix_node_position: }
+                  { \pgfpointdiff \__nicematrix_picture_position: \__nicematrix_node_position_i: }
+              }
+          }
+      }
+  }
 \NewDocumentEnvironment { NiceArrayWithDelims }
   { m m O { } m ! O { } t \CodeBefore }
   {
@@ -1391,7 +1477,7 @@
         \exp_args:NNv \tl_put_right:Nn \l__nicematrix_code_before_tl
           { g__nicematrix_code_before_ \int_use:N \g__nicematrix_env_int _ tl }
       }
-    \bool_if:NTF \g__nicematrix_NiceArray_bool
+    \bool_if:NTF \l__nicematrix_NiceArray_bool
       { \keys_set:nn { NiceMatrix / NiceArray } }
       { \keys_set:nn { NiceMatrix / pNiceArray } }
     { #3 , #5 }
@@ -1432,7 +1518,7 @@
         \skip_horizontal:N \col at sep
         \skip_horizontal:N \g__nicematrix_width_first_col_dim
       }
-    \bool_if:NTF \g__nicematrix_NiceArray_bool
+    \bool_if:NTF \l__nicematrix_NiceArray_bool
       {
         \str_case:VnF \l__nicematrix_baseline_tl
           {
@@ -1509,9 +1595,9 @@
   {
     \group_begin:
     \bool_if:NF \l__nicematrix_Matrix_bool
-      {
-        \__nicematrix_newcolumntype w [ 2 ] { \__nicematrix_w: { ##1 } { ##2 } }
-        \__nicematrix_newcolumntype W [ 2 ] { \__nicematrix_W: { ##1 } { ##2 } }
+     {
+       \__nicematrix_newcolumntype w [ 2 ] { \__nicematrix_w: { ##1 } { ##2 } }
+       \__nicematrix_newcolumntype W [ 2 ] { \__nicematrix_W: { ##1 } { ##2 } }
         \exp_args:NV \@temptokena \g__nicematrix_preamble_tl
         \@tempswatrue
         \@whilesw \if at tempswa \fi { \@tempswafalse \the \NC at list }
@@ -1531,9 +1617,7 @@
           }
         \seq_clear:N \g__nicematrix_cols_vlism_seq
         \int_zero:N \l_tmpa_int
-        \bool_set_false:N \l_tmpa_bool
         \exp_after:wN \__nicematrix_patch_preamble:n \the \@temptokena \q_stop
-        \bool_if:NT \l_tmpa_bool { \bool_gset_false:N \g__nicematrix_NiceArray_bool }
         \int_gset_eq:NN \g__nicematrix_static_num_of_col_int \c at jCol
       }
     \bool_if:NT \l__nicematrix_colortbl_like_bool
@@ -1543,12 +1627,17 @@
           { \c { __nicematrix_columncolor_preamble } }
           \g__nicematrix_preamble_tl
       }
+    \group_end:
+    \bool_lazy_or:nnT
+      { ! \str_if_eq_p:Vn \g__nicematrix_left_delim_tl { . } }
+      { ! \str_if_eq_p:Vn \g__nicematrix_right_delim_tl { . } }
+      { \bool_set_false:N \l__nicematrix_NiceArray_bool }
     \int_compare:nNnTF \l__nicematrix_first_col_int = 0
       { \tl_gput_left:NV \g__nicematrix_preamble_tl \c__nicematrix_preamble_first_col_tl }
       {
         \bool_lazy_all:nT
           {
-            \g__nicematrix_NiceArray_bool
+            \l__nicematrix_NiceArray_bool
             { \bool_not_p:n \l__nicematrix_NiceTabular_bool }
             { \tl_if_empty_p:N \l__nicematrix_vlines_clist }
             { \bool_not_p:n \l__nicematrix_exterior_arraycolsep_bool }
@@ -1560,7 +1649,7 @@
       {
         \bool_lazy_all:nT
           {
-            \g__nicematrix_NiceArray_bool
+            \l__nicematrix_NiceArray_bool
             { \bool_not_p:n \l__nicematrix_NiceTabular_bool }
             { \tl_if_empty_p:N \l__nicematrix_vlines_clist }
             { \bool_not_p:n \l__nicematrix_exterior_arraycolsep_bool }
@@ -1572,7 +1661,6 @@
         \tl_gput_right:Nn \g__nicematrix_preamble_tl
           { > { \__nicematrix_error_too_much_cols: } l }
       }
-    \group_end:
   }
 \cs_new_protected:Npn \__nicematrix_patch_preamble:n #1
   {
@@ -1591,9 +1679,9 @@
         \__nicematrix_w: { \__nicematrix_patch_preamble_v:nnnn { }                          #1 }
         \__nicematrix_W: { \__nicematrix_patch_preamble_v:nnnn { \cs_set_eq:NN \hss \hfil } #1 }
         \__nicematrix_true_c: { \__nicematrix_patch_preamble_vi:n #1 }
-        (  { \__nicematrix_patch_preamble_vii:n #1 }
-        [  { \__nicematrix_patch_preamble_vii:n #1 }
-        \{ { \__nicematrix_patch_preamble_vii:n #1 }
+        (  { \__nicematrix_patch_preamble_vii:nn #1 }
+        [  { \__nicematrix_patch_preamble_vii:nn #1 }
+        \{ { \__nicematrix_patch_preamble_vii:nn #1 }
         )  { \__nicematrix_patch_preamble_viii:nn #1 }
         ]  { \__nicematrix_patch_preamble_viii:nn #1 }
         \} { \__nicematrix_patch_preamble_viii:nn #1 }
@@ -1722,61 +1810,51 @@
     \int_gincr:N \c at jCol
     \__nicematrix_patch_preamble_x:n
   }
-\cs_new_protected:Npn \__nicematrix_patch_preamble_vii:n #1
+\cs_new_protected:Npn \__nicematrix_patch_preamble_vii:nn #1 #2
   {
-    \bool_if:NT \l__nicematrix_small_bool
-      { \__nicematrix_fatal:n { Delimiter~with~small } }
+    \bool_if:NT \l__nicematrix_small_bool { \__nicematrix_fatal:n { Delimiter~with~small } }
     \int_compare:nNnTF \c at jCol = \c_zero_int
       {
-        \bool_if:NTF \g__nicematrix_NiceArray_bool
+        \str_if_eq:VnTF \g__nicematrix_left_delim_tl { . }
           {
             \tl_gset:Nn \g__nicematrix_left_delim_tl { #1 }
             \tl_gset:Nn \g__nicematrix_right_delim_tl { . }
-            \bool_set_true:N \l_tmpa_bool
-            \__nicematrix_patch_preamble:n
+            \__nicematrix_patch_preamble:n #2
           }
           {
             \tl_gput_right:Nn \g__nicematrix_preamble_tl { ! { \enskip } }
             \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl
               { \__nicematrix_delimiter:nnn #1 { \__nicematrix_succ:n \c at jCol } \c_true_bool }
-            \__nicematrix_patch_preamble_vii_i:n
+            \tl_if_in:nnTF { ( [ \{ ) ] \} } { #2 }
+              {
+                \__nicematrix_error:nn { delimiter~after~opening } { #2 }
+                \__nicematrix_patch_preamble:n
+              }
+              { \__nicematrix_patch_preamble:n #2 }
           }
       }
       {
         \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl
           { \__nicematrix_delimiter:nnn #1 { \__nicematrix_succ:n \c at jCol } \c_true_bool }
-        \__nicematrix_patch_preamble_vii_i:n
+        \tl_if_in:nnTF { ( [ \{ ) ] \} } { #2 }
+          {
+            \__nicematrix_error:nn { delimiter~after~opening } { #2 }
+            \__nicematrix_patch_preamble:n
+          }
+          { \__nicematrix_patch_preamble:n #2 }
       }
   }
-\cs_new_protected:Npn \__nicematrix_patch_preamble_vii_i:n #1
-  {
-    \tl_if_in:nnTF { ( [ \{ ) ] \} } { #1 }
-      {
-        \__nicematrix_error:nn { delimiter~after~opening } { #1 }
-        \__nicematrix_patch_preamble:n
-      }
-      { \__nicematrix_patch_preamble:n #1 }
-  }
 \cs_new_protected:Npn \__nicematrix_patch_preamble_viii:nn #1 #2
   {
-    \bool_if:NT \l__nicematrix_small_bool
-      { \__nicematrix_fatal:n { Delimiter~with~small } }
+    \bool_if:NT \l__nicematrix_small_bool { \__nicematrix_fatal:n { Delimiter~with~small } }
     \tl_if_in:nnTF { ) ] \} } { #2 }
+      { \__nicematrix_patch_preamble_viii_i:nnn #1 #2 }
       {
-        \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl
-          { \__nicematrix_delimiter:nnn #1 { \int_use:N \c at jCol } \c_false_bool }
-        \__nicematrix_error:nn { double~closing~delimiter } { #2 }
-        \__nicematrix_patch_preamble:n
-      }
-      {
         \tl_if_eq:nnTF { \q_stop } { #2 }
           {
-            \bool_if:NTF \g__nicematrix_NiceArray_bool
+            \str_if_eq:VnTF \g__nicematrix_right_delim_tl { . }
+              { \tl_gset:Nn \g__nicematrix_right_delim_tl { #1 } }
               {
-                \tl_gset:Nn \g__nicematrix_right_delim_tl { #1 }
-                \bool_set_true:N \l_tmpa_bool
-              }
-              {
                 \tl_gput_right:Nn \g__nicematrix_preamble_tl { ! { \enskip } }
                 \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl
                   { \__nicematrix_delimiter:nnn #1 { \int_use:N \c at jCol } \c_false_bool }
@@ -1792,6 +1870,31 @@
           }
       }
   }
+\cs_new_protected:Npn \__nicematrix_patch_preamble_viii_i:nnn #1 #2 #3
+  {
+    \tl_if_eq:nnTF { \q_stop } { #3 }
+      {
+        \str_if_eq:VnTF \g__nicematrix_right_delim_tl { . }
+          {
+            \tl_gput_right:Nn \g__nicematrix_preamble_tl { ! { \enskip } }
+            \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl
+              { \__nicematrix_delimiter:nnn #1 { \int_use:N \c at jCol } \c_false_bool }
+            \tl_gset:Nn \g__nicematrix_right_delim_tl { #2 }
+          }
+          {
+            \tl_gput_right:Nn \g__nicematrix_preamble_tl { ! { \enskip } }
+            \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl
+              { \__nicematrix_delimiter:nnn #1 { \int_use:N \c at jCol } \c_false_bool }
+            \__nicematrix_error:nn { double~closing~delimiter } { #2 }
+          }
+      }
+      {
+        \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl
+          { \__nicematrix_delimiter:nnn #1 { \int_use:N \c at jCol } \c_false_bool }
+        \__nicematrix_error:nn { double~closing~delimiter } { #2 }
+        \__nicematrix_patch_preamble:n #3
+      }
+  }
 \cs_new_protected:Npn \__nicematrix_patch_preamble_xi:n #1
   {
     \tl_gput_right:Nn \g__nicematrix_preamble_tl
@@ -2250,7 +2353,7 @@
         \hbox_overlap_left:n
           {
             \dim_compare:nNnTF { \box_wd:N \l__nicematrix_cell_box } > \c_zero_dim
-              \__nicematrix_node_for_the_cell:
+              \__nicematrix_node_for_cell:
               { \box_use_drop:N \l__nicematrix_cell_box }
             \skip_horizontal:N \l__nicematrix_left_delim_dim
             \skip_horizontal:N \l__nicematrix_left_margin_dim
@@ -2300,7 +2403,7 @@
                 \skip_horizontal:N \l__nicematrix_right_delim_dim
                 \skip_horizontal:N \l__nicematrix_right_margin_dim
                 \skip_horizontal:N \l__nicematrix_extra_right_margin_dim
-                \__nicematrix_node_for_the_cell:
+                \__nicematrix_node_for_cell:
               }
           }
         \bool_gset_false:N \g__nicematrix_empty_cell_bool
@@ -2308,7 +2411,7 @@
   }
 \NewDocumentEnvironment { NiceArray } { }
   {
-    \bool_gset_true:N \g__nicematrix_NiceArray_bool
+    \bool_set_true:N \l__nicematrix_NiceArray_bool
     \str_if_empty:NT \g__nicematrix_name_env_str
       { \str_gset:Nn \g__nicematrix_name_env_str { NiceArray } }
     \NiceArrayWithDelims . .
@@ -2443,6 +2546,7 @@
               { c__nicematrix_pos_of_blocks_ \int_use:N \g__nicematrix_env_int _ seq }
               { \seq_use:Nnnn \g__nicematrix_pos_of_blocks_seq , , , }
           }
+        \iow_now:Nn \@mainaux \ExplSyntaxOff
       }
     \__nicematrix_create_diag_nodes:
     \bool_if:NT \l__nicematrix_parallelize_diags_bool
@@ -2517,7 +2621,7 @@
         \iow_now:Nn \@mainaux \ExplSyntaxOff
         \bool_set_true:N \l__nicematrix_code_before_bool
       }
-    \bool_gset_false:N \g__nicematrix_NiceArray_bool
+    % \bool_if:NT \l__nicematrix_code_before_bool \__nicematrix_write_aux_for_cell_nodes:
     \str_gclear:N \g__nicematrix_name_env_str
     \__nicematrix_restore_iRow_jCol:
     \cs_gset_eq:NN \CT at arc@ \__nicematrix_old_CT at arc@
@@ -2579,6 +2683,49 @@
     \anchor { 5 } { \five }
     \anchor { center } { \pgfpointorigin }
   }
+\cs_new_protected:Npn \__nicematrix_write_aux_for_cell_nodes:
+  {
+    \pgfpicture
+    \pgfrememberpicturepositiononpagetrue
+    \pgf at relevantforpicturesizefalse
+    \int_step_inline:nnn \l__nicematrix_first_row_int \g__nicematrix_row_total_int
+      {
+        \int_step_inline:nnn \l__nicematrix_first_col_int \g__nicematrix_col_total_int
+          {
+            \cs_if_exist:cT { pgf @ sh @ ns @ \__nicematrix_env: - ##1 - ####1 }
+              {
+                \pgfscope
+                \pgftransformshift
+                  { \pgfpointanchor { \__nicematrix_env: - ##1 - ####1 } { north~west } }
+                \pgfnode
+                  { rectangle }
+                  { center }
+                  {
+                    \hbox
+                      { \pgfsys at markposition { \__nicematrix_env: - ##1 - ####1 - NW } }
+                  }
+                  { }
+                  { }
+                \endpgfscope
+                \pgfscope
+                \pgftransformshift
+                  { \pgfpointanchor { \__nicematrix_env: - ##1 - ####1 } { south~east } }
+                \pgfnode
+                  { rectangle }
+                  { center }
+                  {
+                    \hbox
+                      { \pgfsys at markposition { \__nicematrix_env: - ##1 - ####1 - SE } }
+                  }
+                  { }
+                  { }
+                \endpgfscope
+              }
+          }
+      }
+    \endpgfpicture
+    \__nicematrix_create_extra_nodes:
+  }
 \cs_new_protected:Npn \__nicematrix_create_diag_nodes:
   {
     \pgfpicture
@@ -4206,8 +4353,8 @@
 \cs_new_protected:Npn \__nicematrix_draw_vlines:
   {
     \int_step_inline:nnn
-      { \bool_if:NTF \g__nicematrix_NiceArray_bool 1 2 }
-      { \bool_if:NTF \g__nicematrix_NiceArray_bool { \__nicematrix_succ:n \c at jCol } \c at jCol }
+      { \bool_if:NTF \l__nicematrix_NiceArray_bool 1 2 }
+      { \bool_if:NTF \l__nicematrix_NiceArray_bool { \__nicematrix_succ:n \c at jCol } \c at jCol }
       {
         \tl_if_eq:NnF \l__nicematrix_vlines_clist { all }
           { \clist_if_in:NnT \l__nicematrix_vlines_clist { ##1 } }
@@ -4329,8 +4476,8 @@
 \cs_new_protected:Npn \__nicematrix_draw_hlines:
   {
     \int_step_inline:nnn
-      { \bool_if:NTF \g__nicematrix_NiceArray_bool 1 2 }
-      { \bool_if:NTF \g__nicematrix_NiceArray_bool { \__nicematrix_succ:n \c at iRow } \c at iRow }
+      { \bool_if:NTF \l__nicematrix_NiceArray_bool 1 2 }
+      { \bool_if:NTF \l__nicematrix_NiceArray_bool { \__nicematrix_succ:n \c at iRow } \c at iRow }
       {
         \tl_if_eq:NnF \l__nicematrix_hlines_clist { all }
           { \clist_if_in:NnT \l__nicematrix_hlines_clist { ##1 } }
@@ -4547,7 +4694,7 @@
     \dim_set:Nn \l__nicematrix_x_initial_dim
       {
         \pgf at x +
-        \bool_if:NTF \g__nicematrix_NiceArray_bool \c_zero_dim \arraycolsep
+        \bool_if:NTF \l__nicematrix_NiceArray_bool \c_zero_dim \arraycolsep
         - \l__nicematrix_left_margin_dim
       }
     \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \c at jCol }
@@ -4554,7 +4701,7 @@
     \dim_set:Nn \l__nicematrix_x_final_dim
       {
         \pgf at x -
-        \bool_if:NTF \g__nicematrix_NiceArray_bool \c_zero_dim \arraycolsep
+        \bool_if:NTF \l__nicematrix_NiceArray_bool \c_zero_dim \arraycolsep
         + \l__nicematrix_right_margin_dim
       }
     \tl_if_eq:NnF \g__nicematrix_left_delim_tl (
@@ -5536,9 +5683,10 @@
 \__nicematrix_define_com:nnn B \{ \}
 \NewDocumentCommand \AutoNiceMatrix { O { } m O { } m ! O { } }
   {
-    \bool_gset_true:N \g__nicematrix_NiceArray_bool
+    \group_begin:
+    \bool_set_true:N \l__nicematrix_NiceArray_bool
     \AutoNiceMatrixWithDelims . . { #2 } { #4 } [ #1 , #3 , #5 ]
-    \bool_gset_false: \g__nicematrix_NiceArray_bool
+    \group_end:
   }
 \cs_set_eq:NN \__nicematrix_old_dotfill \dotfill
 \cs_new_protected:Npn \__nicematrix_dotfill:
@@ -6130,11 +6278,6 @@
     the~key~'corners'~in~your~\__nicematrix_full_name_env:.\\
     If~you~go~on,~this~key~will~be~ignored.
   }
-\__nicematrix_msg_new:nn { delimiters-color deleted }
-  {
-    The~key~'delimiters-color'~has~been~renamed~'delimiters/color'.\\
-    ~However,~you~can~go~on~for~this~time.
-  }
 \seq_new:N \c__nicematrix_types_of_matrix_seq
 \seq_set_from_clist:Nn \c__nicematrix_types_of_matrix_seq
   {
@@ -6518,7 +6661,7 @@
     create-extra-nodes,~
     create-medium-nodes,~
     create-large-nodes,~
-    delimiters/color,~
+    delimiters~(several~subkeys),~
     end-of-row,~
     first-col,~
     first-row,~
@@ -6618,7 +6761,7 @@
     create-extra-nodes,~
     create-medium-nodes,~
     create-large-nodes,~
-    delimiters/color,~
+    delimiters~(several~subkeys),~
     extra-left-margin,~
     extra-right-margin,~
     first-col,~



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