summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/nicematrix/nicematrix.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/nicematrix/nicematrix.dtx')
-rw-r--r--macros/latex/contrib/nicematrix/nicematrix.dtx514
1 files changed, 380 insertions, 134 deletions
diff --git a/macros/latex/contrib/nicematrix/nicematrix.dtx b/macros/latex/contrib/nicematrix/nicematrix.dtx
index a8427171e2..b485a9139d 100644
--- a/macros/latex/contrib/nicematrix/nicematrix.dtx
+++ b/macros/latex/contrib/nicematrix/nicematrix.dtx
@@ -15,8 +15,8 @@
%
% \fi
% \iffalse
-\def\myfileversion{5.6}
-\def\myfiledate{2020/11/08}
+\def\myfileversion{5.7}
+\def\myfiledate{2020/11/23}
%
%
%<*batchfile>
@@ -459,7 +459,7 @@ version 2005/12/01 or later.
% $i$\verb|-|$j$ where $i$ is the number of rows of the block and $j$ its number
% of columns.
%
-% \colorbox{yellow!50}{\bfseries New 5.6}\enskip If this argument is empty, its
+% \colorbox{yellow!30}{New 5.6}\enskip If this argument is empty, its
% default value is |1-1|. If the number of rows is not specified, the block
% extends until the last row (idem for the columns).
%
@@ -558,7 +558,8 @@ version 2005/12/01 or later.
% \begin{BVerbatim}
% \begin{NiceTabular}~emphase#{cwc{2cm}wc{3cm}c}@
% rose & tulipe & marguerite & dahlia \\
-% violette & \Block{2-2}{\LARGE\color{blue}De très jolies fleurs} & & souci \\
+% violette
+% & \Block[draw=red,fill=red!15]{2-2}{\LARGE De très jolies fleurs} & & souci \\
% pervenche & & & lys \\
% arum & iris & jacinthe & muguet
% \end{NiceTabular}
@@ -569,12 +570,18 @@ version 2005/12/01 or later.
% \begin{center}
% \begin{NiceTabular}{cwc{2cm}wc{3cm}c}
% rose & tulipe & marguerite & dahlia \\
-% violette & \Block{2-2}{\LARGE\color{blue}De très jolies fleurs} & & souci \\
+% violette &
+% \Block[draw=red,fill=red!15]{2-2}{\LARGE De très jolies fleurs} & & souci \\
% pervenche & & & lys \\
% arum & iris & jacinthe & muguet
% \end{NiceTabular}
% \end{center}
%
+% \colorbox{yellow!50}{\bfseries New 5.7}\enskip As we can see on this example,
+% it's possible to fill the block by using the key |fill| and to draw the frame
+% with the key |draw|\footnote{If the key |draw| is used without value, the
+% default color the rules of the tabulars is used}. It's also possible to change
+% the width (thickness) of that rules with the key |line-width|.
%
% \subsection{The mono-column blocks}
%
@@ -628,7 +635,7 @@ version 2005/12/01 or later.
%
% \subsection{The mono-row blocks}
%
-% \colorbox{yellow!50}{\textbf{New 5.6}}\enskip For the mono-row blocks, the
+% \colorbox{yellow!30}{New 5.6}\enskip For the mono-row blocks, the
% natural height and depth are taken into account for the height and depth of
% the current row (as does a standard |\multicolumn| of LaTeX).
%
@@ -638,12 +645,18 @@ version 2005/12/01 or later.
% mono-column blocks.
%
% \medskip
-% There are two reasons to use a mono-column block:
+% At first sight, one may think that there is no point using a mono-cell block.
+% However, there are some good reasons to use such a block.
% \begin{itemize}
% \item It's possible to use the command |\\| in a (mono-cell) block.
%
% \item It's possible to use the option of horizontal alignment of the block in
% derogation of the type of column given in the preamble of the array.
+%
+% \item It's possible do draw a frame around the cell with the key |draw| of the
+% command |\Block|.\footnote{If one wishes to color the background of a unique
+% celle, there is no point using the command |\Block|: it's possible to use the
+% command |\cellcolor| (when the key |colortbl-like| is used).}
% \end{itemize}
%
% \bigskip
@@ -669,7 +682,7 @@ version 2005/12/01 or later.
% \medskip
% We recall that if the first mandatory argument of |\Block| is left blank, the
% block is mono-cell.\footnote{One may consider that the default value of the
-% first mandatory argument of |\Block| is |1-1|}
+% first mandatory argument of |\Block| is |1-1|.}
%
%
%
@@ -920,15 +933,17 @@ version 2005/12/01 or later.
% \subsection{The key hvlines}
% \label{hvlines}
%
-% The key |hvlines| draws all the vertical and horizontal rules excepted
-% in the blocks (and the virtual blocks determined by dotted lines).
+% The key |hvlines| draws all the vertical and horizontal rules (excepted
+% in the blocks and the virtual blocks determined by dotted lines and excepted
+% the rules corresponding of the frame of the blocks using the key |draw| which
+% are drawn with their own characteristics).
%
% \medskip
% \begin{Verbatim}
% \setlength{\arrayrulewidth}{1pt}
% \begin{NiceTabular}{cccc}[~emphase#hvlines@,rules/color=blue]
% rose & tulipe & marguerite & dahlia \\
-% violette & \Block{2-2}{\LARGE\color{blue} fleurs} & & souci \\
+% violette & \Block[draw=red]{2-2}{\LARGE fleurs} & & souci \\
% pervenche & & & lys \\
% arum & iris & jacinthe & muguet
% \end{NiceTabular}
@@ -938,7 +953,7 @@ version 2005/12/01 or later.
% \setlength{\arrayrulewidth}{1pt}
% \begin{NiceTabular}{cccc}[hvlines,rules/color=blue]
% rose & tulipe & marguerite & dahlia \\
-% violette & \Block{2-2}{\LARGE\color{blue} fleurs} & & souci \\
+% violette & \Block[draw=red]{2-2}{\LARGE fleurs} & & souci \\
% pervenche & & & lys \\
% arum & iris & jacinthe & muguet
% \end{NiceTabular}
@@ -2074,9 +2089,9 @@ version 2005/12/01 or later.
% \Vdots & \Ddots & \Vdots & \Hdotsfor{1} & \Vdots & \Ddots & \Vdots \\
% C[a_n^{(p)},a_1] & \Cdots & C[a_n^{(p)},a_n] & & C[a_n^{(p)},a_1^{(p)}] & \Cdots & C[a_n^{(p)},a_n^{(p)}]
% \end{bNiceMatrix}\]
-
-
-
+%
+%
+%
%
% \subsection{How to generate the continuous dotted lines transparently}
%
@@ -2314,7 +2329,7 @@ version 2005/12/01 or later.
% For the legibility of the code, an alternative syntax is provided: it's
% possible to give the instructions of the |\code-after| at the end of the
% environment, after the keyword |\CodeAfter| (for an example, cf.
-% p.~\pageref{example-CodeAfter}). \colorbox{yellow!50}{\textbf{New 5.5}}\enskip
+% p.~\pageref{example-CodeAfter}). \colorbox{yellow!30}{New 5.5}\enskip
% Before the version 5.5, it was necessary, in some circonstancies, to put the
% keyword |\omit| before |\CodeAfter|. Since version~5.5, one must never put~|\omit|.
%
@@ -2889,9 +2904,6 @@ version 2005/12/01 or later.
% TeX world, the spaces after a control sequence are discarded and the elements
% between curly braces are considered as a whole.
%
-% \bigskip
-% The following example has been composed with XeLaTeX with \pkg{unicode-math},
-% which allows the use of greek letters directly in the TeX source.
%
% \medskip
% \begin{scope}
@@ -2922,6 +2934,24 @@ version 2005/12/01 or later.
% environment of LaTeX which only put TeX commands before and after the content.}
%
%
+% \subsection{Color of the delimiters}
+%
+% For the environements with delimiters (|{pNiceArray}|, |{pNiceMatrix}|, etc.),
+% it's possible to change the color of the delimiters with the key
+% |delimiters-color|.
+%
+% \medskip
+% \begin{BVerbatim}[boxwidth=12cm,baseline=c]
+% $\begin{bNiceMatrix}[delimiters-color=red]
+% 1 & 2 \\
+% 3 & 4
+% \end{bNiceMatrix}$
+% \end{BVerbatim}
+% $\begin{bNiceMatrix}[delimiters-color=red]
+% 1 & 2 \\
+% 3 & 4
+% \end{bNiceMatrix}$
+%
%
% \subsection{The environment \{NiceArrayWithDelims\}}
%
@@ -2963,7 +2993,7 @@ version 2005/12/01 or later.
% \textbf{Caution} : By default, no node is created in a empty cell.
%
% \smallskip
-% \colorbox{yellow!50}{\textbf{New 5.6}}\enskip
+% \colorbox{yellow!30}{New 5.6}\enskip
% However, it's possible to impose the creation of a node with the command |\NotEmpty|.
% \footnote{One should note that, with that command, the cell is considered as
% non-empty, which has consequencies for the continuous dotted lines (cf.
@@ -4026,64 +4056,34 @@ version 2005/12/01 or later.
% \end{multicols}
%
%
-% \subsection{How to highlight cells of the matrix}
+% \subsection{How to highlight cells of a matrix}
%
%
% \label{highlight}
-% The following examples require Tikz (by default, \pkg{nicematrix} only loads
-% \textsc{pgf}) and the Tikz library |fit|. The following lines in the preamble
-% of your document do the job:
-% \begin{verbatim}
-% \usepackage{tikz}
-% \usetikzlibrary{fit}
-% \end{verbatim}
%
% \medskip
-% In order to highlight a cell of a matrix, it's possible to ``draw'' one of the
-% correspondant nodes (the ``normal node'', the ``medium node'' or the ``large
-% node''). In the following example, we use the ``large nodes'' of the diagonal
-% of the matrix (with the Tikz key ``|name suffix|'', it's easy to use the
-% ``large nodes'').
-%
-% We redraw the nodes with other nodes by using the Tikz library |fit|. Since we
-% want to redraw the nodes exactly, we have to set |inner sep = 0 pt| (if we
-% don't do that, the new nodes will be larger that the nodes created by
-% \pkg{nicematrix}).
+% In order to highlight a cell of a matrix, it's possible to ``draw'' that cell
+% with the key |draw| of the command |\Block| (this is one of the uses of a
+% mono-cell block\footnote{We recall that, if the first mandatory argument of
+% the command |\Block| is left empty, that means that the block is a mono-cell block}).
%
% \label{example-CodeAfter}
%
+%
% \begin{Verbatim}
-% $\begin{pNiceArray}{>{\strut}cccc}[create-large-nodes,margin,extra-margin = 2pt]
-% a_{11} & a_{12} & a_{13} & a_{14} \\
-% a_{21} & a_{22} & a_{23} & a_{24} \\
-% a_{31} & a_{32} & a_{33} & a_{34} \\
-% a_{41} & a_{42} & a_{43} & a_{44} \\
-% \CodeAfter
-% \begin{tikzpicture}[~emphase#name suffix = -large@,
-% every node/.style = {draw,~emphase#inner sep = 0 pt@}]
-% \node [fit = (1-1)] {} ;
-% \node [fit = (2-2)] {} ;
-% \node [fit = (3-3)] {} ;
-% \node [fit = (4-4)] {} ;
-% \end{tikzpicture}
+% $\begin{pNiceArray}{>{\strut}cccc}[margin,rules/color=blue]
+% ~emphase#\Block[draw]{}{a_{11}}@ & a_{12} & a_{13} & a_{14} \\
+% a_{21} & \Block[draw]{}{a_{22}} & a_{23} & a_{24} \\
+% a_{31} & a_{32} & \Block[draw]{}{a_{33}} & a_{34} \\
+% a_{41} & a_{42} & a_{43} & \Block[draw]{}{a_{44}} \\
% \end{pNiceArray}$
% \end{Verbatim}
-%
-% \[\begin{pNiceArray}{>{\strut}cccc}[create-large-nodes,margin,extra-margin = 2pt]
-% a_{11} & a_{12} & a_{13} & a_{14} \\
-% a_{21} & a_{22} & a_{23} & a_{24} \\
-% a_{31} & a_{32} & a_{33} & a_{34} \\
-% a_{41} & a_{42} & a_{43} & a_{44} \\
-% \CodeAfter
-% \begin{tikzpicture}[name suffix = -large,
-% every node/.style = {draw,inner sep = 0 pt}]
-% \node [fit = (1-1)] {} ;
-% \node [fit = (2-2)] {} ;
-% \node [fit = (3-3)] {} ;
-% \node [fit = (4-4)] {} ;
-% \end{tikzpicture}
+% \[\begin{pNiceArray}{>{\strut}cccc}[margin,rules/color=blue]
+% \Block[draw]{}{a_{11}} & a_{12} & a_{13} & a_{14} \\
+% a_{21} & \Block[draw]{}{a_{22}} & a_{23} & a_{24} \\
+% a_{31} & a_{32} & \Block[draw]{}{a_{33}} & a_{34} \\
+% a_{41} & a_{42} & a_{43} & \Block[draw]{}{a_{44}} \\
% \end{pNiceArray}\]
-%
%
% We should remark that the rules we have drawn are drawn \emph{after} the
% construction of the array and thus, they don't spread the cells of the array.
@@ -4095,13 +4095,23 @@ version 2005/12/01 or later.
%
% \vspace{1cm}
% It's possible to color a row with |\rowcolor| in the |code-before| (or with
-% |\rowcolor| of \pkg{colortbl} in the first cell of the row). However, it's not
-% possible to do a fine tuning. That's why we describe now method to highlight a
-% row of the matrix. We create a rectangular Tikz node which encompasses the
-% nodes of the second row with the Tikz library \pkg{fit}. This Tikz node is
-% filled after the construction of the matrix. In order to see the text
-% \emph{under} this node, we have to use transparency with the |blend mode|
-% equal to |multiply|.
+% |\rowcolor| in the first cell of the row if the key |colortbl-like| is used).
+% However, it's not possible to do a fine tuning. That's why we describe now a
+% method to highlight a row of the matrix. We create a rectangular Tikz node
+% which encompasses the nodes of the second row with the Tikz library \pkg{fit}.
+% This Tikz node is filled after the construction of the matrix. In order to see
+% the text \emph{under} this node, we have to use transparency with the
+% |blend mode| equal to |multiply|.
+%
+%
+% \medskip
+% That example and the following ones require Tikz (by default, \pkg{nicematrix}
+% only loads \textsc{pgf}) and the Tikz library |fit|. The following lines in
+% the preamble of your document do the job:
+% \begin{verbatim}
+% \usepackage{tikz}
+% \usetikzlibrary{fit}
+% \end{verbatim}
%
% \tikzset{highlight/.style={rectangle,
% fill=red!15,
@@ -4119,19 +4129,21 @@ version 2005/12/01 or later.
% inner sep=1pt,
% fit = ~#1}}
%
-% $\begin{bNiceMatrix}[~emphase#code-after = {\tikz \node [highlight = (2-1) (2-3)] {} ;}@]
+%
+% $\begin{bNiceMatrix}
% 0 & \Cdots & 0 \\
% 1 & \Cdots & 1 \\
-% 0 & \Cdots & 0
+% 0 & \Cdots & 0 \\
+% ~emphase#\CodeAfter \tikz \node [highlight = (2-1) (2-3)] {} ;@
% \end{bNiceMatrix}$
% \end{Verbatim}
-%
-% \[\begin{bNiceMatrix}[code-after = {\tikz \node [highlight = (2-1) (2-3)] {} ;}]
+% \[\begin{bNiceMatrix}
% 0 & \Cdots & 0 \\
% 1 & \Cdots & 1 \\
-% 0 & \Cdots & 0
+% 0 & \Cdots & 0 \\
+% \CodeAfter \tikz \node [highlight = (2-1) (2-3)] {} ;
% \end{bNiceMatrix}\]
-%
+%
%
%
% \vspace{1cm}
@@ -5144,6 +5156,15 @@ version 2005/12/01 or later.
\tl_new:N \l_@@_rules_color_tl
% \end{macrocode}
%
+%
+% \bigskip
+% This boolean will be used only to detect in an expandable way whether we are
+% at the beginning of the (potential) column zero, in order to raise an error if
+% |\Hdotsfor| is used in that column.
+% \begin{macrocode}
+\bool_new:N \g_@@_after_col_zero_bool
+% \end{macrocode}
+%
% \bigskip
% A kind of false row will be inserted at the end of the array for the
% construction of the |col| nodes (and also to fix the width of the columns when
@@ -5158,7 +5179,7 @@ version 2005/12/01 or later.
% \bigskip
% It's possible to use the command |\NotEmpty| to specify explicitely that a
% cell must be considered as non empty by \pkg{nicematrix} (the Tikz nodes are
-% constructed only the non empty cells).
+% constructed only in the non empty cells).
% \begin{macrocode}
\bool_new:N \g_@@_not_empty_cell_bool
% \end{macrocode}
@@ -5220,7 +5241,7 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
-% The following sequence will contain the caracteristics of the blocks of the
+% The following sequence will contain the characteristics of the blocks of the
% array, specified by the command |\Block|. Each block is represented by 6
% components surrounded by braces:
%
@@ -5256,6 +5277,17 @@ version 2005/12/01 or later.
% blocks corresponding to the dotted lines).
%
% \medskip
+% The final user may decide to ``stroke'' a block (using, for example, the key
+% |color=red!15| when using the command |\Block|). In that case, the rules
+% specified, for instance, by |hvlines| must not be drawn around the block.
+% That's why we keep the information of all that stroken blocks in the following
+% sequence.
+% \begin{macrocode}
+\seq_new:N \g_@@_pos_of_stroken_blocks_seq
+% \end{macrocode}
+%
+%
+% \medskip
% We are able to determine the number of columns specified in the preamble (for
% the environments with explicit preamble, of course and without the potential
% exterior columns).
@@ -5263,12 +5295,32 @@ version 2005/12/01 or later.
\int_new:N \g_@@_static_num_of_col_int
% \end{macrocode}
%
+% \medskip
+% The following token lists correspond to the keys |fill| and |draw| of
+% a command |\Block|.
+% \begin{macrocode}
+\tl_new:N \l_@@_fill_tl
+\tl_new:N \l_@@_draw_tl
+% \end{macrocode}
+%
% \medskip
-% Used for the color of the blocks.
+% The following token list correspond to the key |color| of the command
+% |\Block|. However, as of now (v. 5.7 of \pkg{nicematrix}), the key |color|
+% linked to |fill| with an error. We will give to the key |color| of |\Block|
+% its new meaning in a few months (with its new definition, the key |color| will
+% draw the frame with the given color but also color the content of the block
+% (that is to say the text) as does the key |color| of a Tikz node).
% \begin{macrocode}
\tl_new:N \l_@@_color_tl
% \end{macrocode}
-%
+%
+% \medskip
+% Here is the dimension for the width of the rule when a block (created by
+% |\Block|) is stroked.
+% \begin{macrocode}
+\dim_new:N \l_@@_line_width_dim
+% \end{macrocode}
+%
% \medskip
% The parameter of position of the label of a block (|c|, |r| or |l|).
% \begin{macrocode}
@@ -5844,7 +5896,13 @@ version 2005/12/01 or later.
\tl_new:N \l_@@_xdots_color_tl
% \end{macrocode}
%
-% \medskip
+% \bigskip
+% The following token list corresponds to the key |delimiters-color|.
+% \begin{macrocode}
+\tl_new:N \l_@@_delimiters_color_tl
+% \end{macrocode}
+%
+% \bigskip
% Sometimes, we want to have several arrays vertically juxtaposed in order to
% have an alignment of the columns of these arrays. To acheive this goal, one
% may wish to use the same width for all the columns (for example with the
@@ -6143,6 +6201,8 @@ version 2005/12/01 or later.
% \begin{macrocode}
\keys_define:nn { NiceMatrix / NiceMatrixOptions }
{
+ delimiters-color .tl_set:N = \l_@@_delimiters_color_tl ,
+ 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 ,
@@ -6247,6 +6307,8 @@ version 2005/12/01 or later.
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 ,
unknown .code:n = \@@_error:n { Unknown~option~for~NiceMatrix }
}
% \end{macrocode}
@@ -6277,6 +6339,8 @@ version 2005/12/01 or later.
notes / bottomrule .default:n = true ,
tabularnote .tl_set:N = \l_@@_tabularnote_tl ,
tabularnote .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~option~for~NiceArray }
}
% \end{macrocode}
@@ -6392,7 +6456,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\cs_new_protected:Npn \@@_begin_of_row:
{
- \int_gincr:N \c@iRow
+ \refstepcounter { iRow }
\dim_gset_eq:NN \g_@@_dp_ante_last_row_dim \g_@@_dp_last_row_dim
\dim_gset:Nn \g_@@_dp_last_row_dim { \box_dp:N \@arstrutbox }
\dim_gset:Nn \g_@@_ht_last_row_dim { \box_ht:N \@arstrutbox }
@@ -6733,6 +6797,7 @@ version 2005/12/01 or later.
\cs_new_protected:Npn \@@_everycr_i:
{
\int_gzero:N \c@jCol
+ \bool_gset_false:N \g_@@_after_col_zero_bool
\bool_if:NF \g_@@_row_of_col_done_bool
{
\@@_create_row_node:
@@ -7073,10 +7138,14 @@ version 2005/12/01 or later.
% \begin{macrocode}
\seq_gclear:N \g_@@_blocks_seq
\seq_gclear:N \g_@@_pos_of_blocks_seq
- \seq_gclear:N \g_@@_pos_of_xdots_seq
% \end{macrocode}
% In fact, the sequence |\g_@@_pos_of_blocks_seq| will also contain the
% positions of the cells with a |\diagbox|.
+%
+% \begin{macrocode}
+ \seq_gclear:N \g_@@_pos_of_stroken_blocks_seq
+ \seq_gclear:N \g_@@_pos_of_xdots_seq
+% \end{macrocode}
%
% \begin{macrocode}
\tl_if_exist:cT { g_@@_code_before_ \int_use:N \g_@@_env_int _ tl }
@@ -7455,6 +7524,8 @@ version 2005/12/01 or later.
\hbox_set:Nn \l_tmpa_box
{
\c_math_toggle_token
+ \tl_if_empty:NF \l_@@_delimiters_color_tl
+ { \color { \l_@@_delimiters_color_tl } }
\left #1
\vcenter
{
@@ -7688,6 +7759,9 @@ version 2005/12/01 or later.
\@@_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 }
+ C { \@@_error:nn { old~column~type } C }
+ L { \@@_error:nn { old~column~type } L }
+ R { \@@_error:nn { old~column~type } R }
\q_stop { }
}
{
@@ -7963,7 +8037,7 @@ version 2005/12/01 or later.
% \bigskip
% The following command is \emph{always} used by |{NiceArrayWithDelims}| (even
% if, in fact, there is no tabular notes: in fact, it's not possible to know
-% whether there is or not before the composition of the blocks).
+% whether there is tabular notes or not before the composition of the blocks).
% \begin{macrocode}
\cs_new_protected:Npn \@@_use_arraybox_with_notes_c:
{
@@ -8511,6 +8585,7 @@ version 2005/12/01 or later.
{
>
{
+ \bool_gset_true:N \g_@@_after_col_zero_bool
\@@_begin_of_row:
% \end{macrocode}
% The contents of the cell is constructed in the box |\l_@@_cell_box| because we
@@ -10381,8 +10456,15 @@ version 2005/12/01 or later.
% \begin{macrocode}
\cs_new:Npn \@@_Hdotsfor:
{
- \int_compare:nNnTF \c@jCol = 0
- { \@@_error:n { Hdotsfor~in~col~0 } }
+ \int_compare:nNnTF \c@jCol = 0
+ {
+ \bool_if:NTF \g_@@_after_col_zero_bool
+ {
+ \multicolumn { 1 } { c } { }
+ \@@_Hdotsfor_i
+ }
+ { \@@_fatal:n { Hdotsfor~in~col~0 } }
+ }
{
\multicolumn { 1 } { c } { }
\@@_Hdotsfor_i
@@ -10416,7 +10498,7 @@ version 2005/12/01 or later.
#1 , #3 ,
down = \exp_not:n { #4 } , up = \exp_not:n { #5 }
}
- }
+ }
\prg_replicate:nn { #2 - 1 } { & \multicolumn { 1 } { c } { } }
}
}
@@ -11086,6 +11168,9 @@ version 2005/12/01 or later.
}
}
% \end{macrocode}
+%
+%
+%
%
% \bigskip
% \subsection*{The vertical rules}
@@ -11189,6 +11274,8 @@ version 2005/12/01 or later.
{ \@@_test_if_vline_in_block:nnnn ##1 }
\seq_map_inline:Nn \g_@@_pos_of_xdots_seq
{ \@@_test_if_vline_in_block:nnnn ##1 }
+ \seq_map_inline:Nn \g_@@_pos_of_stroken_blocks_seq
+ { \@@_test_if_vline_in_stroken_block:nnnn ##1 }
\clist_if_empty:NF \l_@@_except_corners_clist
\@@_test_in_corner_v:
\bool_if:NTF \g_tmpa_bool
@@ -11364,6 +11451,8 @@ version 2005/12/01 or later.
{ \@@_test_if_hline_in_block:nnnn ##1 }
\seq_map_inline:Nn \g_@@_pos_of_xdots_seq
{ \@@_test_if_hline_in_block:nnnn ##1 }
+ \seq_map_inline:Nn \g_@@_pos_of_stroken_blocks_seq
+ { \@@_test_if_hline_in_stroken_block:nnnn ##1 }
\clist_if_empty:NF \l_@@_except_corners_clist \@@_test_in_corner_h:
\bool_if:NTF \g_tmpa_bool
{
@@ -11565,7 +11654,34 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_test_if_hline_in_stroken_block:nnnn #1 #2 #3 #4
+ {
+ \bool_lazy_all:nT
+ {
+ { \int_compare_p:nNn \l_tmpa_tl > { #1 - 1 } }
+ { \int_compare_p:nNn \l_tmpa_tl < { #3 + 2 } }
+ { \int_compare_p:nNn \l_tmpb_tl > { #2 - 1 } }
+ { \int_compare_p:nNn \l_tmpb_tl < { #4 + 1 } }
+ }
+ { \bool_gset_false:N \g_tmpa_bool }
+ }
+% \end{macrocode}
%
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_test_if_vline_in_stroken_block:nnnn #1 #2 #3 #4
+ {
+ \bool_lazy_all:nT
+ {
+ { \int_compare_p:nNn \l_tmpa_tl > { #1 - 1 } }
+ { \int_compare_p:nNn \l_tmpa_tl < { #3 + 1 } }
+ { \int_compare_p:nNn \l_tmpb_tl > { #2 - 1 } }
+ { \int_compare_p:nNn \l_tmpb_tl < { #4 + 2 } }
+ }
+ { \bool_gset_false:N \g_tmpa_bool }
+ }
+% \end{macrocode}
+%
% \bigskip
% \subsubsection*{The key except-corners}
%
@@ -12400,8 +12516,8 @@ version 2005/12/01 or later.
%
% \bigskip
% The options of the command |\Block| will be analyzed first in the cell of the
-% array (and once again when the block will be put in the array in the
-% |code-after|). Here is the set of keys for the first pass.
+% array (and once again when the block will be put in the array).
+% Here is the set of keys for the first pass.
% \begin{macrocode}
\keys_define:nn { NiceMatrix / Block / FirstPass }
{
@@ -12411,6 +12527,12 @@ version 2005/12/01 or later.
r .value_forbidden:n = true ,
c .code:n = \tl_set:Nn \l_@@_pos_of_block_tl c ,
c .value_forbidden:n = true ,
+% \end{macrocode}
+% The two following lines will be uncommented when we will give to the key
+% |color| its new definition.
+% \begin{macrocode}
+ % color .tl_set:N = \l_@@_color_tl ,
+ % color .value_required:n = true ,
}
% \end{macrocode}
%
@@ -12418,8 +12540,9 @@ version 2005/12/01 or later.
% The following command |\@@_Block:| will be linked to |\Block| in the
% environments of \pkg{nicematrix}. We define it with
% |\NewExpandableDocumentCommand| because it has an optional argument between
-% |<| and |>| (for TeX instructions put before the math mode of the label). It's
-% mandatory to use an expandable command.
+% |<| and |>| (for TeX instructions put before the math mode of the label and
+% before the beginning of the small array of the block). It's mandatory to use
+% an expandable command.
%
% \begin{macrocode}
\NewExpandableDocumentCommand \@@_Block: { O { } m D < > { } m }
@@ -12444,17 +12567,21 @@ version 2005/12/01 or later.
% \medskip
% Now, the arguments have been extracted: |#1| is $i$ (the number of rows of the
% block), |#2| is $j$ (the number of columns of the block), |#3| is the list of
-% key-values, |#4| are the tokens to put before the math mode and |#5| is the
-% label of the block.
+% key-values, |#4| are the tokens to put before the math mode and the beginning
+% of the small array of the block and |#5| is the label of the block.
% \begin{macrocode}
\cs_new_protected:Npn \@@_Block_ii:nnnnn #1 #2 #3 #4 #5
{
% \end{macrocode}
%
% \begin{macrocode}
- \tl_if_empty:NTF \l_@@_cell_type_tl
+ \int_compare:nNnTF { #2 } = 1
+ {
+ \tl_if_empty:NTF \l_@@_cell_type_tl
+ { \tl_set:Nn \l_@@_pos_of_block_tl c }
+ { \tl_set_eq:NN \l_@@_pos_of_block_tl \l_@@_cell_type_tl }
+ }
{ \tl_set:Nn \l_@@_pos_of_block_tl c }
- { \tl_set_eq:NN \l_@@_pos_of_block_tl \l_@@_cell_type_tl }
% \end{macrocode}
%
% \medskip
@@ -12488,7 +12615,7 @@ version 2005/12/01 or later.
% \end{macrocode}
% Now, |\l_tmpa_tl| contains an ``object'' corresponding to the position of the
% block whith four components, each of them surrounded by curly brackets:
-%
+%
% |{|\textsl{imin}|}{|\textsl{jmin}|}{|\textsl{imax}|}{|\textsl{jmax}|}|.
%
% We store this information in the sequence |\g_@@_pos_of_blocks_seq|.
@@ -12553,13 +12680,13 @@ version 2005/12/01 or later.
% command seems to be bugged: it doesn't work in XeLaTeX when \pkg{fontspec} is
% loaded.
% \begin{macrocode}
- \int_compare:nNnT { #2 } = 1 \set@color
- \bool_if:NTF \l_@@_NiceTabular_bool
- {
- \group_begin:
- \cs_set:Npn \arraystretch { 1 }
- \dim_set_eq:NN \extrarowheight \c_zero_dim
- #4
+ \tl_if_empty:NTF \l_@@_color_tl
+ { \int_compare:nNnT { #2 } = 1 \set@color }
+ { \color { \l_@@_color_tl } }
+ \group_begin:
+ \cs_set:Npn \arraystretch { 1 }
+ \dim_set_eq:NN \extrarowheight \c_zero_dim
+ #4
% \end{macrocode}
% If the box is rotated (the key |\rotate| may be in the previous |#4|), the
% tabular used for the content of the cell will be constructed with a format
@@ -12568,29 +12695,23 @@ version 2005/12/01 or later.
% the tabular is the same as the external alignment of the tabular (that is to
% say the position of the block in its zone of merged cells).
% \begin{macrocode}
- \bool_if:NT \g_@@_rotate_bool
- { \tl_set:Nn \l_@@_pos_of_block_tl c }
+ \bool_if:NT \g_@@_rotate_bool { \tl_set:Nn \l_@@_pos_of_block_tl c }
+ \bool_if:NTF \l_@@_NiceTabular_bool
+ {
\exp_args:Nnx \begin { tabular }
{ @ { } \l_@@_pos_of_block_tl @ { } }
#5
\end { tabular }
- \group_end:
}
{
- \group_begin:
- \cs_set:Npn \arraystretch { 1 }
- \dim_set_eq:NN \extrarowheight \c_zero_dim
- #4
- \bool_if:NT \g_@@_rotate_bool
- { \tl_set:Nn \l_@@_pos_of_block_tl c }
\c_math_toggle_token
\exp_args:Nnx \begin { array }
{ @ { } \l_@@_pos_of_block_tl @ { } }
#5
\end { array }
\c_math_toggle_token
- \group_end:
}
+ \group_end:
}
\bool_if:NT \g_@@_rotate_bool
{
@@ -12721,17 +12842,25 @@ version 2005/12/01 or later.
% array \emph{after the construction of the array} (by using \textsc{pgf}).
%
% \medskip
-% The key |tikz| is for Tikz options used when the \textsc{pgf} node of the
-% block is created (the ``normal'' block node and not the ``short'' one nor the
-% ``medium'' one). \textbf{In fact, as of now, it is \emph{not} documented}. Is
-% it really a good idea to provide such a key?
% \begin{macrocode}
\keys_define:nn { NiceMatrix / Block / SecondPass }
{
- tikz .tl_set:N = \l_@@_tikz_tl ,
- tikz .value_required:n = true ,
- color .tl_set:N = \l_@@_color_tl ,
+ fill .tl_set:N = \l_@@_fill_tl ,
+ fill .value_required:n = true ,
+ draw .tl_set:N = \l_@@_draw_tl ,
+ draw .default:n = default ,
+% \end{macrocode}
+% The following definition for the key |color| will be deleted when we will give
+% to the key |color| of the command |\Block| its new definition. It will be
+% replaced by the line which is commented.
+% \begin{macrocode}
+ color .code:n =
+ \@@_error:n { Key~color~for~Block }
+ \tl_set:Nn \l_@@_fill_tl { #1 } ,
+ % color .code:n = \color { #1 } \tl_set:Nn \l_@@_draw_tl { #1 } ,
color .value_required:n = true ,
+ line-width .dim_set:N = \l_@@_line_width_dim ,
+ line-width .value_required:n = true ,
l .code:n = \tl_set:Nn \l_@@_pos_of_block_tl l ,
l .value_forbidden:n = true ,
r .code:n = \tl_set:Nn \l_@@_pos_of_block_tl r ,
@@ -12762,11 +12891,11 @@ version 2005/12/01 or later.
% The group is for the keys.
% \begin{macrocode}
\group_begin:
- \keys_set:nn { NiceMatrix / Block / SecondPass} { #5 }
+ \keys_set:nn { NiceMatrix / Block / SecondPass } { #5 }
% \end{macrocode}
%
% The integer |\l_@@_last_row_int| will be the last row of the block and
-% |\l_@@_last_col_int| it's last column.
+% |\l_@@_last_col_int| its last column.
% \begin{macrocode}
\int_zero_new:N \l_@@_last_row_int
\int_zero_new:N \l_@@_last_col_int
@@ -12789,12 +12918,29 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \begin{macrocode}
- \tl_if_empty:NF \l_@@_color_tl
+ \bool_lazy_or:nnT
+ { ! \tl_if_empty_p:N \l_@@_draw_tl }
+ { \dim_compare_p:nNn \l_@@_line_width_dim > \c_zero_dim }
+ {
+ \tl_gput_right:Nx \g_nicematrix_code_after_tl
+ {
+ \@@_stroke_block:nnn
+ { #5 }
+ { #1 - #2 }
+ { \int_use:N \l_@@_last_row_int - \int_use:N \l_@@_last_col_int }
+ }
+ \seq_gput_right:Nn \g_@@_pos_of_stroken_blocks_seq
+ { { #1 } { #2 } { #3 } { #4 } }
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+ \tl_if_empty:NF \l_@@_fill_tl
{
\tl_gput_right:Nx \g_nicematrix_code_before_tl
{
\exp_not:N \rectanglecolor
- { \l_@@_color_tl }
+ { \l_@@_fill_tl }
{ #1 - #2 }
{ \int_use:N \l_@@_last_row_int - \int_use:N \l_@@_last_col_int }
}
@@ -12897,7 +13043,6 @@ version 2005/12/01 or later.
% and the four coordinates of two opposite corner points of the rectangle.
% \begin{macrocode}
\begin { pgfscope }
- \exp_args:Nx \pgfset { \l_@@_tikz_tl }
\@@_pgf_rect_node:nnnnn
{ \@@_env: - #1 - #2 - block }
\l_tmpb_dim \l_tmpa_dim \l_tmpd_dim \l_tmpc_dim
@@ -13036,17 +13181,20 @@ version 2005/12/01 or later.
%
% \medskip
% If the number of rows is different of $1$, we will put the label of the block
-% in using the short node (the label of the block has been composed in
+% by using the short node (the label of the block has been composed in
% |\l_@@_cell_box|).
% \begin{macrocode}
{
% \end{macrocode}
% If we are in the first column, we must put the block as if it was with the key~|r|.
% \begin{macrocode}
- \int_compare:nNnT \c@jCol = 0
+ \int_compare:nNnT { #2 } = 0
{ \tl_set:Nn \l_@@_pos_of_block_tl r }
- \int_compare:nNnT \c@jCol = \l_@@_last_col_int
- { \tl_set:Nn \l_@@_pos_of_block_tl l }
+ \bool_if:nT \g_@@_last_col_found_bool
+ {
+ \int_compare:nNnT { #2 } = \g_@@_col_total_int
+ { \tl_set:Nn \l_@@_pos_of_block_tl l }
+ }
\pgftransformshift
{
\pgfpointanchor
@@ -13079,6 +13227,76 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
+%
+% % \bigskip
+% The first argument of |\@@_stroke_block:nnn| is a list of options for the
+% rectangle that you will stoke. The second argument is the upper-left cell of
+% the block (with, as usual, the syntex $i$|-|$j$) and the third is the last
+% cell of the block (with the same syntax).
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_stroke_block:nnn #1 #2 #3
+ {
+ \group_begin:
+ \tl_clear:N \l_@@_draw_tl
+ \dim_set_eq:NN \l_@@_line_width_dim \arrayrulewidth
+ \keys_set_known:nn { NiceMatrix / BlockStroke } { #1 }
+ \pgfpicture
+ \pgfrememberpicturepositiononpagetrue
+ \pgf@relevantforpicturesizefalse
+ \tl_if_empty:NF \l_@@_draw_tl
+ {
+% \end{macrocode}
+% If the user has used the key |color| of the command |\Block| without value,
+% the color fixed by |\arrayrulecolor| is used.
+% \begin{macrocode}
+ \str_if_eq:VnTF \l_@@_draw_tl { default }
+ { \CT@arc@ }
+ { \pgfsetstrokecolor { \l_@@_draw_tl } }
+ }
+ \@@_cut_on_hyphen:w #2 \q_stop
+ \bool_lazy_and:nnT
+ { \int_compare_p:n { \l_tmpa_tl <= \c@iRow } }
+ { \int_compare_p:n { \l_tmpb_tl <= \c@jCol } }
+ {
+ \@@_qpoint:n { row - \l_tmpa_tl }
+ \dim_set:Nn \l_tmpb_dim { \pgf@y }
+ \@@_qpoint:n { col - \l_tmpb_tl }
+ \dim_set:Nn \l_tmpc_dim { \pgf@x }
+ \@@_cut_on_hyphen:w #3 \q_stop
+ \int_compare:nNnT \l_tmpa_tl > \c@iRow
+ { \tl_set:Nx \l_tmpa_tl { \int_use:N \c@iRow } }
+ \int_compare:nNnT \l_tmpb_tl > \c@jCol
+ { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } }
+ \@@_qpoint:n { row - \@@_succ:n \l_tmpa_tl }
+ \dim_set:Nn \l_tmpa_dim { \pgf@y }
+ \@@_qpoint:n { col - \@@_succ:n \l_tmpb_tl }
+ \dim_set:Nn \l_tmpd_dim { \pgf@x }
+ \pgfpathrectanglecorners
+ { \pgfpoint \l_tmpc_dim \l_tmpb_dim }
+ { \pgfpoint \l_tmpd_dim \l_tmpa_dim }
+ \pgfsetlinewidth { 1.1 \l_@@_line_width_dim }
+ \pgfusepathqstroke
+ }
+ \endpgfpicture
+ \group_end:
+ }
+% \end{macrocode}
+%
+% Here is the set of keys for the command |\@@_stroke_block:nnn|.
+% \begin{macrocode}
+\keys_define:nn { NiceMatrix / BlockStroke }
+ {
+% \end{macrocode}
+% We will uncomment the following line when we will give to the key |color| of
+% the command |\Block| its new definition.
+% \begin{macrocode}
+ % color .tl_set:N = \l_@@_draw_tl ,
+ draw .tl_set:N = \l_@@_draw_tl ,
+ draw .default:n = default ,
+ line-width .dim_set:N = \l_@@_line_width_dim ,
+ }
+% \end{macrocode}
+%
% \bigskip
% \subsection*{How to draw the dotted lines transparently}
% \begin{macrocode}
@@ -13658,6 +13876,16 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \begin{macrocode}
+\@@_msg_new:nn { Key~color~for~Block }
+ {
+ The~key~'color'~for~the~command~\token_to_str:N \Block\
+ is~deprecated:~you~should~use~'fill'~instead.\\
+ You~can~go~on~for~this~time~but~remember~that~that~key~
+ will~be~deleted~in~a~future~version.
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
\@@_msg_new:nn { ampersand~in~light-syntax }
{
You~can't~use~an~ampersand~(\token_to_str &)~to~separate~columns~because
@@ -13682,7 +13910,16 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
-%
+% \begin{macrocode}
+\@@_msg_new:nn { old~column~type }
+ {
+ The~column~type~'#1'~is~no~longer~defined~in~'nicematrix'.~
+ Since~version~5.0,~you~have~to~use~'l',~'c'~and~'r'~instead~of~'L',~
+ 'C'~and~'R'.~You~can~also~use~the~key~'define-L-C-R'.\\
+ This~error~is~fatal.
+ }
+% \end{macrocode}
+%
% \begin{macrocode}
\@@_msg_new:nn { bad~value~for~baseline }
{
@@ -13712,7 +13949,7 @@ version 2005/12/01 or later.
\@@_msg_new:nn { Hdotsfor~in~col~0 }
{
You~can't~use~\token_to_str:N \Hdotsfor\ in~an~exterior~column~of~
- the~array.~If~you~go~on,~the~corresponding~dotted~line~won't~be~drawn.
+ the~array.~This~error~is~fatal.
}
% \end{macrocode}
%
@@ -13882,6 +14119,7 @@ version 2005/12/01 or later.
create-extra-nodes,~
create-medium-nodes,~
create-large-nodes,~
+ delimiters-color,~
end-of-row,~
first-col,~
first-row,~
@@ -13932,6 +14170,7 @@ version 2005/12/01 or later.
create-extra-nodes,~
create-medium-nodes,~
create-large-nodes,~
+ delimiters-color,~
extra-left-margin,~
extra-right-margin,~
first-col,~
@@ -13989,6 +14228,7 @@ version 2005/12/01 or later.
create-extra-nodes,~
create-medium-nodes,~
create-large-nodes,~
+ delimiters-color,~
extra-left-margin,~
extra-right-margin,~
first-col,~
@@ -14486,6 +14726,12 @@ version 2005/12/01 or later.
% Different behaviour for the mono-row blocks.
%
% New command |\NotEmpty|.
+%
+% \subsection*{Changes between versions 5.6 and 5.7}
+%
+% New key |delimiters-color|
+%
+% Keys |fill|, |draw| and |line-width| for the command |\Block|.
%
% \PrintIndex
%