summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/nicematrix/nicematrix-code.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/nicematrix/nicematrix-code.dtx')
-rw-r--r--macros/latex/contrib/nicematrix/nicematrix-code.dtx210
1 files changed, 131 insertions, 79 deletions
diff --git a/macros/latex/contrib/nicematrix/nicematrix-code.dtx b/macros/latex/contrib/nicematrix/nicematrix-code.dtx
index 4605970134..6e883a8b82 100644
--- a/macros/latex/contrib/nicematrix/nicematrix-code.dtx
+++ b/macros/latex/contrib/nicematrix/nicematrix-code.dtx
@@ -17,8 +17,8 @@
%
% \fi
% \iffalse
-\def\myfileversion{6.25}
-\def\myfiledate{2023/10/24}
+\def\myfileversion{6.25a}
+\def\myfiledate{2023/11/03}
%
%
%<*batchfile>
@@ -900,15 +900,15 @@ version 2005/12/01 or later.
% The dimension |\l_@@_columns_width_dim| will be used when the options specify
% that all the columns must have the same width (but, if the key |columns-width|
% is used with the special value |auto|, the boolean
-% |l_@@_auto_columns_width_bool| also will be raised).
+% |\l_@@_auto_columns_width_bool| also will be raised).
% \begin{macrocode}
\dim_new:N \l_@@_columns_width_dim
% \end{macrocode}
%
% \bigskip
% The dimension |\l_@@_col_width_dim| will be available in each cell which
-% belongs to a column of fixed width: |w{...}{...}|, |W{...}{...}|, |p{}|,
-% |m{}|, |b{}| but also |X| (when the actual width of that column is known, that
+% belongs to a column of fixed width: |w{...}{...}|, |W{...}{...}|, |p{...}|,
+% |m{...}|, |b{...}| but also |X| (when the actual width of that column is known, that
% is to say after the first compilation). It's the width of that column. It will
% be used by some commands |\Block|. A non positive value means that the column
% has no fixed width (it's a column of type |c|, |r|, |l|, etc.).
@@ -1044,7 +1044,7 @@ version 2005/12/01 or later.
% In a cell, it will be possible to know whether we are in a cell of a column of
% type |X| thanks to that flag.
% \begin{macrocode}
-\bool_new:N \l_@@_X_column_bool
+\bool_new:N \l_@@_X_bool
% \end{macrocode}
%
% \begin{macrocode}
@@ -2493,7 +2493,7 @@ version 2005/12/01 or later.
% |\tl_put_right:Nn| and not |\tl_set:Nn| (or |.tl_set:N|) because we don't want
% a direct use of |up=...| erased by a absent |^{...}|.
% \begin{macrocode}
- down .code:n = \tl_put_right:Nn \l_@@_xdots_down_tl { #1 } , % modified 2023-08-09
+ down .code:n = \tl_put_right:Nn \l_@@_xdots_down_tl { #1 } ,
up .code:n = \tl_put_right:Nn \l_@@_xdots_up_tl { #1 } ,
middle .code:n = \tl_put_right:Nn \l_@@_xdots_middle_tl { #1 } ,
% \end{macrocode}
@@ -4425,7 +4425,7 @@ version 2005/12/01 or later.
\seq_gclear:N \g_@@_pos_of_blocks_seq
% \end{macrocode}
% In fact, the sequence |\g_@@_pos_of_blocks_seq| will also contain the
-% positions of the cells with a |\diagbox|.
+% positions of the cells with a |\diagbox| and the |\multicolumn|.
%
% \begin{macrocode}
\seq_gclear:N \g_@@_pos_of_stroken_blocks_seq
@@ -4992,7 +4992,7 @@ version 2005/12/01 or later.
\cs_new_protected:Npn \@@_make_preamble_i_i:n #1
{
\str_if_eq:nnTF { #1 } |
- { \@@_make_preamble_iii:n | }
+ { \use:c { @@ _ | } | }
{ \@@_make_preamble_i_ii:nn { } #1 }
}
% \end{macrocode}
@@ -5149,7 +5149,7 @@ version 2005/12/01 or later.
\str_set:Nn \l_@@_hpos_col_str { j }
\tl_set:Nn \l_tmpa_tl { #1 }
\@@_keys_p_column:V \l_tmpa_tl
- \@@_make_preamble_ii_iv:nn { #2 } { minipage }
+ \@@_make_preamble_ii_iv:nnn { #2 } { minipage } { }
}
% \end{macrocode}
%
@@ -5161,9 +5161,10 @@ version 2005/12/01 or later.
%
% \medskip
% The first argument is the width of the column. The second is the type of
-% environment: |minipage| or |varwidth|.
+% environment: |minipage| or |varwidth|. The third is some code added at the
+% beginning of the cell.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_ii_iv:nn #1 #2
+\cs_new_protected:Npn \@@_make_preamble_ii_iv:nnn #1 #2 #3
{
\use:e
{
@@ -5192,6 +5193,7 @@ version 2005/12/01 or later.
L { \exp_not:N \RaggedRight }
R { \exp_not:N \RaggedLeft }
}
+ #3
}
{ \str_if_eq:VnT \l_@@_vpos_col_str { m } \@@_center_cell_box: }
{ \str_if_eq:VnT \l_@@_hpos_col_str { si } \siunitx_cell_begin:w }
@@ -5219,7 +5221,7 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \medskip
-% |#1| is the optional argument of |{minipage}| (or |{varwidth}|): |t| of |b|.
+% |#1| is the optional argument of |{minipage}| (or |{varwidth}|): |t| or |b|.
% Indeed, for the columns of type |m|, we use the value |b| here because there
% is a special post-action in order to center vertically the box (see |#4|).
%
@@ -5260,7 +5262,11 @@ version 2005/12/01 or later.
% \begin{macrocode}
\dim_set:Nn \l_@@_col_width_dim { #2 }
\@@_cell_begin:w
- \begin { #7 } [ #1 ] { #2 }
+% \end{macrocode}
+% We use the form |\minipage|--|\endminipage| (|\varwidth|--|\endvarwidth|) for
+% compatibility with \pkg{collcell} (2023-10-31).
+% \begin{macrocode}
+ \use:c { #7 } [ #1 ] { #2 }
% \end{macrocode}
% The following lines have been taken from |array.sty|.
% \begin{macrocode}
@@ -5288,8 +5294,7 @@ version 2005/12/01 or later.
% The following line has been taken from |array.sty|.
% \begin{macrocode}
\@finalstrut \@arstrutbox
- % \bool_if:NT \g_@@_rotate_bool { \raggedright \hsize = 3 cm }
- \end { #7 }
+ \use:c { end #7 }
% \end{macrocode}
% If the letter in the preamble is |m|, |#4| will be equal to
% |\@@_center_cell_box:| (see just below).
@@ -5302,35 +5307,50 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
+%
+% \begin{macrocode}
+\str_new:N \c_@@_ignorespaces_str
+\str_set:Nx \c_@@_ignorespaces_str { \ignorespaces }
+\str_remove_all:Nn \c_@@_ignorespaces_str { ~ }
+% \end{macrocode}
+%
+% \bigskip
+% In order to test whether a cell is empty, we test whether it begins by
+% |\ignorespaces\unskip|. However, in some circunstancies, for example when
+% |\collectcell| of \pkg{collcell} is used, the cell does not begin with
+% |\ignorespaces|. In that case, we consider as not empty...
+%
+% First, we test if the next token is |\ignorespaces| and it's not very easy...
% \begin{macrocode}
-\cs_new_protected:Npn \@@_test_if_empty: \ignorespaces #1
+\cs_new_protected:Npn \@@_test_if_empty: { \peek_after:Nw \@@_test_if_empty_i: }
+\cs_new_protected:Npn \@@_test_if_empty_i:
+ {
+ \str_set:Nx \l_tmpa_str { \token_to_meaning:N \l_peek_token }
+ \str_if_eq:NNT \l_tmpa_str \c_@@_ignorespaces_str
+ { \@@_test_if_empty:w }
+ }
+\cs_new_protected:Npn \@@_test_if_empty:w \ignorespaces
{
\peek_meaning:NT \unskip
{
\tl_gput_right:Nn \g_@@_cell_after_hook_tl
{
\box_set_wd:Nn \l_@@_cell_box \c_zero_dim
-% \end{macrocode}
-% We put the following code in order to have a column with the correct width
-% even when all the cells of the column are empty.
-% \begin{macrocode}
\skip_horizontal:N \l_@@_col_width_dim
}
}
- #1
}
-% \end{macrocode}
-%
+% \end{macrocode}
+%
%
% \begin{macrocode}
-\cs_new_protected:Npn \@@_test_if_empty_for_S: #1
+\cs_new_protected:Npn \@@_test_if_empty_for_S:
{
\peek_meaning:NT \__siunitx_table_skip:n
{
\tl_gput_right:Nn \g_@@_cell_after_hook_tl
{ \box_set_wd:Nn \l_@@_cell_box \c_zero_dim }
}
- #1
}
% \end{macrocode}
%
@@ -5393,10 +5413,10 @@ version 2005/12/01 or later.
\tl_set:Nn \l_tmpa_tl { #1 }
\@@_keys_p_column:V \l_tmpa_tl
\IfPackageLoadedTF { varwidth }
- { \@@_make_preamble_ii_iv:nn { #2 } { varwidth } }
+ { \@@_make_preamble_ii_iv:nnn { #2 } { varwidth } { } }
{
\@@_error_or_warning:n { varwidth~not~loaded }
- \@@_make_preamble_ii_iv:nn { #2 } { minipage }
+ \@@_make_preamble_ii_iv:nnn { #2 } { minipage } { }
}
}
% \end{macrocode}
@@ -5523,23 +5543,27 @@ version 2005/12/01 or later.
% \begin{macrocode}
\cs_new_protected:Npn \@@_make_preamble_S_i:n #1
{
- \tl_gput_right:NV \g_@@_array_preamble_tl \g_@@_pre_cell_tl
- \tl_gclear:N \g_@@_pre_cell_tl
- \tl_gput_right:Nn \g_@@_array_preamble_tl
+ \IfPackageLoadedTF { siunitx }
{
- > {
- \@@_cell_begin:w
- \keys_set:nn { siunitx } { #1 }
- \siunitx_cell_begin:w
+ \tl_gput_right:NV \g_@@_array_preamble_tl \g_@@_pre_cell_tl
+ \tl_gclear:N \g_@@_pre_cell_tl
+ \tl_gput_right:Nn \g_@@_array_preamble_tl
+ {
+ > {
+ \@@_cell_begin:w
+ \keys_set:nn { siunitx } { #1 }
+ \siunitx_cell_begin:w
+ }
+ c
+ < { \siunitx_cell_end: \@@_cell_end: }
}
- c
- < { \siunitx_cell_end: \@@_cell_end: }
- }
% \end{macrocode}
% We increment the counter of columns and then we test for the presence of a |<|.
% \begin{macrocode}
- \int_gincr:N \c@jCol
- \@@_rec_preamble_after_col:n
+ \int_gincr:N \c@jCol
+ \@@_rec_preamble_after_col:n
+ }
+ { \@@_fatal:n { siunitx~not~loaded } }
}
% \end{macrocode}
%
@@ -5827,16 +5851,17 @@ version 2005/12/01 or later.
\bool_if:NTF \l_@@_X_columns_aux_bool
{
\exp_args:Nne
- \@@_make_preamble_ii_iv:nn
+ \@@_make_preamble_ii_iv:nnn
{ \l_@@_weight_int \l_@@_X_columns_dim }
{ minipage }
+ { \@@_no_update_width: }
}
{
\tl_gput_right:Nn \g_@@_array_preamble_tl
{
> {
\@@_cell_begin:w
- \bool_set_true:N \l_@@_X_column_bool
+ \bool_set_true:N \l_@@_X_bool
% \end{macrocode}
% You encounter a problem on 2023-03-04: for an environment with |X| columns,
% during the first compilations (which are not the definitive one), sometimes,
@@ -5869,6 +5894,15 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \medskip
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_no_update_width:
+ {
+ \tl_gput_right:Nn \g_@@_cell_after_hook_tl
+ { \cs_set_eq:NN \@@_update_max_cell_width: \prg_do_nothing: }
+ }
+% \end{macrocode}
+%
+% \medskip
% For the letter set by the user with |vlines-in-sub-matrix| (vlism).
% \begin{macrocode}
\cs_new_protected:Npn \@@_make_preamble_vlism:n #1
@@ -6863,13 +6897,13 @@ version 2005/12/01 or later.
% \end{macrocode}
% We compute in |\g_tmpa_skip| the common width of the columns (it's a skip and
% not a dimension). We use a global variable because we are in a cell of an
-% |\halign| and because we have to use this variable in other cells (of the same
+% |\halign| and because we have to use that variable in other cells (of the same
% row). The affectation of |\g_tmpa_skip|, like all the affectations, must be
% done after the |\omit| of the cell.
%
% \smallskip
-% We give a default value for |\g_tmpa_skip| (|0 pt plus 1 fill|) but it will
-% just after be erased by a fixed value in the concerned cases.
+% We give a default value for |\g_tmpa_skip| (|0 pt plus 1 fill|) but we will
+% add some dimensions to it.
% \begin{macrocode}
\skip_gset:Nn \g_tmpa_skip { 0 pt~plus 1 fill }
\bool_if:NF \l_@@_auto_columns_width_bool
@@ -6878,8 +6912,8 @@ version 2005/12/01 or later.
\bool_lazy_and:nnTF
\l_@@_auto_columns_width_bool
{ \bool_not_p:n \l_@@_block_auto_columns_width_bool }
- { \skip_gset_eq:NN \g_tmpa_skip \g_@@_max_cell_width_dim }
- { \skip_gset_eq:NN \g_tmpa_skip \l_@@_columns_width_dim }
+ { \skip_gadd:Nn \g_tmpa_skip \g_@@_max_cell_width_dim }
+ { \skip_gadd:Nn \g_tmpa_skip \l_@@_columns_width_dim }
\skip_gadd:Nn \g_tmpa_skip { 2 \col@sep }
}
\skip_horizontal:N \g_tmpa_skip
@@ -11967,11 +12001,11 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
-% \section{The key corners}
+% \section{The empty corners}
%
-% When the key |corners| is raised, the rules are not drawn in the
-% corners. Of course, we have to compute the corners before we begin to draw the
-% rules.
+% When the key |corners| is raised, the rules are not drawn in the corners; they
+% are not colored and |\TikzEveryCell| does not apply. Of course, we have to
+% compute the corners before we begin to draw the rules.
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_compute_corners:
@@ -12771,7 +12805,7 @@ version 2005/12/01 or later.
% column, it's imperative. Otherwise, the process for the determination of the
% widths of the columns will be wrong.
% \begin{macrocode}
- && ! \l_@@_X_column_bool
+ && ! \l_@@_X_bool
}
{ \exp_args:Nee \@@_Block_iv:nnnnn }
{ \exp_args:Nee \@@_Block_v:nnnnn }
@@ -12791,8 +12825,8 @@ version 2005/12/01 or later.
%
% |#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 \textsl{key=values} pairs, |#4| are
-% the tokens to put before the math mode and before the composition of the block
-% and |#5| is the label (=content) of the block.
+% the tokens to put before the potential math mode and before the composition of
+% the block and |#5| is the label (=content) of the block.
% \begin{macrocode}
\cs_new_protected:Npn \@@_Block_iv:nnnnn #1 #2 #3 #4 #5
{
@@ -12806,7 +12840,8 @@ version 2005/12/01 or later.
{ \int_use:N \c@jCol }
{ \int_eval:n { \c@iRow + #1 - 1 } }
{ \int_eval:n { \c@jCol + #2 - 1 } }
- { \exp_not:n { ##1 } } { \exp_not:n { ##2 } }
+ { \exp_not:n { ##1 } }
+ { \exp_not:n { ##2 } }
}
}
\box_gclear_new:c
@@ -12877,7 +12912,7 @@ version 2005/12/01 or later.
{ \int_compare_p:nNn { #2 } = 1 }
% \end{macrocode}
% Remind that, when the column has not a fixed width, the dimension
-% |\l_@@_col_width_dim| has the conventionnal value of $-1$~cm.
+% |\l_@@_col_width_dim| has the conventional value of $-1$~cm.
% \begin{macrocode}
{ \dim_compare_p:n { \l_@@_col_width_dim >= \c_zero_dim } }
{ ! \g_@@_rotate_bool }
@@ -12956,30 +12991,38 @@ version 2005/12/01 or later.
}
}
% \end{macrocode}
-% If we are in a mono-row block, we take into account the height and the
-% depth of that block for the height and the depth of the row.
+% If we are in a mono-row block and if that block has no vertical option for the
+% position\footnote{If the block has a key of a vertical position, that means
+% that it has to be put in a vertical space determined by the \emph{others}
+% cells of the row. Therefore there is no point creating space here. Moreover,
+% that would lead to problems when a multi-row block with a position key such as
+% |b| or |B|.}, we take into account the height and the depth of that block for the
+% height and the depth of the row.
% \begin{macrocode}
- \int_compare:nNnT { #1 } = 1
- {
- \dim_gset:Nn \g_@@_blocks_ht_dim
- {
- \dim_max:nn
- \g_@@_blocks_ht_dim
- {
- \box_ht:c
- { g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box }
- }
- }
- \dim_gset:Nn \g_@@_blocks_dp_dim
- {
- \dim_max:nn
- \g_@@_blocks_dp_dim
- {
- \box_dp:c
- { g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box }
- }
- }
- }
+ \str_if_eq:VnT \l_@@_vpos_of_block_str { c }
+ {
+ \int_compare:nNnT { #1 } = 1
+ {
+ \dim_gset:Nn \g_@@_blocks_ht_dim
+ {
+ \dim_max:nn
+ \g_@@_blocks_ht_dim
+ {
+ \box_ht:c
+ { g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box }
+ }
+ }
+ \dim_gset:Nn \g_@@_blocks_dp_dim
+ {
+ \dim_max:nn
+ \g_@@_blocks_dp_dim
+ {
+ \box_dp:c
+ { g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box }
+ }
+ }
+ }
+ }
\seq_gput_right:Nx \g_@@_blocks_seq
{
\l_tmpa_tl
@@ -16157,6 +16200,15 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \begin{macrocode}
+\@@_msg_new:nn { siunitx~not~loaded }
+ {
+ siunitx~not~loaded\\
+ You~can't~use~the~columns~'S'~because~'siunitx'~is~not~loaded.\\
+ That~error~is~fatal.
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
\@@_msg_new:nn { ragged2e~not~loaded }
{
You~have~to~load~'ragged2e'~in~order~to~use~the~key~'\l_keys_key_str'~in~