diff options
author | Karl Berry <karl@freefriends.org> | 2023-07-14 21:05:26 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2023-07-14 21:05:26 +0000 |
commit | 388fd5ba705617c4ea1ab64b1edd2da78f8285df (patch) | |
tree | 3ea7cd92571794250db1d9b19725b1e91469903b /Master/texmf-dist/source | |
parent | 4f4a6fbdcff9c424b96574e43efe30c376e6ea33 (diff) |
nicematrix (14jul23)
git-svn-id: svn://tug.org/texlive/trunk@67630 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source')
-rw-r--r-- | Master/texmf-dist/source/latex/nicematrix/nicematrix-code.dtx | 614 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/nicematrix/nicematrix.ins | 2 |
2 files changed, 377 insertions, 239 deletions
diff --git a/Master/texmf-dist/source/latex/nicematrix/nicematrix-code.dtx b/Master/texmf-dist/source/latex/nicematrix/nicematrix-code.dtx index 86e54a5643d..cd4e1fd25bc 100644 --- a/Master/texmf-dist/source/latex/nicematrix/nicematrix-code.dtx +++ b/Master/texmf-dist/source/latex/nicematrix/nicematrix-code.dtx @@ -17,8 +17,8 @@ % % \fi % \iffalse -\def\myfileversion{6.20a} -\def\myfiledate{2023/06/30} +\def\myfileversion{6.21} +\def\myfiledate{2023/07/14} % % %<*batchfile> @@ -384,7 +384,7 @@ version 2005/12/01 or later. % % \bigskip % The following regex will be used to modify the preamble of the array when the -% key |colortbl-like| is used. +% key |color-inside| is used. % \begin{macrocode} \regex_const:Nn \c_@@_columncolor_regex { \c { columncolor } } % \end{macrocode} @@ -598,7 +598,7 @@ version 2005/12/01 or later. % The following command is a small shortcut. % \begin{macrocode} \cs_new:Npn \@@_math_toggle_token: - { \bool_if:NF \l_@@_NiceTabular_bool \c_math_toggle_token } + { \bool_if:NF \l_@@_tabular_bool \c_math_toggle_token } % \end{macrocode} % % \bigskip @@ -737,7 +737,40 @@ version 2005/12/01 or later. \cs_new_protected:Npn \@@_qpoint:n #1 { \pgfpointanchor { \@@_env: - #1 } { center } } % \end{macrocode} -% +% +% \bigskip +% If the user uses |{NiceTabular}|, |{NiceTabular*}| or |{NiceTabularX}|, we +% will raise the following flag. +% \begin{macrocode} +\bool_new:N \l_@@_tabular_bool +% \end{macrocode} +% +% \bigskip +% |\g_@@_delims_bool| will be true for the environments with delimiters (ex. : +% |{pNiceMatrix}|, |{pNiceArray}|, |\pAutoNiceMatrix|, etc.). +% \begin{macrocode} +\bool_new:N \g_@@_delims_bool +\bool_gset_true:N \g_@@_delims_bool +% \end{macrocode} +% In fact, if there is delimiters in the preamble of |{NiceArray}| (eg: +% |[cccc]|), this boolean will be set to false. +% +% \medskip +% The following boolean will be equal to |true| in the environments which have +% an environment (provided by the final user): |{NiceTabular}|, |{NiceArray}|, +% |{pNiceArray}|, etc. +% \begin{macrocode} +\bool_new:N \l_@@_preamble_bool +\bool_set_true:N \l_@@_preamble_bool +% \end{macrocode} +% +% \medskip +% We need a special treatment for |{NiceMatrix}| when |vlines| is not used, in +% order to retrieve |\arraycolsep| on both sides. +% \begin{macrocode} +\bool_new:N \l_@@_NiceMatrix_without_vlines_bool +% \end{macrocode} +% % \bigskip % The following counter will count the environments |{NiceMatrixBlock}|. % \begin{macrocode} @@ -861,22 +894,6 @@ version 2005/12/01 or later. \bool_new:N \l_@@_notes_detect_duplicates_bool \bool_set_true:N \l_@@_notes_detect_duplicates_bool % \end{macrocode} -% -% \bigskip -% If the user uses |{NiceArray}| or |{NiceTabular}| the flag -% |\g_@@_NiceArray_bool| will be raised. -% \begin{macrocode} -\bool_new:N \g_@@_NiceArray_bool -% \end{macrocode} -% In fact, if there is delimiters in the preamble of |{NiceArray}| (eg: -% |[cccc]|), this boolean will be set to false. -% -% \bigskip -% If the user uses |{NiceTabular}|, |{NiceTabular*}| or |{NiceTabularX}|, we -% will raise the following flag. -% \begin{macrocode} -\bool_new:N \l_@@_NiceTabular_bool -% \end{macrocode} % % \bigskip % If the user uses |{NiceTabular*}|, the width of the tabular (in the first @@ -894,19 +911,19 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% If the user uses an environment without preamble, we will raise the following -% flag. -% \begin{macrocode} -\bool_new:N \l_@@_Matrix_bool -% \end{macrocode} -% -% \bigskip % The following boolean will be raised when the command |\rotate| is used. % \begin{macrocode} \bool_new:N \g_@@_rotate_bool % \end{macrocode} % % \bigskip +% The following boolean will be raise then the command |\rotate| is used with +% the key |c|. +% \begin{macrocode} +\bool_new:N \g_@@_rotate_c_bool +% \end{macrocode} +% +% \bigskip % 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} @@ -1002,14 +1019,6 @@ version 2005/12/01 or later. } % \end{macrocode} % -% \bigskip -% The following token list corresponds to the option |code-after| (it's also -% possible to set the value of that parameter with the keyword |\CodeAfter|). -% That parameter is \emph{public}. -% \begin{macrocode} -\tl_new:N \g_nicematrix_code_after_tl -\bool_new:N \l_@@_in_code_after_bool -% \end{macrocode} % % \bigskip % For the key |code| of the command |\SubMatrix| (itself in the main @@ -1032,16 +1041,33 @@ version 2005/12/01 or later. % |\g_@@_pre_code_after_tl| because we must take care of the order in which % instructions stored in that parameters are executed. % \begin{macrocode} -\tl_new:N \g_@@_pre_code_after_tl + % \end{macrocode} % % \bigskip +% The so-called `\CodeBefore` is splitted in two parts because we want to control +% the order of execution of some instructions. +% \begin{macrocode} +\tl_new:N \g_@@_pre_code_before_tl +\tl_new:N \g_nicematrix_code_before_tl +% \end{macrocode} % The value of the key |code-before| will be added to the left of % |\g_@@_pre_code_before_tl|. Idem for the code between |\CodeBefore| and % |\Body|. -% \begin{macrocode} -\tl_new:N \g_nicematrix_code_before_tl -\tl_new:N \g_@@_pre_code_before_tl +% +% \bigskip +% The so-called `\CodeAfter` is splitted in two parts because we want to control +% the order of execution of some instructions. +% \begin{macrocode} +\tl_new:N \g_@@_pre_code_after_tl +\tl_new:N \g_nicematrix_code_after_tl +% \end{macrocode} +% The `\CodeAfter` provided by the final user (with the key |code-after| or the +% keyword |\CodeAfter|) will be stored in the second token list. +% +% \bigskip +% \begin{macrocode} +\bool_new:N \l_@@_in_code_after_bool % \end{macrocode} % % \bigskip @@ -1353,7 +1379,6 @@ version 2005/12/01 or later. % \begin{macrocode} \bool_new:N \l_@@_draw_first_bool % \end{macrocode} -% % % \medskip % The following flag corresponds to the keys |vlines| and |hlines| of the @@ -1496,6 +1521,13 @@ version 2005/12/01 or later. \bool_new:N \g_@@_last_col_found_bool % \end{macrocode} % This boolean is set to |false| at the end of |\@@_pre_array_ii:|. +% +% \medskip +% In the last column, we will raise the following flag (it will be used by +% |\OnlyMainNiceMatrix|). +% \begin{macrocode} +\bool_new:N \l_@@_in_last_col_bool +% \end{macrocode} % \end{itemize} % % \bigskip @@ -1536,7 +1568,8 @@ version 2005/12/01 or later. } } % \end{macrocode} -% +% +% % \bigskip % \section{The command \textbackslash tabularnote} % @@ -1694,7 +1727,7 @@ version 2005/12/01 or later. { \bool_if:nT { \cs_if_exist_p:N \@captype || \l_@@_in_env_bool } { - \bool_if:nTF { ! \l_@@_NiceTabular_bool && \l_@@_in_env_bool } + \bool_if:nTF { ! \l_@@_tabular_bool && \l_@@_in_env_bool } { \@@_error:n { tabularnote~forbidden } } { \bool_if:NTF \l_@@_in_caption_bool @@ -1981,10 +2014,10 @@ version 2005/12/01 or later. % \bigskip % By default, the commands |\cellcolor| and |\rowcolor| are available for the % user in the cells of the tabular (the user may use the commands provided by -% |\colortbl|). However, if the key |colortbl-like| is used, these +% |\colortbl|). However, if the key |color-inside| is used, these % commands are available. % \begin{macrocode} -\bool_new:N \l_@@_colortbl_like_bool +\bool_new:N \l_@@_color_inside_bool % \end{macrocode} % % \bigskip @@ -2308,6 +2341,8 @@ version 2005/12/01 or later. % \begin{macrocode} \keys_define:nn { NiceMatrix / Global } { + rounded-corners .dim_set:N = \l_@@_tab_rounded_corners_dim , + rounded-corners .default:n = 4 pt , custom-line .code:n = \@@_custom_line:n { #1 } , rules .code:n = \keys_set:nn { NiceMatrix / rules } { #1 } , rules .value_required:n = true , @@ -2446,10 +2481,11 @@ version 2005/12/01 or later. name .value_required:n = true , code-after .tl_gset:N = \g_nicematrix_code_after_tl , code-after .value_required:n = true , - colortbl-like .code:n = - \bool_set_true:N \l_@@_colortbl_like_bool + color-inside .code:n = + \bool_set_true:N \l_@@_color_inside_bool \bool_set_true:N \l_@@_code_before_bool , - colortbl-like .value_forbidden:n = true + color-inside .value_forbidden:n = true , + colortbl-like .meta:n = color-inside } % \end{macrocode} % @@ -2734,8 +2770,6 @@ version 2005/12/01 or later. width .code:n = \dim_set:Nn \l_@@_width_dim { #1 } \bool_set_true:N \l_@@_width_used_bool , width .value_required:n = true , - rounded-corners .dim_set:N = \l_@@_tab_rounded_corners_dim , - rounded-corners .default:n = 4 pt , notes .code:n = \keys_set:nn { NiceMatrix / notes } { #1 } , tabularnote .tl_gset:N = \g_@@_tabularnote_tl , tabularnote .value_required:n = true , @@ -2794,7 +2828,7 @@ version 2005/12/01 or later. % |\@@_cell_end:| (and the potential |\c_math_toggle_token| also). % \begin{macrocode} \hbox_set:Nw \l_@@_cell_box - \bool_if:NF \l_@@_NiceTabular_bool + \bool_if:NF \l_@@_tabular_bool { \c_math_toggle_token \bool_if:NT \l_@@_small_bool \scriptstyle @@ -2888,16 +2922,28 @@ version 2005/12/01 or later. \cs_new_protected:Npn \@@_rotate_cell_box: { \box_rotate:Nn \l_@@_cell_box { 90 } - \int_compare:nNnT \c@iRow = \l_@@_last_row_int - { - \vbox_set_top:Nn \l_@@_cell_box + \bool_if:NTF \g_@@_rotate_c_bool + { + \hbox_set:Nn \l_@@_cell_box { - \vbox_to_zero:n { } - \skip_vertical:n { - \box_ht:N \@arstrutbox + 0.8 ex } - \box_use:N \l_@@_cell_box + \c_math_toggle_token + \vcenter { \box_use:N \l_@@_cell_box } + \c_math_toggle_token } - } + } + { + \int_compare:nNnT \c@iRow = \l_@@_last_row_int + { + \vbox_set_top:Nn \l_@@_cell_box + { + \vbox_to_zero:n { } + \skip_vertical:n { - \box_ht:N \@arstrutbox + 0.8 ex } + \box_use:N \l_@@_cell_box + } + } + } \bool_gset_false:N \g_@@_rotate_bool + \bool_gset_false:N \g_@@_rotate_c_bool } % \end{macrocode} % @@ -3179,7 +3225,7 @@ version 2005/12/01 or later. % \begin{macrocode} \cs_new_protected:Npn \@@_array:n { - \bool_if:NTF \l_@@_NiceTabular_bool + \bool_if:NTF \l_@@_tabular_bool { \dim_set_eq:NN \col@sep \tabcolsep } { \dim_set_eq:NN \col@sep \arraycolsep } \dim_compare:nNnTF \l_@@_tabular_width_dim = \c_zero_dim @@ -3339,13 +3385,15 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% When the key |colortbl-like| is used, the following code will be executed. +% When the key |color-inside| is used, the following code will be executed. % \begin{macrocode} \cs_new_protected:Npn \@@_colortbl_like: { \cs_set_eq:NN \cellcolor \@@_cellcolor_tabular \cs_set_eq:NN \rowcolor \@@_rowcolor_tabular \cs_set_eq:NN \columncolor \@@_columncolor_preamble + \cs_set_eq:NN \rowcolors \@@_rowcolors_tabular + \cs_set_eq:NN \rowlistcolors \@@_rowlistcolors_tabular } % \end{macrocode} % @@ -3494,7 +3542,7 @@ version 2005/12/01 or later. \cs_set_eq:NN \RowStyle \@@_RowStyle:n \seq_map_inline:Nn \l_@@_custom_line_commands_seq { \cs_set_eq:cc { ##1 } { nicematrix - ##1 } } - \bool_if:NT \l_@@_colortbl_like_bool \@@_colortbl_like: + \bool_if:NT \l_@@_color_inside_bool \@@_colortbl_like: \bool_if:NT \l_@@_renew_dots_bool \@@_renew_dots: % \end{macrocode} % We redefine |\multicolumn| and, since we want |\multicolumn| to be available @@ -3596,9 +3644,6 @@ version 2005/12/01 or later. % \begin{macrocode} \cs_new_protected:Npn \@@_pre_array: { -% \end{macrocode} -% -% \begin{macrocode} \cs_if_exist:NT \theiRow { \int_set_eq:NN \l_@@_old_iRow_int \c@iRow } \int_gzero_new:N \c@iRow \cs_if_exist:NT \thejCol { \int_set_eq:NN \l_@@_old_jCol_int \c@jCol } @@ -3703,11 +3748,7 @@ version 2005/12/01 or later. % \begin{macrocode} \dim_zero_new:N \l_@@_left_delim_dim \dim_zero_new:N \l_@@_right_delim_dim - \bool_if:NTF \g_@@_NiceArray_bool - { - \dim_gset:Nn \l_@@_left_delim_dim { 2 \arraycolsep } - \dim_gset:Nn \l_@@_right_delim_dim { 2 \arraycolsep } - } + \bool_if:NTF \g_@@_delims_bool { % \end{macrocode} % The command |\bBigg@| is a command of \pkg{amsmath}. @@ -3717,6 +3758,10 @@ version 2005/12/01 or later. \hbox_set:Nn \l_tmpa_box { $ \bBigg@ 5 \g_@@_right_delim_tl $ } \dim_set:Nn \l_@@_right_delim_dim { \box_wd:N \l_tmpa_box } } + { + \dim_gset:Nn \l_@@_left_delim_dim { 2 \arraycolsep } + \dim_gset:Nn \l_@@_right_delim_dim { 2 \arraycolsep } + } % \end{macrocode} % % \bigskip @@ -3759,7 +3804,8 @@ version 2005/12/01 or later. % \bigskip % \section{The \textbackslash CodeBefore} % -% The following command will be executed if the |\CodeBefore| has to be actually executed. +% The following command will be executed if the |\CodeBefore| has to be actually +% executed (that commmand will be used only once and is present only for legibility). % \begin{macrocode} \cs_new_protected:Npn \@@_pre_code_before: { @@ -3861,7 +3907,7 @@ version 2005/12/01 or later. % We compose the |\CodeBefore| in math mode in order to nullify the spaces put % by the user between instructions in the |\CodeBefore|. % \begin{macrocode} - \bool_if:NT \l_@@_NiceTabular_bool \c_math_toggle_token + \bool_if:NT \l_@@_tabular_bool \c_math_toggle_token % \end{macrocode} % % \bigskip @@ -3895,7 +3941,7 @@ version 2005/12/01 or later. \@@_actually_color: \l_@@_code_before_tl \q_stop - \bool_if:NT \l_@@_NiceTabular_bool \c_math_toggle_token + \bool_if:NT \l_@@_tabular_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: } @@ -3927,7 +3973,7 @@ version 2005/12/01 or later. % % 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 +% rest of the |\CodeBefore|, excepted, of course, if we are in the first % compilation. % \begin{macrocode} \cs_new_protected:Npn \@@_CodeBefore:w #1 \q_stop @@ -3940,8 +3986,6 @@ version 2005/12/01 or later. } % \end{macrocode} % -% \bigskip -% % % \bigskip % By default, if the user uses the |\CodeBefore|, only the |col| nodes, |row| @@ -4094,7 +4138,7 @@ version 2005/12/01 or later. \bool_gset_false:N \g_@@_row_of_col_done_bool \str_if_empty:NT \g_@@_name_env_str { \str_gset:Nn \g_@@_name_env_str { NiceArrayWithDelims } } - \bool_if:NTF \l_@@_NiceTabular_bool + \bool_if:NTF \l_@@_tabular_bool \mode_leave_vertical: \@@_test_if_math_mode: \bool_if:NT \l_@@_in_env_bool { \@@_fatal:n { Yet~in~env } } @@ -4182,9 +4226,9 @@ version 2005/12/01 or later. % 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 - { \keys_set:nn { NiceMatrix / NiceArray } } + \bool_if:NTF \g_@@_delims_bool { \keys_set:nn { NiceMatrix / pNiceArray } } + { \keys_set:nn { NiceMatrix / NiceArray } } { #3 , #5 } % \end{macrocode} % @@ -4319,13 +4363,10 @@ version 2005/12/01 or later. } % \end{macrocode} % -% The construction of the real box is different when |\g_@@_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. -% +% The construction of the real box is different whether we have delimiters to +% put. % \begin{macrocode} - \bool_if:NTF \g_@@_NiceArray_bool + \bool_if:nTF { ! \g_@@_delims_bool } { \str_case:VnF \l_@@_baseline_tl { @@ -4336,9 +4377,9 @@ version 2005/12/01 or later. } % \end{macrocode} % -% Now, in the case of an environment |{pNiceArray}|, |{bNiceArray}|, etc. We -% compute |\l_tmpa_dim| which is the total height of the ``first row'' above the -% array (when the key |first-row| is used). +% Now, in the case of an environment with delimiters. We compute |\l_tmpa_dim| +% which is the total height of the ``first row'' above the array (when the key +% |first-row| is used). % \begin{macrocode} { \int_compare:nNnTF \l_@@_first_row_int = 0 @@ -4379,11 +4420,11 @@ version 2005/12/01 or later. \skip_vertical:n { -\l_tmpa_dim - \arrayrulewidth } \hbox { - \bool_if:NTF \l_@@_NiceTabular_bool + \bool_if:NTF \l_@@_tabular_bool { \skip_horizontal:N -\tabcolsep } { \skip_horizontal:N -\arraycolsep } \@@_use_arraybox_with_notes_c: - \bool_if:NTF \l_@@_NiceTabular_bool + \bool_if:NTF \l_@@_tabular_bool { \skip_horizontal:N -\tabcolsep } { \skip_horizontal:N -\arraycolsep } } @@ -4427,8 +4468,8 @@ version 2005/12/01 or later. \skip_horizontal:N \g_@@_width_last_col_dim \skip_horizontal:N \col@sep } - \bool_if:NF \l_@@_Matrix_bool - { + \bool_if:NT \l_@@_preamble_bool + { \int_compare:nNnT \c@jCol < \g_@@_static_num_of_col_int { \@@_warning_gredirect_none:n { columns~not~used } } } @@ -4468,17 +4509,24 @@ version 2005/12/01 or later. % \bigskip % The transformation of the preamble is an operation in several % steps.\footnote{Be careful: the transformation of the preamble may also have -% by-side effects, for example, the boolean |\g_@@_NiceArray_bool| will be set -% to |false| if we detect in the preamble a delimiter at the beginning or at the +% by-side effects, for example, the boolean |\g_@@_delims_bool| will be set +% to |true| if we detect in the preamble a delimiter at the beginning or at the % end.} % % \bigskip % The preamble given by the final user is in |\g_@@_preamble_tl| and the modified % version will be stored in |\g_@@_preamble_tl| also. -% % \begin{macrocode} \cs_new_protected:Npn \@@_transform_preamble: { + \bool_if:NT \l_@@_preamble_bool \@@_transform_preamble_i: + \@@_transform_preamble_ii: + } +% \end{macrocode} +% +% \begin{macrocode} +\cs_new_protected:Npn \@@_transform_preamble_i: + { % \end{macrocode} % First, we will do an ``expansion'' of the preamble with the tools of the % package \pkg{array} itself. This ``expansion'' will expand all the constructions @@ -4499,100 +4547,82 @@ version 2005/12/01 or later. % That's why we do those redefinitions in a TeX group. % \begin{macrocode} \group_begin: -% \end{macrocode} -% -% If we are in an environment without explicit preamble, we have nothing to do -% (excepted the treatment on both sides of the preamble which will be done at -% 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} % % \bigskip % If the package \pkg{varwidth} has defined the column type |V|, we protect from % expansion by redefining it to |\@@_V:| (which will be catched by our system). % \begin{macrocode} - \cs_if_exist:NT \NC@find@V { \@@_newcolumntype V { \@@_V: } } + \cs_if_exist:NT \NC@find@V { \@@_newcolumntype V { \@@_V: } } % \end{macrocode} % % First, we have to store our preamble in the token register |\@temptokena| % (those ``token registers'' are \emph{not} supported by the L3 programming layer). % \begin{macrocode} - \exp_args:NV \@temptokena \g_@@_preamble_tl + \exp_args:NV \@temptokena \g_@@_preamble_tl % \end{macrocode} % Initialisation of a flag used by \pkg{array} to detect the end of the expansion. % \begin{macrocode} - \@tempswatrue + \@tempswatrue % \end{macrocode} % The following line actually does the expansion (it's has been copied from % |array.sty|). The expanded version is still in |\@temptokena|. % \begin{macrocode} - \@whilesw \if@tempswa \fi { \@tempswafalse \the \NC@list } -% \end{macrocode} -% -% -% \bigskip -% Now, we have to ``patch'' that preamble by transforming some columns. -% We will insert in the TeX flow the preamble in its actual form (that is to say -% after the ``expansion'') following by a marker |\q_stop| and we will consume -% these tokens constructing the (new form of the) preamble in -% |\g_@@_preamble_tl|. This is done recursively with the command -% |\@@_patch_preamble:n|. In the same time, we will count the columns with the -% counter |\c@jCol|. -% \begin{macrocode} - \int_gzero:N \c@jCol - \tl_gclear:N \g_@@_preamble_tl + \@whilesw \if@tempswa \fi { \@tempswafalse \the \NC@list } + \int_gzero:N \c@jCol + \tl_gclear:N \g_@@_preamble_tl % \end{macrocode} % |\g_tmpb_bool| will be raised if you have a \verb+|+ at the end of the preamble. % \begin{macrocode} - \bool_gset_false:N \g_tmpb_bool - \tl_if_eq:NnTF \l_@@_vlines_clist { all } + \bool_gset_false:N \g_tmpb_bool + \tl_if_eq:NnTF \l_@@_vlines_clist { all } + { + \tl_gset:Nn \g_@@_preamble_tl + { ! { \skip_horizontal:N \arrayrulewidth } } + } + { + \clist_if_in:NnT \l_@@_vlines_clist 1 { \tl_gset:Nn \g_@@_preamble_tl { ! { \skip_horizontal:N \arrayrulewidth } } } - { - \clist_if_in:NnT \l_@@_vlines_clist 1 - { - \tl_gset:Nn \g_@@_preamble_tl - { ! { \skip_horizontal:N \arrayrulewidth } } - } - } + } % \end{macrocode} % The sequence |\g_@@_cols_vlsim_seq| will contain the numbers of the columns % where you will to have to draw vertical lines in the potential sub-matrices % (hence the name |vlism|). % \begin{macrocode} - \seq_clear:N \g_@@_cols_vlism_seq + \seq_clear:N \g_@@_cols_vlism_seq % \end{macrocode} % % \bigskip % The following sequence will store the arguments of the successive |>| in the % preamble. % \begin{macrocode} - \tl_gclear_new:N \g_@@_pre_cell_tl + \tl_gclear_new:N \g_@@_pre_cell_tl % \end{macrocode} % % The counter |\l_tmpa_int| will count the number of consecutive occurrences % of the symbol \verb+|+. % \begin{macrocode} - \int_zero:N \l_tmpa_int + \int_zero:N \l_tmpa_int % \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 - \int_gset_eq:NN \g_@@_static_num_of_col_int \c@jCol - } + \exp_after:wN \@@_patch_preamble:n \the \@temptokena \q_stop + \int_gset_eq:NN \g_@@_static_num_of_col_int \c@jCol % \end{macrocode} +% Remark that |\g_@@_static_num_of_col_int| will stay equel to zero in the +% environments without preamble since we are in a code that is executed only +% in the environments \emph{with} preamble. % % \medskip % Now, we replace |\columncolor| by |\@@_columncolor_preamble|. % \begin{macrocode} - \bool_if:NT \l_@@_colortbl_like_bool + \bool_if:NT \l_@@_color_inside_bool { \regex_replace_all:NnN \c_@@_columncolor_regex @@ -4606,7 +4636,22 @@ version 2005/12/01 or later. % the columns of type |w| and~|W|. % \begin{macrocode} \group_end: + } % \end{macrocode} +% +% +% +% \bigskip +% Now, we have to ``patch'' that preamble by transforming some columns. +% We will insert in the TeX flow the preamble in its actual form (that is to say +% after the ``expansion'') following by a marker |\q_stop| and we will consume +% these tokens constructing the (new form of the) preamble in +% |\g_@@_preamble_tl|. This is done recursively with the command +% |\@@_patch_preamble:n|. In the same time, we will count the columns with the +% counter |\c@jCol|. +% \begin{macrocode} +\cs_new_protected:Npn \@@_transform_preamble_ii: + { % % \medskip % If there was delimiters at the beginning or at the end of the preamble, the @@ -4615,7 +4660,7 @@ version 2005/12/01 or later. \bool_lazy_or:nnT { ! \str_if_eq_p:Vn \g_@@_left_delim_tl { . } } { ! \str_if_eq_p:Vn \g_@@_right_delim_tl { . } } - { \bool_gset_false:N \g_@@_NiceArray_bool } + { \bool_gset_true:N \g_@@_delims_bool } % \end{macrocode} % % \medskip @@ -4632,8 +4677,8 @@ version 2005/12/01 or later. { \bool_lazy_all:nT { - \g_@@_NiceArray_bool - { \bool_not_p:n \l_@@_NiceTabular_bool } + { \bool_not_p:n \g_@@_delims_bool } + { \bool_not_p:n \l_@@_tabular_bool } { \tl_if_empty_p:N \l_@@_vlines_clist } { \bool_not_p:n \l_@@_exterior_arraycolsep_bool } } @@ -4644,8 +4689,8 @@ version 2005/12/01 or later. { \bool_lazy_all:nT { - \g_@@_NiceArray_bool - { \bool_not_p:n \l_@@_NiceTabular_bool } + { \bool_not_p:n \g_@@_delims_bool } + { \bool_not_p:n \l_@@_tabular_bool } { \tl_if_empty_p:N \l_@@_vlines_clist } { \bool_not_p:n \l_@@_exterior_arraycolsep_bool } } @@ -5268,8 +5313,6 @@ version 2005/12/01 or later. < { \@@_cell_end: \hbox_set_end: - % The following line is probably pointless - % \bool_if:NT \g_@@_rotate_bool \@@_rotate_cell_box: #1 \@@_adjust_size_box: \makebox [ #4 ] [ #3 ] { \box_use_drop:N \l_@@_cell_box } @@ -5985,7 +6028,7 @@ version 2005/12/01 or later. % that's why we can't put |@{}| at the end of the preamble. That's why we remove % a |\arraycolsep| now. % \begin{macrocode} - \bool_lazy_and:nnT \l_@@_Matrix_bool \g_@@_NiceArray_bool + \bool_if:NT \l_@@_NiceMatrix_without_vlines_bool { \box_set_wd:Nn \l_@@_the_array_box { \box_wd:N \l_@@_the_array_box - \arraycolsep } @@ -6492,6 +6535,8 @@ version 2005/12/01 or later. \@@_transform_preamble: % \end{macrocode} % +% +% % The call to |\array| is in the following command (we have a dedicated macro % |\@@_array:n| because of compatibility with the classes \cls{revtex4-1} and % \cls{revtex4-2}). @@ -6710,8 +6755,8 @@ version 2005/12/01 or later. \int_gincr:N \g_tmpa_int \bool_lazy_all:nT { - \g_@@_NiceArray_bool - { \bool_not_p:n \l_@@_NiceTabular_bool } + { \bool_not_p:n \g_@@_delims_bool } + { \bool_not_p:n \l_@@_tabular_bool } { \clist_if_empty_p:N \l_@@_vlines_clist } { \bool_not_p:n \l_@@_exterior_arraycolsep_bool } { ! \l_@@_bar_at_end_of_pream_bool } @@ -6728,13 +6773,12 @@ version 2005/12/01 or later. % that's why we can't put |@{}| at the end of the preamble. That's why we remove % a |\arraycolsep| now. % \begin{macrocode} - \bool_lazy_and:nnT \l_@@_Matrix_bool \g_@@_NiceArray_bool + \bool_if:NT \l_@@_NiceMatrix_without_vlines_bool { \skip_horizontal:N -\arraycolsep } \pgfsys@markposition - { \@@_env: - col - \int_eval:n { - \g_tmpa_int + 1 } } + { \@@_env: - col - \int_eval:n { \g_tmpa_int + 1 } } \skip_horizontal:N 0.5\arrayrulewidth - \bool_lazy_and:nnT \l_@@_Matrix_bool \g_@@_NiceArray_bool + \bool_if:NT \l_@@_NiceMatrix_without_vlines_bool { \skip_horizontal:N \arraycolsep } } } @@ -6742,7 +6786,7 @@ version 2005/12/01 or later. \pgfrememberpicturepositiononpagetrue \pgfcoordinate { \@@_env: - col - \int_eval:n { \g_tmpa_int + 1 } } { - \bool_lazy_and:nnTF \l_@@_Matrix_bool \g_@@_NiceArray_bool + \bool_if:NT \l_@@_NiceMatrix_without_vlines_bool { \pgfpoint { - 0.5 \arrayrulewidth - \arraycolsep } @@ -6877,6 +6921,7 @@ version 2005/12/01 or later. { > { + \bool_set_true:N \l_@@_in_last_col_bool % \end{macrocode} % At the beginning of the cell, we link |\CodeAfter| to a command which % begins with |\\| (whereas the standard version of |\CodeAfter| begins does @@ -6949,19 +6994,17 @@ version 2005/12/01 or later. % % \interitem % The environment |{NiceArray}| is constructed upon the environment -% |{NiceArrayWithDelims}| but, in fact, there is a flag |\g_@@_NiceArray_bool|. -% In |{NiceArrayWithDelims}|, some special code will be executed if this flag is -% raised. +% |{NiceArrayWithDelims}|. % \begin{macrocode} \NewDocumentEnvironment { NiceArray } { } { - \bool_gset_true:N \g_@@_NiceArray_bool + \bool_gset_false:N \g_@@_delims_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). +% |\g_@@_delims_bool| is set to false). % \begin{macrocode} \NiceArrayWithDelims . . } @@ -6977,7 +7020,7 @@ version 2005/12/01 or later. { \NewDocumentEnvironment { #1 NiceArray } { } { - \bool_gset_false:N \g_@@_NiceArray_bool + \bool_gset_true:N \g_@@_delims_bool \str_if_empty:NT \g_@@_name_env_str { \str_gset:Nn \g_@@_name_env_str { #1 NiceArray } } \@@_test_if_math_mode: @@ -7003,9 +7046,12 @@ version 2005/12/01 or later. % \begin{macrocode} \cs_new_protected:Npn \@@_begin_of_NiceMatrix:nn #1 #2 { - \bool_set_true:N \l_@@_Matrix_bool - \use:c { #1 NiceArray } - { + \bool_set_false:N \l_@@_preamble_bool + \tl_clear:N \l_tmpa_tl + \bool_if:NT \l_@@_NiceMatrix_without_vlines_bool + { \tl_set:Nn \l_tmpa_tl { @ { } } } + \tl_put_right:Nn \l_tmpa_tl + { * { \int_case:nnF \l_@@_last_col_int @@ -7021,6 +7067,8 @@ version 2005/12/01 or later. } { #2 } } + \tl_set:Nn \l_tmpb_tl { \use:c { #1 NiceArray } } + \exp_args:NV \l_tmpb_tl \l_tmpa_tl } % \end{macrocode} % @@ -7033,7 +7081,7 @@ version 2005/12/01 or later. { \NewDocumentEnvironment { #1 NiceMatrix } { ! O { } } { - \bool_gset_false:N \g_@@_NiceArray_bool + \bool_gset_true:N \g_@@_delims_bool \str_gset:Nn \g_@@_name_env_str { #1 NiceMatrix } \keys_set:nn { NiceMatrix / NiceMatrix } { ##1 } \@@_begin_of_NiceMatrix:nV { #1 } \l_@@_columns_type_tl @@ -7047,9 +7095,12 @@ version 2005/12/01 or later. % \begin{macrocode} \NewDocumentEnvironment { NiceMatrix } { ! O { } } { - \bool_gset_false:N \g_@@_NiceArray_bool \str_gset:Nn \g_@@_name_env_str { NiceMatrix } \keys_set:nn { NiceMatrix / NiceMatrix } { #1 } + \bool_lazy_or:nnT + { \clist_if_empty_p:N \l_@@_vlines_clist } + { \l_@@_except_borders_bool } + { \bool_set_true:N \l_@@_NiceMatrix_without_vlines_bool } \@@_begin_of_NiceMatrix:nV { } \l_@@_columns_type_tl } { \endNiceArray } @@ -7077,36 +7128,6 @@ version 2005/12/01 or later. { \dim_set_eq:NN \l_@@_width_dim \linewidth } \str_gset:Nn \g_@@_name_env_str { NiceTabular } \keys_set:nn { NiceMatrix / NiceTabular } { #1 , #3 } - \int_compare:nNnT \l_@@_tab_rounded_corners_dim > \c_zero_dim - { - \bool_if:NT \l_@@_hvlines_bool - { - \bool_set_true:N \l_@@_except_borders_bool - % we should try to be more efficient in the number of lines of code here - \tl_if_empty:NTF \l_@@_rules_color_tl - { - \tl_gput_right:Nn \g_@@_pre_code_after_tl - { - \@@_stroke_block:nnn - { rounded-corners = \dim_use:N \l_@@_tab_rounded_corners_dim } - { 1-1 } - { \int_use:N \c@iRow - \int_use:N \c@jCol } - } - } - { - \tl_gput_right:Nn \g_@@_pre_code_after_tl - { - \@@_stroke_block:nnn - { - rounded-corners = \dim_use:N \l_@@_tab_rounded_corners_dim , - draw = \l_@@_rules_color_tl - } - { 1-1 } - { \int_use:N \c@iRow - \int_use:N \c@jCol } - } - } - } - } \tl_if_empty:NF \l_@@_short_caption_tl { \tl_if_empty:NT \l_@@_caption_tl @@ -7131,7 +7152,7 @@ version 2005/12/01 or later. } } { } - \bool_set_true:N \l_@@_NiceTabular_bool + \bool_set_true:N \l_@@_tabular_bool \NiceArray { #2 } } { \endNiceArray } @@ -7166,7 +7187,7 @@ version 2005/12/01 or later. \dim_zero_new:N \l_@@_width_dim \dim_set:Nn \l_@@_width_dim { #1 } \keys_set:nn { NiceMatrix / NiceTabular } { #2 , #4 } - \bool_set_true:N \l_@@_NiceTabular_bool + \bool_set_true:N \l_@@_tabular_bool \NiceArray { #3 } } { \endNiceArray } @@ -7179,7 +7200,7 @@ version 2005/12/01 or later. \str_gset:Nn \g_@@_name_env_str { NiceTabular* } \dim_set:Nn \l_@@_tabular_width_dim { #1 } \keys_set:nn { NiceMatrix / NiceTabular } { #2 , #4 } - \bool_set_true:N \l_@@_NiceTabular_bool + \bool_set_true:N \l_@@_tabular_bool \NiceArray { #3 } } { \endNiceArray } @@ -7189,6 +7210,33 @@ version 2005/12/01 or later. % \bigskip % \section{After the construction of the array} % +% \bigskip +% \begin{macrocode} +\cs_new_protected:Npn \@@_deal_with_rounded_corners: + { + \bool_lazy_all:nT + { + { \int_compare_p:nNn \l_@@_tab_rounded_corners_dim > \c_zero_dim } + \l_@@_hvlines_bool + { ! \g_@@_delims_bool } + { ! \l_@@_except_borders_bool } + } + { + \bool_set_true:N \l_@@_except_borders_bool + \tl_gput_right:Nn \g_@@_pre_code_after_tl + { + \_@@_stroke_block:nnn + { + rounded-corners = \dim_use:N \l_@@_tab_rounded_corners_dim , + draw = \l_@@_rules_color_tl + } + { 1-1 } + { \int_use:N \c@iRow - \int_use:N \c@jCol } + } + } + } +% +% % \medskip % \begin{macrocode} \cs_new_protected:Npn \@@_after_array: @@ -7383,6 +7431,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \begin{macrocode} + \@@_deal_with_rounded_corners: \tl_if_empty:NF \l_@@_hlines_clist \@@_draw_hlines: \tl_if_empty:NF \l_@@_vlines_clist \@@_draw_vlines: % \end{macrocode} @@ -7450,7 +7499,7 @@ version 2005/12/01 or later. % % \medskip % |\g_@@_pre_code_before_tl| is for instructions in the cells of the array such as -% |\rowcolor| and |\cellcolor| (when the key |colortbl-like| is in +% |\rowcolor| and |\cellcolor| (when the key |color-inside| is in % force). These instructions will be written on the |aux| file to be added to % the |code-before| in the next run. % \begin{macrocode} @@ -9258,10 +9307,24 @@ version 2005/12/01 or later. % The command |\@@_rotate:| will be linked to |\rotate| in % |{NiceArrayWithDelims}|. % \begin{macrocode} -\cs_new_protected:Npn \@@_rotate: { \bool_gset_true:N \g_@@_rotate_bool } +\NewDocumentCommand \@@_rotate: { O { } } + { + \bool_gset_true:N \g_@@_rotate_bool + \keys_set:nn { NiceMatrix / rotate } { #1 } + } % \end{macrocode} % % \bigskip +% \begin{macrocode} +\keys_define:nn { NiceMatrix / rotate } + { + c .code:n = \bool_gset_true:N \g_@@_rotate_c_bool , + c .value_forbidden:n = true , + unknown .code:n = \@@_error:n { Unknown~key~for~rotate } + } +% \end{macrocode} +% +% \bigskip % \section{The command \textbackslash line accessible in code-after} % % In the |\CodeAfter|, the command |\@@_line:nn| will be linked to |\line|. This @@ -9858,6 +9921,9 @@ version 2005/12/01 or later. % However, the command |\rowcolors| of \pkg{nicematrix} has \emph{not} the % optional argument of the command |\rowcolors| of \pkg{xcolor}. Here is an % example: |\rowcolors{1}{blue!10}{}[respect-blocks]|. +% +% In \pkg{nicematrix}, the commmand |\@@_rowcolors| apperas as a special case of +% |\@@_rowlistcolors|. % % |#1| (optional) is the color space ; % |#2| is a list of intervals of rows ; @@ -9909,9 +9975,8 @@ version 2005/12/01 or later. % index of the loop over the rows. % \begin{macrocode} \int_set:Nn \l_tmpa_int \l_tmpa_tl - \bool_if:NTF \l_@@_rowcolors_restart_bool - { \int_set:Nn \l_@@_color_int 1 } - { \int_set:Nn \l_@@_color_int \l_tmpa_tl } + \int_set:Nn \l_@@_color_int + { \bool_if:NTF \l_@@_rowcolors_restart_bool 1 \l_tmpa_tl } \int_zero_new:N \l_@@_tmpc_int \int_set:Nn \l_@@_tmpc_int \l_tmpb_tl \int_do_until:nNnn \l_tmpa_int > \l_@@_tmpc_int @@ -9979,10 +10044,11 @@ version 2005/12/01 or later. % % \bigskip % The command |\rowcolors| (available in the |\CodeBefore|) is a specialisation -% of the most general command |\rowlistcolors|. +% of the most general command |\rowlistcolors|. The last argument, which is a +% optional argument between square brackets is provided by curryfication. % \begin{macrocode} -\NewDocumentCommand \@@_rowcolors { O { } m m m O { } } - { \@@_rowlistcolors [ #1 ] { #2 } { { #3 } , { #4 } } [ #5 ] } +\NewDocumentCommand \@@_rowcolors { O { } m m m } + { \@@_rowlistcolors [ #1 ] { #2 } { { #3 } , { #4 } } } % \end{macrocode} % % \bigskip @@ -10155,7 +10221,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% When the user uses the key |colortbl-like|, the following command will +% When the user uses the key |color-inside|, the following command will % be linked to |\cellcolor| in the tabular. % \begin{macrocode} \NewDocumentCommand \@@_cellcolor_tabular { O { } m } @@ -10175,7 +10241,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% When the user uses the key |colortbl-like|, the following command will +% When the user uses the key |color-inside|, the following command will % be linked to |\rowcolor| in the tabular. % \begin{macrocode} \NewDocumentCommand \@@_rowcolor_tabular { O { } m } @@ -10190,6 +10256,31 @@ version 2005/12/01 or later. } % \end{macrocode} % +% \bigskip +% When the user uses the key |color-inside|, the following command will +% be linked to |\rowcolors| in the tabular. The last argument (an optional +% argument between square brackets is taken by curryfication). +% \begin{macrocode} +\NewDocumentCommand { \@@_rowcolors_tabular } { O { } m m } + { \@@_rowlistcolors_tabular [ #1 ] { #2 , #3 } } +% \end{macrocode} +% +% \bigskip +% When the user uses the key |color-inside|, the following command will +% be linked to |\rowlistcolors| in the tabular. +% \begin{macrocode} +\NewDocumentCommand { \@@_rowlistcolors_tabular } { O { } m O { } } + { + \peek_remove_spaces:n + { + \tl_gput_right:Nx \g__nicematrix_pre_code_before_tl + { + \@@_rowlistcolors + [ #1 ] { \int_use:N \c@iRow } { #2 } [ restart, #3 ] + } + } + } +% \end{macrocode} % % \bigskip % \begin{macrocode} @@ -10272,7 +10363,13 @@ version 2005/12/01 or later. \cs_new_protected:Npn \@@_OnlyMainNiceMatrix_i:n #1 { \int_compare:nNnF \c@iRow = 0 - { \int_compare:nNnF \c@iRow = \l_@@_last_row_int { #1 } } + { + \int_compare:nNnF \c@iRow = \l_@@_last_row_int + { + \int_compare:nNnT \c@jCol > \c_zero_int + { \bool_if:NF \l_@@_in_last_col_bool { #1 } } + } + } } % \end{macrocode} % Remember that |\c@iRow| is not always inferior to |\l_@@_last_row_int| because @@ -10582,11 +10679,11 @@ version 2005/12/01 or later. { \int_step_inline:nnn { - \bool_if:nTF { \g_@@_NiceArray_bool && ! \l_@@_except_borders_bool } + \bool_if:nTF { ! \g_@@_delims_bool && ! \l_@@_except_borders_bool } 1 2 } { - \bool_if:nTF { \g_@@_NiceArray_bool && ! \l_@@_except_borders_bool } + \bool_if:nTF { ! \g_@@_delims_bool && ! \l_@@_except_borders_bool } { \int_eval:n { \c@jCol + 1 } } \c@jCol } @@ -10839,7 +10936,7 @@ version 2005/12/01 or later. \int_compare:nNnT \l_@@_local_start_int = 1 { \dim_sub:Nn \l_@@_x_initial_dim \l_@@_left_margin_dim - \bool_if:NT \g_@@_NiceArray_bool + \bool_if:NF \g_@@_delims_bool { \dim_sub:Nn \l_@@_x_initial_dim \arraycolsep } % \end{macrocode} % For reasons purely aesthetic, we do an adjustment in the case of a rounded @@ -10854,7 +10951,7 @@ version 2005/12/01 or later. \int_compare:nNnT \l_@@_local_end_int = \c@jCol { \dim_add:Nn \l_@@_x_final_dim \l_@@_right_margin_dim - \bool_if:NT \g_@@_NiceArray_bool + \bool_if:NF \g_@@_delims_bool { \dim_add:Nn \l_@@_x_final_dim \arraycolsep } \tl_if_eq:NnF \g_@@_right_delim_tl ) { \dim_gsub:Nn \l_@@_x_final_dim { 0.5 \l_@@_xdots_inter_dim } } @@ -10898,11 +10995,11 @@ version 2005/12/01 or later. { \int_step_inline:nnn { - \bool_if:nTF { \g_@@_NiceArray_bool && ! \l_@@_except_borders_bool } + \bool_if:nTF { ! \g_@@_delims_bool && ! \l_@@_except_borders_bool } 1 2 } { - \bool_if:nTF { \g_@@_NiceArray_bool && ! \l_@@_except_borders_bool } + \bool_if:nTF { ! \g_@@_delims_bool && ! \l_@@_except_borders_bool } { \int_eval:n { \c@iRow + 1 } } \c@iRow } @@ -12007,8 +12104,23 @@ version 2005/12/01 or later. % |\NewExpandableDocumentCommand| because it has an optional argument between % |<| and |>|. It's mandatory to use an expandable command. % +% % \begin{macrocode} -\NewExpandableDocumentCommand \@@_Block: { O { } m D < > { } +m } +\cs_new_protected:Npn \@@_block:n #1 + { + \peek_meaning:NTF [ + { \@@_block_i:n { #1 } } + { \@@_Block_i:[#1] } + } + +\cs_new_protected:Npn \@@_block_i:n #1[#2] { \@@_block:n {#1,#2} } + +\cs_new_protected:Npn \@@_Block: { \@@_block:n { } } +% \end{macrocode} +% +% \bigskip +% \begin{macrocode} +\NewExpandableDocumentCommand \@@_Block_i: { O { } m D < > { } +m } { % \end{macrocode} % If the first mandatory argument of the command (which is the size of the block @@ -12210,8 +12322,8 @@ 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 { \str_set:Nn \l_@@_hpos_block_str c } - \bool_if:NTF \l_@@_NiceTabular_bool + \bool_if:NT \g_@@_rotate_bool { \str_set:Nn \l_@@_hpos_block_str c } + \bool_if:NTF \l_@@_tabular_bool { \bool_lazy_all:nTF { @@ -12268,6 +12380,20 @@ version 2005/12/01 or later. \box_grotate:cn { g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box } { 90 } + \bool_if:NT \g_@@_rotate_c_bool + { + \hbox_gset:cn + { g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box } + { + \c_math_toggle_token + \vcenter + { + \box_use:c + { g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box } + } + \c_math_toggle_token + } + } \bool_gset_false:N \g_@@_rotate_bool } % \end{macrocode} @@ -12321,12 +12447,17 @@ version 2005/12/01 or later. % alignment and that's why we put a key corresponding to the value of % |\l_@@_hpos_block_str|, which is fixed by the type of current column. % \begin{macrocode} - { \exp_not:n { #3 } , \l_@@_hpos_block_str } + { + \exp_not:n { #3 } , + \l_@@_hpos_block_str , + \bool_if:NT \g_@@_rotate_c_bool { v-center } + } { \box_use_drop:c { g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box } } } + \bool_set_false:N \g_@@_rotate_c_bool } % \end{macrocode} % @@ -12343,7 +12474,7 @@ version 2005/12/01 or later. \l_tmpa_tl { \exp_not:n { #3 } } { - \bool_if:NTF \l_@@_NiceTabular_bool + \bool_if:NTF \l_@@_tabular_bool { \group_begin: \bool_if:NF \l_@@_respect_arraystretch_bool @@ -12539,6 +12670,7 @@ version 2005/12/01 or later. % % % \medskip +% The following command |\@@_Block_v:nnnnnn| will actually draw the block. % |#1| is the first row of the block; % |#2| is the first column of the block; % |#3| is the last row of the block; @@ -13061,7 +13193,8 @@ version 2005/12/01 or later. \keys_define:nn { NiceMatrix / BlockStroke } { color .tl_set:N = \l_@@_draw_tl , - draw .tl_set:N = \l_@@_draw_tl , + draw .code:n = + \exp_args:Nx \tl_if_empty:nF { #1 } { \tl_set:Nn \l_@@_draw_tl { #1 } } , draw .default:n = default , line-width .dim_set:N = \l_@@_line_width_dim , rounded-corners .dim_set:N = \l_@@_rounded_corners_dim , @@ -13328,6 +13461,8 @@ version 2005/12/01 or later. delimiters / max-width .default:n = true , delimiters .code:n = \keys_set:nn { NiceMatrix / delimiters } { #1 } , delimiters .value_required:n = true , + rounded-corners .dim_set:N = \l_@@_tab_rounded_corners_dim , + rounded-corners .default:n = 4 pt } % \end{macrocode} % @@ -13345,20 +13480,13 @@ version 2005/12/01 or later. % The group is for the protection of the keys. % \begin{macrocode} \group_begin: - \bool_set_true:N \l_@@_Matrix_bool - \str_if_eq:nnT { #1 } { . } - { - \str_if_eq:nnT { #2 } { . } - { \bool_set_false:N \l_@@_Matrix_bool } - } \keys_set_known:nnN { NiceMatrix / Auto } { #6 } \l_tmpa_tl % \end{macrocode} -% We nullify the command |\@@_transform_preamble:| because we will provide a +% We nullify the command |\@@_transform_preamble_i:| because we will provide a % preamble which is yet transformed (by using |\l_@@_columns_type_tl| which is % yet nicematrix-ready). -% % \begin{macrocode} - \cs_set_eq:NN \@@_transform_preamble: \prg_do_nothing: + \bool_set_false:N \l_@@_preamble_bool \use:x { \exp_not:N \begin { NiceArrayWithDelims } { #1 } { #2 } @@ -13394,13 +13522,12 @@ version 2005/12/01 or later. } % \end{macrocode} % -% % \begin{macrocode} \cs_set_protected:Npn \@@_define_com:nnn #1 #2 #3 { \cs_set_protected:cpn { #1 AutoNiceMatrix } { - \bool_gset_false:N \g_@@_NiceArray_bool + \bool_gset_true:N \g_@@_delims_bool \str_gset:Nx \g_@@_name_env_str { #1 AutoNiceMatrix } \AutoNiceMatrixWithDelims { #2 } { #3 } } @@ -13421,8 +13548,7 @@ version 2005/12/01 or later. \NewDocumentCommand \AutoNiceMatrix { O { } m O { } m ! O { } } { \group_begin: - \bool_gset_true:N \g_@@_NiceArray_bool - % \bool_set_true:N \l_@@_Matrix_bool + \bool_gset_false:N \g_@@_delims_bool \AutoNiceMatrixWithDelims . . { #2 } { #4 } [ #1 , #3 , #5 ] \group_end: } @@ -14817,7 +14943,7 @@ version 2005/12/01 or later. % The class \cls{beamer} has its own system to extract footnotes and that's why % we have nothing to do if \cls{beamer} is used. % \begin{macrocode} - \IfClassLoadeTF { beamer } + \IfClassLoadedTF { beamer } { \bool_set_false:N \c_@@_footnote_bool } { \IfPackageLoadedTF { footnotehyper } @@ -15146,7 +15272,16 @@ version 2005/12/01 or later. { Unknown~key.\\ There~is~only~two~keys~available~here:~width~and~color.\\ - You~key~'\l_keys_key_str'~will~be~ignored. + Your~key~'\l_keys_key_str'~will~be~ignored. + } +% \end{macrocode} +% +% \begin{macrocode} +\@@_msg_new:nn { Unknown~key~for~rotate } + { + Unknown~key.\\ + The~only~key~available~here~is~'c'.\\ + Your~key~'\l_keys_key_str'~will~be~ignored. } % \end{macrocode} % @@ -15887,6 +16022,7 @@ version 2005/12/01 or later. renew-dots,~ renew-matrix,~ respect-arraystretch,~ + rounded-corners,~ right-margin,~ rules~(with~the~subkeys~'color'~and~'width'),~ small,~ @@ -15920,7 +16056,7 @@ version 2005/12/01 or later. code-for-first-row,~ code-for-last-col,~ code-for-last-row,~ - colortbl-like,~ + color-inside,~ columns-width,~ corners,~ create-extra-nodes,~ @@ -15943,6 +16079,7 @@ version 2005/12/01 or later. renew-dots,~ respect-arraystretch,~ right-margin,~ + rounded-corners,~ rules~(with~the~subkeys~'color'~and~'width'),~ small,~ t,~ @@ -15981,7 +16118,7 @@ version 2005/12/01 or later. code-for-first-row,~ code-for-last-col,~ code-for-last-row,~ - colortbl-like,~ + color-inside,~ columns-type,~ columns-width,~ corners,~ @@ -16007,6 +16144,7 @@ version 2005/12/01 or later. renew-dots,~ respect-arraystretch,~ right-margin,~ + rounded-corners,~ rules~(with~the~subkeys~'color'~and~'width'),~ small,~ t,~ @@ -16042,7 +16180,7 @@ version 2005/12/01 or later. code-for-first-row,~ code-for-last-col,~ code-for-last-row,~ - colortbl-like,~ + color-inside,~ columns-width,~ corners,~ custom-line,~ diff --git a/Master/texmf-dist/source/latex/nicematrix/nicematrix.ins b/Master/texmf-dist/source/latex/nicematrix/nicematrix.ins index 2fff6fcb8ca..838315cbb2a 100644 --- a/Master/texmf-dist/source/latex/nicematrix/nicematrix.ins +++ b/Master/texmf-dist/source/latex/nicematrix/nicematrix.ins @@ -1,5 +1,5 @@ %% -%% Copyright (C) 2018-2022 by F. Pantigny +%% Copyright (C) 2018-2023 by F. Pantigny %% %% %% This file may be distributed and/or modified under the |