diff options
author | Karl Berry <karl@freefriends.org> | 2020-05-27 21:45:50 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-05-27 21:45:50 +0000 |
commit | ae777e8c9cd9b932a2ebcad4bc6af2c185ac09e5 (patch) | |
tree | 1375a62a0417ff2fd35f32a31f6ea4f690593bdf /Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty | |
parent | 5ee27d9c2742c9956bae4c3e3fa9f7b9c0a58d45 (diff) |
nicematrix (27may20)
git-svn-id: svn://tug.org/texlive/trunk@55302 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty | 721 |
1 files changed, 425 insertions, 296 deletions
diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty index 06c3fa98690..dde56d6fc32 100644 --- a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty +++ b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty @@ -18,8 +18,8 @@ %% and version 1.3 or later is part of all distributions of %% LaTeX version 2005/12/01 or later. %% -\def\myfileversion{4.0} -\def\myfiledate{2020/05/08} +\def\myfileversion{4.1} +\def\myfiledate{2020/05/27} \RequirePackage{pgfcore} \usepgfmodule{shapes} \RequirePackage{l3keys2e} @@ -110,22 +110,59 @@ { \bool_set_true:N \c__nicematrix_colortbl_loaded_bool } { \cs_set_protected:Npn \CT@arc@ { } - \NewDocumentCommand { \arrayrulecolor } { m } - { \tl_gset:Nn \CT@arc@ { \color { #1 } } } + \cs_set:Npn \arrayrulecolor #1 # { \CT@arc { #1 } } + \cs_set:Npn \CT@arc #1 #2 + { + \dim_compare:nNnT \baselineskip = \c_zero_dim \noalign + { \cs_gset:Npn \CT@arc@ { \color #1 { #2 } } } + } \cs_set:Npn \hline { \noalign { \ifnum 0 = `} \fi - \let \hskip \vskip - \let \vrule \hrule - \let \@width \@height + \cs_set_eq:NN \hskip \vskip + \cs_set_eq:NN \vrule \hrule + \cs_set_eq:NN \@width \@height { \CT@arc@ \vline } \futurelet \reserved@a \@xhline } } } +\cs_set:Npn \__nicematrix_standard_cline #1 { \__nicematrix_standard_cline:w #1 \q_stop } +\cs_set:Npn \__nicematrix_standard_cline:w #1-#2 \q_stop + { + \int_compare:nNnT \l__nicematrix_first_col_int = 0 { \omit & } + \int_compare:nNnT { #1 } > 1 { \multispan { \__nicematrix_pred:n { #1 } } & } + \multispan { \int_eval:n { #2 - #1 + 1 } } + { \CT@arc@ \leaders \hrule \@height \arrayrulewidth \hfill } + \everycr { } + \cr + \noalign { \skip_vertical:N -\arrayrulewidth } + } +\cs_set:Npn \__nicematrix_cline + { \exp_args:Ne \__nicematrix_cline_i:nn \l__nicematrix_first_col_int } +\cs_set:Npn \__nicematrix_cline_i:nn #1 #2 { \__nicematrix_cline_i:w #1-#2 \q_stop } +\cs_set:Npn \__nicematrix_cline_i:w #1-#2-#3 \q_stop + { + \int_compare:nNnT { #1 } < { #2 } + { \multispan { \int_eval:n { #2 - #1 } } & } + \multispan { \int_eval:n { #3 - #2 + 1 } } + { \CT@arc@ \leaders \hrule \@height \arrayrulewidth \hfill } + \peek_meaning_remove_ignore_spaces:NTF \cline + { & \exp_args:Ne \__nicematrix_cline_i:nn { \__nicematrix_succ:n { #3 } } } + { \everycr { } \cr } + } + \cs_new:Npn \__nicematrix_succ:n #1 { \the \numexpr #1 + 1 \relax } \cs_new:Npn \__nicematrix_pred:n #1 { \the \numexpr #1 - 1 \relax } +\cs_new:Npn \__nicematrix_math_toggle_token: + { \bool_if:NF \l__nicematrix_NiceTabular_bool \c_math_toggle_token } +\cs_new_protected:Npn \__nicematrix_set_CT@arc@: + { \peek_meaning:NTF [ \__nicematrix_set_CT@arc@_i: \__nicematrix_set_CT@arc@_ii: } +\cs_new_protected:Npn \__nicematrix_set_CT@arc@_i: [ #1 ] #2 \q_stop + { \cs_set:Npn \CT@arc@ { \color [ #1 ] { #2 } } } +\cs_new_protected:Npn \__nicematrix_set_CT@arc@_ii: #1 \q_stop + { \cs_set:Npn \CT@arc@ { \color { #1 } } } \bool_new:N \c__nicematrix_siunitx_loaded_bool \AtBeginDocument { @@ -167,6 +204,8 @@ } \int_new:N \g__nicematrix_env_int \cs_new:Npn \__nicematrix_env: { nm - \int_use:N \g__nicematrix_env_int } +\NewExpandableDocumentCommand \NiceMatrixLastEnv { } + { \int_use:N \g__nicematrix_env_int } \cs_new_protected:Npn \__nicematrix_qpoint:n #1 { \pgfpointanchor { \__nicematrix_env: - #1 } { center } } \int_new:N \g__nicematrix_NiceMatrixBlock_int @@ -196,6 +235,7 @@ \tl_new:N \g__nicematrix_internal_code_after_tl \int_new:N \l__nicematrix_old_iRow_int \int_new:N \l__nicematrix_old_jCol_int +\tl_new:N \l__nicematrix_rules_color_tl \bool_new:N \g__nicematrix_row_of_col_done_bool \bool_new:N \l__nicematrix_code_before_bool \dim_new:N \l__nicematrix_x_initial_dim @@ -208,6 +248,9 @@ \dim_new:N \__nicematrix_old_arraycolsep_dim \dim_new:N \g__nicematrix_width_last_col_dim \dim_new:N \g__nicematrix_width_first_col_dim +\seq_new:N \g__nicematrix_blocks_seq +\seq_new:N \g__nicematrix_pos_of_blocks_seq +\seq_new:N \g__nicematrix_pos_of_xdots_seq \int_new:N \l__nicematrix_first_row_int \int_set:Nn \l__nicematrix_first_row_int 1 \int_new:N \l__nicematrix_first_col_int @@ -268,6 +311,7 @@ { } \end { pgfscope } } +\bool_new:N \l__nicematrix_standard_cline_bool \dim_new:N \l__nicematrix_cell_space_top_limit_dim \dim_new:N \l__nicematrix_cell_space_bottom_limit_dim \dim_new:N \l__nicematrix_inter_dots_dim @@ -287,6 +331,7 @@ \bool_set_true:N \l__nicematrix_parallelize_diags_bool \bool_new:N \l__nicematrix_hlines_bool \bool_new:N \l__nicematrix_vlines_bool +\bool_new:N \l__nicematrix_hvlines_bool \bool_new:N \l__nicematrix_nullify_dots_bool \bool_new:N \l__nicematrix_auto_columns_width_bool \str_new:N \l__nicematrix_name_str @@ -319,8 +364,17 @@ up .tl_set:N = \l__nicematrix_xdots_up_tl , unknown .code:n = \__nicematrix_error:n { Unknown~option~for~xdots } } +\keys_define:nn { NiceMatrix / rules } + { + color .tl_set:N = \l__nicematrix_rules_color_tl , + color .value_required:n = true , + width .dim_set:N = \arrayrulewidth , + width .value_required:n = true + } \keys_define:nn { NiceMatrix / Global } { + standard-cline .bool_set:N = \l__nicematrix_standard_cline_bool , + standard-cline .default:n = true , cell-space-top-limit .dim_set:N = \l__nicematrix_cell_space_top_limit_dim , cell-space-top-limit .value_required:n = true , cell-space-bottom-limit .dim_set:N = \l__nicematrix_cell_space_bottom_limit_dim , @@ -345,7 +399,12 @@ code-for-last-row .value_required:n = true , hlines .bool_set:N = \l__nicematrix_hlines_bool , vlines .bool_set:N = \l__nicematrix_vlines_bool , - hvlines .meta:n = { hlines , vlines } , + hvlines .code:n = + { + \bool_set_true:N \l__nicematrix_hvlines_bool + \bool_set_true:N \l__nicematrix_vlines_bool + \bool_set_true:N \l__nicematrix_hlines_bool + } , parallelize-diags .bool_set:N = \l__nicematrix_parallelize_diags_bool , renew-dots .bool_set:N = \l__nicematrix_renew_dots_bool , renew-dots .value_forbidden:n = true , @@ -412,24 +471,28 @@ NiceMatrix / Env , } , NiceMatrix / xdots .inherit:n = NiceMatrix / xdots , + NiceMatrix / rules .inherit:n = NiceMatrix / rules , NiceTabular .inherit:n = { NiceMatrix / Global , NiceMatrix / Env } , NiceTabular / xdots .inherit:n = NiceMatrix / xdots , + NiceTabular / rules .inherit:n = NiceMatrix / rules , NiceArray .inherit:n = { NiceMatrix / Global , NiceMatrix / Env , } , NiceArray / xdots .inherit:n = NiceMatrix / xdots , + NiceArray / rules .inherit:n = NiceMatrix / rules , pNiceArray .inherit:n = { NiceMatrix / Global , NiceMatrix / Env , } , - pNiceArray / xdots .inherit:n = NiceMatrix / xdots + pNiceArray / xdots .inherit:n = NiceMatrix / xdots , + pNiceArray / rules .inherit:n = NiceMatrix / rules , } \keys_define:nn { NiceMatrix / NiceMatrixOptions } { @@ -504,6 +567,9 @@ } \keys_define:nn { NiceMatrix / NiceTabular } { + last-col .code:n = \tl_if_empty:nF {#1} + { \__nicematrix_error:n { last-col~non~empty~for~NiceArray } } + \int_zero:N \l__nicematrix_last_col_int , unknown .code:n = \__nicematrix_error:n { Unknown~option~for~NiceTabular } } \cs_new_protected:Npn \__nicematrix_Cell: @@ -572,7 +638,7 @@ } \cs_new_protected:Npn \__nicematrix_end_Cell: { - \bool_if:NF \l__nicematrix_NiceTabular_bool \c_math_toggle_token + \__nicematrix_math_toggle_token: \hbox_set_end: \box_set_ht:Nn \l__nicematrix_cell_box { \box_ht:N \l__nicematrix_cell_box + \l__nicematrix_cell_space_top_limit_dim } @@ -677,7 +743,7 @@ \int_compare:nNnT \c@iRow > { -1 } { \int_compare:nNnF \c@iRow = \l__nicematrix_last_row_int - { { \CT@arc@ \hrule height \arrayrulewidth } } + { \hrule height \arrayrulewidth width \c_zero_dim } } } } @@ -756,6 +822,9 @@ \cs_set_eq:NN \__nicematrix_old_iddots \iddots \cs_set_eq:NN \firsthline \hline \cs_set_eq:NN \lasthline \hline + \bool_if:NTF \l__nicematrix_standard_cline_bool + { \cs_set_eq:NN \cline \__nicematrix_standard_cline } + { \cs_set_eq:NN \cline \__nicematrix_cline } \cs_set_eq:NN \Ldots \__nicematrix_Ldots \cs_set_eq:NN \Cdots \__nicematrix_Cdots \cs_set_eq:NN \Vdots \__nicematrix_Vdots @@ -771,7 +840,7 @@ \cs_set_eq:NN \OnlyMainNiceMatrix \__nicematrix_OnlyMainNiceMatrix:n \cs_set_eq:NN \dotfill \__nicematrix_dotfill: \cs_set_eq:NN \CodeAfter \__nicematrix_CodeAfter:n - \cs_set_eq:NN \slashbox \__nicematrix_slashbox:nn + \cs_set_eq:NN \diagbox \__nicematrix_diagbox:nn \bool_if:NT \l__nicematrix_renew_dots_bool { \cs_set_eq:NN \ldots \__nicematrix_Ldots @@ -866,6 +935,7 @@ \__nicematrix_test_if_math_mode: \bool_if:NT \l__nicematrix_in_env_bool { \__nicematrix_fatal:n { Yet~in~env } } \bool_set_true:N \l__nicematrix_in_env_bool + \cs_gset_eq:NN \__nicematrix_old_CT@arc@ \CT@arc@ \cs_if_exist:NT \tikz@library@external@loaded { \tikzset { external / export = false } @@ -876,10 +946,14 @@ \bool_if:NF \l__nicematrix_block_auto_columns_width_bool { \dim_gzero_new:N \g__nicematrix_max_cell_width_dim } \cs_set_protected:Npn \@arrayrule { \@addtopreamble \__nicematrix_vline: } + \seq_clear:N \g__nicematrix_blocks_seq + \seq_clear:N \g__nicematrix_pos_of_blocks_seq \bool_if:NTF \l__nicematrix_NiceArray_bool { \keys_set:nn { NiceMatrix / NiceArray } } { \keys_set:nn { NiceMatrix / pNiceArray } } { #3 , #5 } + \tl_if_empty:NF \l__nicematrix_rules_color_tl + { \exp_after:wN \__nicematrix_set_CT@arc@: \l__nicematrix_rules_color_tl \q_stop } \bool_if:NT \l__nicematrix_code_before_bool { \seq_if_exist:cT { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } @@ -917,18 +991,18 @@ \group_begin: \bool_if:NT \c__nicematrix_tikz_loaded_bool { - \pgfset + \tikzset { every~picture / .style = - { overlay , name~prefix = \__nicematrix_env: - } + { overlay , name~prefix = \__nicematrix_env: - } } } - \cs_set_eq:NN \cellcolor \__nicematrix_cellcolor:nn - \cs_set_eq:NN \rectanglecolor \__nicematrix_rectanglecolor:nnn - \cs_set_eq:NN \rowcolor \__nicematrix_rowcolor:nn - \cs_set_eq:NN \rowcolors \__nicematrix_rowcolors:nnn - \cs_set_eq:NN \columncolor \__nicematrix_columncolor:nn - \cs_set_eq:NN \chessboardcolors \__nicematrix_chessboardcolors:nn + \cs_set_eq:NN \cellcolor \__nicematrix_cellcolor + \cs_set_eq:NN \rectanglecolor \__nicematrix_rectanglecolor + \cs_set_eq:NN \rowcolor \__nicematrix_rowcolor + \cs_set_eq:NN \rowcolors \__nicematrix_rowcolors + \cs_set_eq:NN \columncolor \__nicematrix_columncolor + \cs_set_eq:NN \chessboardcolors \__nicematrix_chessboardcolors \bool_if:NT \l__nicematrix_NiceTabular_bool \c_math_toggle_token \l__nicematrix_code_before_tl \bool_if:NT \l__nicematrix_NiceTabular_bool \c_math_toggle_token @@ -1217,7 +1291,7 @@ { \box_ht:N \l_tmpa_box + \box_dp:N \l_tmpa_box } { } } - \right . + \right . \c_math_toggle_token } \dim_set:Nn \l__nicematrix_real_left_delim_dim @@ -1440,7 +1514,7 @@ { \__nicematrix_begin_of_row: \hbox_set:Nw \l__nicematrix_cell_box - \bool_if:NF \l__nicematrix_NiceTabular_bool \c_math_toggle_token + \__nicematrix_math_toggle_token: \bool_if:NT \l__nicematrix_small_bool \scriptstyle \bool_lazy_and:nnT { \int_compare_p:nNn \c@iRow > 0 } @@ -1457,7 +1531,7 @@ l < { - \bool_if:NF \l__nicematrix_NiceTabular_bool \c_math_toggle_token + \__nicematrix_math_toggle_token: \hbox_set_end: \__nicematrix_update_for_first_and_last_row: \dim_gset:Nn \g__nicematrix_width_first_col_dim @@ -1482,7 +1556,7 @@ \int_gincr:N \c@jCol \int_gset_eq:NN \g__nicematrix_col_total_int \c@jCol \hbox_set:Nw \l__nicematrix_cell_box - \bool_if:NF \l__nicematrix_NiceTabular_bool \c_math_toggle_token + \__nicematrix_math_toggle_token: \bool_if:NT \l__nicematrix_small_bool \scriptstyle \int_compare:nNnT \c@iRow > 0 { @@ -1498,7 +1572,7 @@ l < { - \bool_if:NF \l__nicematrix_NiceTabular_bool \c_math_toggle_token + \__nicematrix_math_toggle_token: \hbox_set_end: \__nicematrix_update_for_first_and_last_row: \dim_gset:Nn \g__nicematrix_width_last_col_dim @@ -1596,6 +1670,7 @@ \__nicematrix_define_env:n V \NewDocumentEnvironment { NiceTabular } { O { } m ! O { } } { + \str_gset:Nn \g__nicematrix_name_env_str { NiceTabular } \keys_set:nn { NiceMatrix / NiceTabular } { #1 , #3 } \bool_set_true:N \l__nicematrix_NiceTabular_bool \NiceArray { #2 } @@ -1698,7 +1773,14 @@ \dim_set:Nn \l__nicematrix_xdots_shorten_dim { 0.6 \l__nicematrix_xdots_shorten_dim } } \__nicematrix_draw_dotted_lines: - \bool_if:NT \l__nicematrix_vlines_bool \__nicematrix_draw_vlines: + \bool_if:NTF \l__nicematrix_hvlines_bool + \__nicematrix_draw_hvlines: + { + \bool_if:NT \l__nicematrix_hlines_bool \__nicematrix_draw_hlines: + \bool_if:NT \l__nicematrix_vlines_bool \__nicematrix_draw_vlines: + } + \cs_set_eq:NN \ialign \__nicematrix_old_ialign: + \seq_if_empty:NF \g__nicematrix_blocks_seq \__nicematrix_draw_blocks: \g__nicematrix_internal_code_after_tl \tl_gclear:N \g__nicematrix_internal_code_after_tl \bool_if:NT \c__nicematrix_tikz_loaded_bool @@ -1720,6 +1802,7 @@ \group_end: \str_gclear:N \g__nicematrix_name_env_str \__nicematrix_restore_iRow_jCol: + \cs_gset_eq:NN \CT@arc@ \__nicematrix_old_CT@arc@ } \AtBeginDocument { @@ -1889,6 +1972,16 @@ } } } + \bool_if:NT \l__nicematrix_hvlines_bool + { + \seq_gput_right:Nx \g__nicematrix_pos_of_xdots_seq + { + { \int_use:N \l__nicematrix_initial_i_int } + { \int_use:N \l__nicematrix_initial_j_int } + { \int_use:N \l__nicematrix_final_i_int } + { \int_use:N \l__nicematrix_final_j_int } + } + } } \cs_new_protected:Npn \__nicematrix_set_initial_coords: { @@ -2201,8 +2294,6 @@ } \__nicematrix_draw_line: } -\NewExpandableDocumentCommand \NiceMatrixLastEnv { } - { \int_use:N \g__nicematrix_env_int } \cs_new_protected:Npn \__nicematrix_draw_line: { \pgfrememberpicturepositiononpagetrue @@ -2388,22 +2479,18 @@ } \AtBeginDocument { - \tl_set:Nn \l__nicematrix_argspec_tl { s O { } E { _ ^ } { { } { } } } + \tl_set:Nn \l__nicematrix_argspec_tl { O { } E { _ ^ } { { } { } } } \tl_set_rescan:Nno \l__nicematrix_argspec_tl { } \l__nicematrix_argspec_tl \exp_args:NNV \NewDocumentCommand \__nicematrix_Ldots \l__nicematrix_argspec_tl { - \bool_if:nTF { #1 } - { \__nicematrix_error:n { starred~commands } } + \int_compare:nNnTF \c@jCol = 0 + { \__nicematrix_error:nn { in~first~col } \Ldots } { - \int_compare:nNnTF \c@jCol = 0 - { \__nicematrix_error:nn { in~first~col } \Ldots } + \int_compare:nNnTF \c@jCol = \l__nicematrix_last_col_int + { \__nicematrix_error:nn { in~last~col } \Ldots } { - \int_compare:nNnTF \c@jCol = \l__nicematrix_last_col_int - { \__nicematrix_error:nn { in~last~col } \Ldots } - { - \__nicematrix_instruction_of_type:nn { Ldots } - { #2 , down = #3 , up = #4 } - } + \__nicematrix_instruction_of_type:nn { Ldots } + { #1 , down = #2 , up = #3 } } } \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_old_ldots } @@ -2411,18 +2498,14 @@ } \exp_args:NNV \NewDocumentCommand \__nicematrix_Cdots \l__nicematrix_argspec_tl { - \bool_if:nTF { #1 } - { \__nicematrix_error:n { starred~commands } } + \int_compare:nNnTF \c@jCol = 0 + { \__nicematrix_error:nn { in~first~col } \Cdots } { - \int_compare:nNnTF \c@jCol = 0 - { \__nicematrix_error:nn { in~first~col } \Cdots } + \int_compare:nNnTF \c@jCol = \l__nicematrix_last_col_int + { \__nicematrix_error:nn { in~last~col } \Cdots } { - \int_compare:nNnTF \c@jCol = \l__nicematrix_last_col_int - { \__nicematrix_error:nn { in~last~col } \Cdots } - { - \__nicematrix_instruction_of_type:nn { Cdots } - { #2 , down = #3 , up = #4 } - } + \__nicematrix_instruction_of_type:nn { Cdots } + { #1 , down = #2 , up = #3 } } } \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_old_cdots } @@ -2430,69 +2513,59 @@ } \exp_args:NNV \NewDocumentCommand \__nicematrix_Vdots \l__nicematrix_argspec_tl { - \bool_if:nTF { #1 } - { \__nicematrix_error:n { starred~commands } } - \int_compare:nNnTF \c@iRow = 0 - { \__nicematrix_error:nn { in~first~row } \Vdots } + \int_compare:nNnTF \c@iRow = 0 + { \__nicematrix_error:nn { in~first~row } \Vdots } + { + \int_compare:nNnTF \c@iRow = \l__nicematrix_last_row_int + { \__nicematrix_error:nn { in~last~row } \Vdots } { - \int_compare:nNnTF \c@iRow = \l__nicematrix_last_row_int - { \__nicematrix_error:nn { in~last~row } \Vdots } - { - \__nicematrix_instruction_of_type:nn { Vdots } - { #2 , down = #3 , up = #4 } - } + \__nicematrix_instruction_of_type:nn { Vdots } + { #1 , down = #2 , up = #3 } } + } \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_old_vdots } \bool_gset_true:N \g__nicematrix_empty_cell_bool } \exp_args:NNV \NewDocumentCommand \__nicematrix_Ddots \l__nicematrix_argspec_tl { - \bool_if:nTF { #1 } - { \__nicematrix_error:n { starred~commands } } + \int_case:nnF \c@iRow + { + 0 { \__nicematrix_error:nn { in~first~row } \Ddots } + \l__nicematrix_last_row_int { \__nicematrix_error:nn { in~last~row } \Ddots } + } { - \int_case:nnF \c@iRow + \int_case:nnF \c@jCol { - 0 { \__nicematrix_error:nn { in~first~row } \Ddots } - \l__nicematrix_last_row_int { \__nicematrix_error:nn { in~last~row } \Ddots } + 0 { \__nicematrix_error:nn { in~first~col } \Ddots } + \l__nicematrix_last_col_int { \__nicematrix_error:nn { in~last~col } \Ddots } } { - \int_case:nnF \c@jCol - { - 0 { \__nicematrix_error:nn { in~first~col } \Ddots } - \l__nicematrix_last_col_int { \__nicematrix_error:nn { in~last~col } \Ddots } - } - { - \__nicematrix_instruction_of_type:nn { Ddots } - { #2 , down = #3 , up = #4 } - } - + \__nicematrix_instruction_of_type:nn { Ddots } + { #1 , down = #2 , up = #3 } } + } \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_old_ddots } \bool_gset_true:N \g__nicematrix_empty_cell_bool } \exp_args:NNV \NewDocumentCommand \__nicematrix_Iddots \l__nicematrix_argspec_tl { - \bool_if:nTF { #1 } - { \__nicematrix_error:n { starred~commands } } + \int_case:nnF \c@iRow + { + 0 { \__nicematrix_error:nn { in~first~row } \Iddots } + \l__nicematrix_last_row_int { \__nicematrix_error:nn { in~last~row } \Iddots } + } { - \int_case:nnF \c@iRow + \int_case:nnF \c@jCol { - 0 { \__nicematrix_error:nn { in~first~row } \Iddots } - \l__nicematrix_last_row_int { \__nicematrix_error:nn { in~last~row } \Iddots } + 0 { \__nicematrix_error:nn { in~first~col } \Iddots } + \l__nicematrix_last_col_int { \__nicematrix_error:nn { in~last~col } \Iddots } } { - \int_case:nnF \c@jCol - { - 0 { \__nicematrix_error:nn { in~first~col } \Iddots } - \l__nicematrix_last_col_int { \__nicematrix_error:nn { in~last~col } \Iddots } - } - { - \__nicematrix_instruction_of_type:nn { Iddots } - { #2 , down = #3 , up = #4 } - } - + \__nicematrix_instruction_of_type:nn { Iddots } + { #1 , down = #2 , up = #3 } } + } \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_old_iddots } \bool_gset_true:N \g__nicematrix_empty_cell_bool @@ -2507,13 +2580,23 @@ \cs_new:Npn \__nicematrix_multicolumn:nnn #1 #2 #3 { \__nicematrix_old_multicolumn { #1 } { #2 } { #3 } - \int_compare:nNnT #1 > 1 + \peek_remove_spaces:n { - \seq_gput_left:Nx \g__nicematrix_multicolumn_cells_seq - { \int_use:N \c@iRow - \int_use:N \c@jCol } - \seq_gput_left:Nn \g__nicematrix_multicolumn_sizes_seq { #1 } - } - \int_gadd:Nn \c@jCol { #1 - 1 } + \int_compare:nNnT #1 > 1 + { + \seq_gput_left:Nx \g__nicematrix_multicolumn_cells_seq + { \int_use:N \c@iRow - \int_use:N \c@jCol } + \seq_gput_left:Nn \g__nicematrix_multicolumn_sizes_seq { #1 } + \seq_gput_right:Nx \g__nicematrix_pos_of_blocks_seq + { + { \int_use:N \c@iRow } + { \int_use:N \c@jCol } + { \int_use:N \c@iRow } + { \int_eval:n { \c@jCol + #1 - 1 } } + } + } + \int_gadd:Nn \c@jCol { #1 - 1 } + } } \cs_new:Npn \__nicematrix_Hdotsfor: { @@ -2671,7 +2754,12 @@ \int_step_inline:nnn { #1 } { #1 + #3 - 1 } { \cs_set:cpn { __nicematrix _ dotted _ ##1 - #2 } { } } } -\cs_new_protected:Npn \__nicematrix_rotate: { \group_insert_after:N \__nicematrix_rotate_i: } +\cs_new_protected:Npn \__nicematrix_rotate: + { + \bool_if:NTF \l__nicematrix_NiceTabular_bool + { \group_insert_after:N \__nicematrix_rotate_ii: } + { \group_insert_after:N \__nicematrix_rotate_i: } + } \cs_new_protected:Npn \__nicematrix_rotate_i: { \group_insert_after:N \__nicematrix_rotate_ii: } \cs_new_protected:Npn \__nicematrix_rotate_ii: { \group_insert_after:N \__nicematrix_rotate_iii: } \cs_new_protected:Npn \__nicematrix_rotate_iii: @@ -2747,16 +2835,20 @@ \tl_set:Nn \l_tmpa_tl { #1 } \tl_set:Nn \l_tmpb_tl { #2 } } -\cs_new_protected:Npn \__nicematrix_rowcolor:nn #1 #2 +\NewDocumentCommand \__nicematrix_rowcolor { O { } m m } { - \tl_if_blank:nF { #1 } + \tl_if_blank:nF { #2 } { \pgfpicture \pgf@relevantforpicturesizefalse - \pgfsetfillcolor { #1 } + \tl_if_empty:nTF { #1 } \color { \color [ #1 ] } { #2 } + \__nicematrix_qpoint:n { col - 1} + \int_compare:nNnTF \l__nicematrix_first_col_int = 0 + { \dim_set:Nn \l_tmpc_dim { \pgf@x + 0.5 \arrayrulewidth } } + { \dim_set:Nn \l_tmpc_dim { \pgf@x - 0.5 \arrayrulewidth } } \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \c@jCol } - \dim_set_eq:NN \l_tmpa_dim \pgf@x - \clist_map_inline:nn { #2 } + \dim_set:Nn \l_tmpa_dim { \pgf@x + 0.5 \arrayrulewidth } + \clist_map_inline:nn { #3 } { \tl_set:Nn \l_tmpa_tl { ##1 } \tl_if_in:NnTF \l_tmpa_tl { - } @@ -2768,26 +2860,29 @@ \int_compare:nNnT \l_tmpb_tl > \c@iRow { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@iRow } } \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \l_tmpb_tl } + \dim_set:Nn \l_tmpb_dim { \pgf@y + 0.5 \arrayrulewidth } + \__nicematrix_qpoint:n { row - \l_tmpa_tl } + \dim_set:Nn \l_tmpd_dim { \pgf@y + 0.5 \arrayrulewidth } \pgfpathrectanglecorners - { \__nicematrix_qpoint:n { row - \l_tmpa_tl } } - { \pgfpoint \l_tmpa_dim \pgf@y } + { \pgfpoint \l_tmpc_dim \l_tmpd_dim } + { \pgfpoint \l_tmpa_dim \l_tmpb_dim } } \pgfusepathqfill \endpgfpicture } } -\cs_new_protected:Npn \__nicematrix_columncolor:nn #1 #2 +\NewDocumentCommand \__nicematrix_columncolor { O { } m m } { - \tl_if_blank:nF { #1 } + \tl_if_blank:nF { #2 } { \pgfpicture \pgf@relevantforpicturesizefalse - \pgfsetfillcolor { #1 } + \tl_if_empty:nTF { #1 } \color { \color [ #1 ] } { #2 } \__nicematrix_qpoint:n { row - 1 } - \dim_set_eq:NN \l_tmpa_dim \pgf@y + \dim_set:Nn \l_tmpa_dim {\pgf@y + 0.5 \arrayrulewidth } \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \c@iRow } - \dim_set_eq:NN \l_tmpb_dim \pgf@y - \clist_map_inline:nn { #2 } + \dim_set:Nn \l_tmpb_dim { \pgf@y + 0.5 \arrayrulewidth } + \clist_map_inline:nn { #3 } { \tl_set:Nn \l_tmpa_tl { ##1 } \tl_if_in:NnTF \l_tmpa_tl { - } @@ -2799,24 +2894,27 @@ \int_compare:nNnT \l_tmpb_tl > \c@jCol { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } } \__nicematrix_qpoint:n { col - \l_tmpa_tl } - \dim_set_eq:NN \l_tmpc_dim \pgf@x + \int_compare:nNnTF \l__nicematrix_first_col_int = \l_tmpa_tl + { \dim_set:Nn \l_tmpc_dim { \pgf@x - 0.5 \arrayrulewidth } } + { \dim_set:Nn \l_tmpc_dim { \pgf@x + 0.5 \arrayrulewidth } } \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l_tmpb_tl } + \dim_set:Nn \l_tmpd_dim { \pgf@x + 0.5 \arrayrulewidth } \pgfpathrectanglecorners { \pgfpoint \l_tmpc_dim \l_tmpa_dim } - { \pgfpoint \pgf@x \l_tmpb_dim } + { \pgfpoint \l_tmpd_dim \l_tmpb_dim } } \pgfusepathqfill \endpgfpicture } } -\cs_new_protected:Npn \__nicematrix_cellcolor:nn #1 #2 +\NewDocumentCommand \__nicematrix_cellcolor { O { } m m } { - \tl_if_blank:nF { #1 } + \tl_if_blank:nF { #2 } { \pgfpicture \pgf@relevantforpicturesizefalse - \pgfsetfillcolor { #1 } - \clist_map_inline:nn { #2 } + \tl_if_empty:nTF { #1 } \color { \color [ #1 ] } { #2 } + \clist_map_inline:nn { #3 } { \__nicematrix_cut_on_hyphen:w ##1 \q_stop \__nicematrix_qpoint:n { row - \l_tmpa_tl } @@ -2824,13 +2922,15 @@ { \int_compare_p:n { \l_tmpa_tl <= \c@iRow } } { \int_compare_p:n { \l_tmpb_tl <= \c@jCol } } { - \dim_set_eq:NN \l_tmpb_dim \pgf@y + \dim_set:Nn \l_tmpb_dim { \pgf@y + 0.5 \arrayrulewidth } \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \l_tmpa_tl } - \dim_set_eq:NN \l_tmpa_dim \pgf@y + \dim_set:Nn \l_tmpa_dim { \pgf@y + 0.5 \arrayrulewidth } \__nicematrix_qpoint:n { col - \l_tmpb_tl } - \dim_set_eq:NN \l_tmpc_dim \pgf@x + \int_compare:nNnTF \l__nicematrix_first_col_int = \l_tmpb_tl + { \dim_set:Nn \l_tmpc_dim { \pgf@x - 0.5 \arrayrulewidth } } + { \dim_set:Nn \l_tmpc_dim { \pgf@x + 0.5 \arrayrulewidth } } \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l_tmpb_tl } - \dim_set_eq:NN \l_tmpd_dim \pgf@x + \dim_set:Nn \l_tmpd_dim { \pgf@x + 0.5 \arrayrulewidth } \pgfpathrectanglecorners { \pgfpoint \l_tmpc_dim \l_tmpb_dim } { \pgfpoint \l_tmpd_dim \l_tmpa_dim } @@ -2838,33 +2938,35 @@ } \pgfusepathqfill \endpgfpicture - } + } } -\cs_new_protected:Npn \__nicematrix_rectanglecolor:nnn #1 #2 #3 +\NewDocumentCommand \__nicematrix_rectanglecolor { O { } m m m } { - \tl_if_blank:nF { #1 } + \tl_if_blank:nF { #2 } { \pgfpicture \pgf@relevantforpicturesizefalse - \pgfsetfillcolor { #1 } - \__nicematrix_cut_on_hyphen:w #2 \q_stop + \tl_if_empty:nTF { #1 } \color { \color [ #1 ] } { #2 } + \__nicematrix_cut_on_hyphen:w #3 \q_stop \bool_lazy_and:nnT { \int_compare_p:n { \l_tmpa_tl <= \c@iRow } } { \int_compare_p:n { \l_tmpb_tl <= \c@jCol } } { \__nicematrix_qpoint:n { row - \l_tmpa_tl } - \dim_set_eq:NN \l_tmpb_dim \pgf@y + \dim_set:Nn \l_tmpb_dim { \pgf@y + 0.5 \arrayrulewidth } \__nicematrix_qpoint:n { col - \l_tmpb_tl } - \__nicematrix_cut_on_hyphen:w #3 \q_stop + \int_compare:nNnTF \l__nicematrix_first_col_int = \l_tmpb_tl + { \dim_set:Nn \l_tmpc_dim { \pgf@x - 0.5 \arrayrulewidth } } + { \dim_set:Nn \l_tmpc_dim { \pgf@x + 0.5 \arrayrulewidth } } + \__nicematrix_cut_on_hyphen:w #4 \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 } } - \dim_set_eq:NN \l_tmpc_dim \pgf@x \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \l_tmpa_tl } - \dim_set_eq:NN \l_tmpa_dim \pgf@y + \dim_set:Nn \l_tmpa_dim { \pgf@y + 0.5 \arrayrulewidth } \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l_tmpb_tl } - \dim_set_eq:NN \l_tmpd_dim \pgf@x + \dim_set:Nn \l_tmpd_dim { \pgf@x + 0.5 \arrayrulewidth } \pgfpathrectanglecorners { \pgfpoint \l_tmpc_dim \l_tmpb_dim } { \pgfpoint \l_tmpd_dim \l_tmpa_dim } @@ -2873,24 +2975,26 @@ \endpgfpicture } } -\cs_new_protected:Npn \__nicematrix_rowcolors:nnn #1 #2 #3 +\NewDocumentCommand \__nicematrix_rowcolors { O { } m m m } { - \int_step_inline:nnn { #1 } { \int_use:N \c@iRow } + \int_step_inline:nnn { #2 } { \int_use:N \c@iRow } { \int_if_odd:nTF { ##1 } - { \__nicematrix_rowcolor:nn { #2 } { ##1 } } - { \__nicematrix_rowcolor:nn { #3 } { ##1 } } + { \__nicematrix_rowcolor [ #1 ] { #3 } } + { \__nicematrix_rowcolor [ #1 ] { #4 } } + { ##1 } } } -\cs_new_protected:Npn \__nicematrix_chessboardcolors:nn #1 #2 +\NewDocumentCommand \__nicematrix_chessboardcolors { O { } m m } { \int_step_inline:nn { \int_use:N \c@iRow } { \int_step_inline:nn { \int_use:N \c@jCol } { \int_if_even:nTF { ####1 + ##1 } - { \__nicematrix_cellcolor:nn { #1 } { ####1 - ##1 } } - { \__nicematrix_cellcolor:nn { #2 } { ####1 - ##1 } } + { \__nicematrix_cellcolor [ #1 ] { #2 } } + { \__nicematrix_cellcolor [ #1 ] { #3 } } + { ##1 - ####1 } } } } @@ -2925,16 +3029,14 @@ \pgfsetlinewidth \arrayrulewidth \__nicematrix_qpoint:n { row - 1 } \dim_set_eq:NN \l_tmpa_dim \pgf@y - \pgfusepathqfill \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \c@iRow } \dim_sub:Nn \l_tmpa_dim \pgf@y - \pgfusepathqfill \dim_zero:N \l_tmpb_dim \int_compare:nNnT \l__nicematrix_last_row_int > { -1 } { \dim_set_eq:NN \l_tmpb_dim \g__nicematrix_dp_last_row_dim \dim_add:Nn \l_tmpb_dim \g__nicematrix_ht_last_row_dim - \__nicematrix_qpoint:n { row - \__nicematrix_succ:n\c@iRow } + \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \c@iRow } \dim_add:Nn \l_tmpa_dim \pgf@y \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \g__nicematrix_row_total_int } \dim_sub:Nn \l_tmpa_dim \pgf@y @@ -2957,6 +3059,154 @@ \endpgfpicture \group_end: } +%% +\cs_new_protected:Npn \__nicematrix_draw_hlines: + { + \pgfpicture + \CT@arc@ + \pgfrememberpicturepositiononpagetrue + \pgf@relevantforpicturesizefalse + \pgfsetlinewidth \arrayrulewidth + \int_step_inline:nnn + { \bool_if:NTF \l__nicematrix_NiceArray_bool 1 2 } + { \bool_if:NTF \l__nicematrix_NiceArray_bool { \__nicematrix_succ:n \c@iRow } \c@iRow } + { + \__nicematrix_qpoint:n { row - ##1 } + \dim_set_eq:NN \l_tmpa_dim \pgf@y + \pgfpathmoveto { \pgfpoint \pgf@x \pgf@y } + \__nicematrix_qpoint:n { col - \__nicematrix_succ:n { \c@jCol } } + \dim_set:Nn \l_tmpb_dim { \pgf@x + 0.5 \arrayrulewidth } + \pgfpathlineto { \pgfpoint \l_tmpb_dim \l_tmpa_dim } + } + \pgfusepathqstroke + \endpgfpicture + } +\cs_new_protected:Npn \__nicematrix_draw_hvlines: + { + \bool_lazy_and:nnTF + { \seq_if_empty_p:N \g__nicematrix_pos_of_blocks_seq } + { \seq_if_empty_p:N \g__nicematrix_pos_of_xdots_seq } + \__nicematrix_draw_hvlines_i: + \__nicematrix_draw_hvlines_ii: + } +\cs_new_protected:Npn \__nicematrix_draw_hvlines_i: + { + \__nicematrix_draw_hlines: + \__nicematrix_draw_vlines: + } +\cs_new_protected:Npn \__nicematrix_draw_hvlines_ii: + { + \group_begin: + \CT@arc@ + \bool_if:NT \l__nicematrix_NiceArray_bool + { + \pgfpicture + \pgfrememberpicturepositiononpagetrue + \pgf@relevantforpicturesizefalse + \pgfsetlinewidth \arrayrulewidth + \pgfsetrectcap + \__nicematrix_qpoint:n { col - 1 } + \dim_set_eq:NN \l_tmpa_dim \pgf@x + \__nicematrix_qpoint:n { row -1 } + \dim_set_eq:NN \l_tmpb_dim \pgf@y + \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \c@jCol } + \dim_set_eq:NN \l_tmpc_dim \pgf@x + \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \c@iRow } + \pgfpathrectanglecorners + { \pgfpoint \l_tmpa_dim \l_tmpb_dim } + { \pgfpoint \l_tmpc_dim \pgf@y } + \pgfusepathqstroke + \endpgfpicture + } + \int_step_variable:nnNn 2 \c@iRow \l_tmpa_tl + { + \int_step_variable:nNn \c@jCol \l_tmpb_tl + { + \bool_gset_true:N \g_tmpa_bool + \seq_map_inline:Nn \g__nicematrix_pos_of_blocks_seq + { \__nicematrix_test_if_hline_in_block:nnnn ##1 } + \seq_map_inline:Nn \g__nicematrix_pos_of_xdots_seq + { \__nicematrix_test_if_hline_in_block:nnnn ##1 } + \bool_if:NT \g_tmpa_bool + { + \pgfpicture + \pgfrememberpicturepositiononpagetrue + \pgf@relevantforpicturesizefalse + \pgfsetlinewidth \arrayrulewidth + \pgfsetrectcap + \__nicematrix_qpoint:n { row - \l_tmpa_tl } + \dim_set_eq:NN \l_tmpb_dim \pgf@y + \__nicematrix_qpoint:n { col - \l_tmpb_tl } + \dim_set_eq:NN \l_tmpa_dim \pgf@x + \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l_tmpb_tl } + \dim_set_eq:NN \l_tmpc_dim \pgf@x + \pgfpathmoveto { \pgfpoint \l_tmpa_dim \l_tmpb_dim } + \pgfpathlineto { \pgfpoint \l_tmpc_dim \l_tmpb_dim } + \pgfusepathqstroke + \endpgfpicture + } + } + } + \int_step_variable:nNn \c@iRow \l_tmpa_tl + { + \int_step_variable:nnNn 2 \c@jCol \l_tmpb_tl + { + \bool_gset_true:N \g_tmpa_bool + \seq_map_inline:Nn \g__nicematrix_pos_of_blocks_seq + { \__nicematrix_test_if_vline_in_block:nnnn ##1 } + \seq_map_inline:Nn \g__nicematrix_pos_of_xdots_seq + { \__nicematrix_test_if_vline_in_block:nnnn ##1 } + \bool_if:NT \g_tmpa_bool + { + \pgfpicture + \pgfrememberpicturepositiononpagetrue + \pgf@relevantforpicturesizefalse + \pgfsetlinewidth \arrayrulewidth + \pgfsetrectcap + \__nicematrix_qpoint:n { row - \l_tmpa_tl } + \dim_set_eq:NN \l_tmpb_dim \pgf@y + \__nicematrix_qpoint:n { col - \l_tmpb_tl } + \dim_set_eq:NN \l_tmpa_dim \pgf@x + \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \l_tmpa_tl } + \dim_set_eq:NN \l_tmpc_dim \pgf@y + \pgfpathmoveto { \pgfpoint \l_tmpa_dim \l_tmpb_dim } + \pgfpathlineto { \pgfpoint \l_tmpa_dim \l_tmpc_dim } + \pgfusepathqstroke + \endpgfpicture + } + } + } + \group_end: + \seq_gclear:N \g__nicematrix_pos_of_xdots_seq + } +\cs_set_protected:Npn \__nicematrix_test_if_hline_in_block:nnnn #1 #2 #3 #4 + { + \int_compare:nNnT \l_tmpa_tl > { #1 } + { + \int_compare:nNnT \l_tmpa_tl < { #3 + 1 } + { + \int_compare:nNnT \l_tmpb_tl > { #2 - 1 } + { + \int_compare:nNnT \l_tmpb_tl < { #4 + 1 } + { \bool_gset_false:N \g_tmpa_bool } + } + } + } + } +\cs_set_protected:Npn \__nicematrix_test_if_vline_in_block:nnnn #1 #2 #3 #4 + { + \int_compare:nNnT \l_tmpa_tl > { #1 - 1 } + { + \int_compare:nNnT \l_tmpa_tl < { #3 + 1 } + { + \int_compare:nNnT \l_tmpb_tl > { #2 } + { + \int_compare:nNnT \l_tmpb_tl < { #4 + 1 } + { \bool_gset_false:N \g_tmpa_bool } + } + } + } + } \cs_new:Npn \__nicematrix_hdottedline: { \noalign { \skip_vertical:N 2\l__nicematrix_radius_dim } @@ -3264,40 +3514,35 @@ \cs_new:Npn \__nicematrix_Block_i #1-#2 \q_stop { \__nicematrix_Block_ii:nnnnn { #1 } { #2 } } \cs_new_protected:Npn \__nicematrix_Block_ii:nnnnn #1 #2 #3 #4 #5 { - \tl_gput_left:Nx \g__nicematrix_internal_code_after_tl + \tl_set:Nx \l_tmpa_tl { - \__nicematrix_Block_iii:nnnnnn { \int_use:N \c@iRow } { \int_use:N \c@jCol } { \int_eval:n { \c@iRow + #1 - 1 } } { \int_eval:n { \c@jCol + #2 - 1 } } - { #3 } - \exp_not:n { { #4 $ #5 $ } } } - \cs_set_eq:NN \Block \__nicematrix_Block_error:nn - } -\cs_new:Npn \__nicematrix_Block_error:nn #1 #2 - { - \__nicematrix_error:n { Second~Block } - \cs_set_eq:NN \Block \use:nn + \seq_gput_left:NV \g__nicematrix_pos_of_blocks_seq \l_tmpa_tl + \seq_gput_left:Nx \g__nicematrix_blocks_seq + { + \l_tmpa_tl + { #3 } + \exp_not:n { { #4 \__nicematrix_math_toggle_token: #5 \__nicematrix_math_toggle_token: } } + } } \keys_define:nn { NiceMatrix / Block } { tikz .tl_set:N = \l__nicematrix_tikz_tl , tikz .value_required:n = true , - white .bool_set:N = \l__nicematrix_white_bool , - white .default:n = true , - white .value_forbidden:n = true , } +\cs_new_protected:Npn \__nicematrix_draw_blocks: + { \seq_map_inline:Nn \g__nicematrix_blocks_seq { \__nicematrix_Block_iii:nnnnnn ##1 } } \cs_new_protected:Npn \__nicematrix_Block_iii:nnnnnn #1 #2 #3 #4 #5 #6 { \group_begin: \keys_set:nn { NiceMatrix / Block } { #5 } - \bool_if:nTF - { - \int_compare_p:nNn { #3 } > \c@iRow - || \int_compare_p:nNn { #4 } > \c@jCol - } + \bool_lazy_or:nnTF + { \int_compare_p:nNn { #3 } > \c@iRow } + { \int_compare_p:nNn { #4 } > \c@jCol } { \msg_error:nnnn { nicematrix } { Block~too~large } { #1 } { #2 } } { \hbox_set:Nn \l__nicematrix_cell_box { #6 } @@ -3312,24 +3557,6 @@ \dim_set_eq:NN \l_tmpc_dim \pgf@y \__nicematrix_qpoint:n { col - \__nicematrix_succ:n { #4 } } \dim_set_eq:NN \l_tmpd_dim \pgf@x - \bool_if:NT \l__nicematrix_white_bool - { - \begin { pgfscope } - \pgfsetfillcolor { white } - \pgfpathrectanglecorners - { - \pgfpoint - { \l_tmpb_dim + 0.5 \arrayrulewidth } - { \l_tmpa_dim - 0.5 \arrayrulewidth } - } - { - \pgfpoint - { \l_tmpd_dim - 0.5 \arrayrulewidth } - { \l_tmpc_dim + 0.5 \arrayrulewidth } - } - \pgfusepathqfill - \end { pgfscope } - } \begin { pgfscope } \exp_args:Nx \pgfset { \l__nicematrix_tikz_tl } \__nicematrix_pgf_rect_node:nnnnn @@ -3434,21 +3661,23 @@ \cs_new_protected:Npn \__nicematrix_dotfill: { \__nicematrix_dotfill - \group_insert_after:N \__nicematrix_dotfill_i: + \bool_if:NT \l__nicematrix_NiceTabular_bool + { \group_insert_after:N \__nicematrix_dotfill_ii: } + { \group_insert_after:N \__nicematrix_dotfill_i: } } \cs_new_protected:Npn \__nicematrix_dotfill_i: { \group_insert_after:N \__nicematrix_dotfill_ii: } \cs_new_protected:Npn \__nicematrix_dotfill_ii: { \group_insert_after:N \__nicematrix_dotfill_iii: } \cs_new_protected:Npn \__nicematrix_dotfill_iii: { \dim_compare:nNnT { \box_wd:N \l__nicematrix_cell_box } = \c_zero_dim \__nicematrix_dotfill } -\cs_new_protected:Npn \__nicematrix_slashbox:nn #1 #2 +\cs_new_protected:Npn \__nicematrix_diagbox:nn #1 #2 { \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl { - \__nicematrix_actually_slashbox:nnnn + \__nicematrix_actually_diagbox:nnnn { \int_use:N \c@iRow } { \int_use:N \c@jCol } { #1 } { #2 } } } -\cs_new_protected:Npn \__nicematrix_actually_slashbox:nnnn #1 #2 #3 #4 +\cs_new_protected:Npn \__nicematrix_actually_diagbox:nnnn #1 #2 #3 #4 { \pgfpicture \pgf@relevantforpicturesizefalse @@ -3471,10 +3700,12 @@ \pgfset { inner~sep = 1 pt } \pgfscope \pgftransformshift { \pgfpoint \l_tmpb_dim \l_tmpc_dim } - \pgfnode { rectangle } { south~west } { $ #3 $ } { } { } + \pgfnode { rectangle } { south~west } + { \__nicematrix_math_toggle_token: #3 \__nicematrix_math_toggle_token: } { } { } \endpgfscope \pgftransformshift { \pgfpoint \l_tmpd_dim \l_tmpa_dim } - \pgfnode { rectangle } { north~east } { $ #4 $ } { } { } + \pgfnode { rectangle } { north~east } + { \__nicematrix_math_toggle_token: #4 \__nicematrix_math_toggle_token: } { } { } \endpgfpicture } \cs_new_protected:Npn \__nicematrix_CodeAfter:n #1 \end @@ -3492,14 +3723,6 @@ \__nicematrix_CodeAfter:n } } -\__nicematrix_msg_new:nn { obsolete~environments } - { - The~obsolete~environments~(eg.~{pNiceArrayC})~have~been~deleted~ - from~the~package~nicematrix.\\ - However,~if~you~still~want~to~use~them,~you~will~find~the~code~for~ - those~environments~at~the~end~of~the~file~'nicematrix.sty',~after~ - a~command~'\token_to_str:N\file_input_stop:'. - } \keys_define:nn { NiceMatrix / Package } { renew-dots .bool_set:N = \l__nicematrix_renew_dots_bool , @@ -3508,11 +3731,6 @@ renew-matrix .value_forbidden:n = true , transparent .meta:n = { renew-dots , renew-matrix } , transparent .value_forbidden:n = true, - obsolete-environments .code:n = \__nicematrix_fatal:n { obsolete~environments }, - starred-commands .code:n = - \__nicematrix_msg_redirect_name:nn { starred~commands } { none } , - starred-commands .value_forbidden:n = true , - } \ProcessKeysOptions { NiceMatrix / Package } \cs_new_protected:Npn \__nicematrix_convert_to_str_seq:N #1 @@ -3622,13 +3840,10 @@ the~option~'light-syntax'.~You~must~use~the~character~'\l__nicematrix_end_of_row_tl'~ (set~by~the~option~'end-of-row').~This~error~is~fatal. } -\__nicematrix_msg_new:nn { starred~commands } +\__nicematrix_msg_new:nn { standard-cline~in~document } { - The~starred~versions~of~\token_to_str:N \Cdots,~\token_to_str:N \Ldots,~ - \token_to_str:N \Vdots,~\token_to_str:N\Ddots\ and~\token_to_str:N\Iddots\ - are~deprecated.~However,~you~can~go~on~for~this~time.~If~you~don't~want~to~ - see~this~error~we~should~load~'nicematrix'~with~the~option~ - 'starred-commands'. + The~key~'standard-cline'~is~available~only~in~the~preamble.\\ + If~you~go~on~this~command~will~be~ignored. } \__nicematrix_msg_new:nn { bad~value~for~baseline } { @@ -3637,11 +3852,6 @@ \int_use:N \g__nicematrix_row_total_int\ or~equal~to~'t',~'c'~or~'b'.\\ If~you~go~on,~a~value~of~1~will~be~used. } -\__nicematrix_msg_new:nn { Second~Block } - { - You~can't~use~\token_to_str:N \Block\ twice~in~the~same~cell~of~the~array.\\ - If~you~go~on,~this~command~(and~the~other)~will~be~ignored. - } \__nicematrix_msg_new:nn { empty~environment } { Your~\__nicematrix_full_name_env:\ is~empty.~This~error~is~fatal. } \__nicematrix_msg_new:nn { unknown~cell~for~line~in~code-after } @@ -3699,7 +3909,7 @@ The~key~'\tl_use:N\l_keys_key_str'~is~unknown~for~the~command~ \token_to_str:N \NiceMatrixOptions. \\ If~you~go~on,~it~will~be~ignored. \\ - For~a~list~of~the~available~keys,~type~H~<return>. + For~a~list~of~the~*principal*~available~keys,~type~H~<return>. } { The~available~options~are~(in~alphabetic~order):~ @@ -3714,7 +3924,6 @@ create-medium-nodes,~ create-large-nodes,~ end-of-row,~ - exterior-arraycolsep,~ first-col,~ first-row,~ hlines,~ @@ -3725,7 +3934,6 @@ letter-for-dotted-lines,~ light-syntax,~ nullify-dots,~ - parallelize-diags,~ renew-dots,~ renew-matrix,~ right-margin,~ @@ -3741,7 +3949,7 @@ The~option~'\tl_use:N\l_keys_key_str'~is~unknown~for~the~environment~ \{NiceArray\}. \\ If~you~go~on,~it~will~be~ignored. \\ - For~a~list~of~the~available~options,~type~H~<return>. + For~a~list~of~the~*principal*~available~options,~type~H~<return>. } { The~available~options~are~(in~alphabetic~order):~ @@ -3759,7 +3967,6 @@ create-extra-nodes,~ create-medium-nodes,~ create-large-nodes,~ - end-of-row,~ extra-left-margin,~ extra-right-margin,~ first-col,~ @@ -3772,9 +3979,10 @@ light-syntax,~ name,~ nullify-dots,~ - parallelize-diags,~ renew-dots,~ right-margin,~ + rules/color,~ + rules/width,~ small,~ t,~ vlines,~ @@ -3787,7 +3995,7 @@ The~option~'\tl_use:N\l_keys_key_str'~is~unknown~for~the~ \__nicematrix_full_name_env:. \\ If~you~go~on,~it~will~be~ignored. \\ - For~a~list~of~the~available~options,~type~H~<return>. + For~a~list~of~the~*principal*~available~options,~type~H~<return>. } { The~available~options~are~(in~alphabetic~order):~ @@ -3805,7 +4013,6 @@ create-extra-nodes,~ create-medium-nodes,~ create-large-nodes,~ - end-of-row,~ extra-left-margin,~ extra-right-margin,~ first-col,~ @@ -3819,10 +4026,11 @@ light-syntax,~ name,~ nullify-dots,~ - parallelize-diags,~ r~(=R),~ renew-dots,~ right-margin,~ + rules/color,~ + rules/width,~ S,~ small,~ t,~ @@ -3836,7 +4044,7 @@ The~option~'\tl_use:N\l_keys_key_str'~is~unknown~for~the~environment~ \{NiceTabular\}. \\ If~you~go~on,~it~will~be~ignored. \\ - For~a~list~of~the~available~options,~type~H~<return>. + For~a~list~of~the~*principal*~available~options,~type~H~<return>. } { The~available~options~are~(in~alphabetic~order):~ @@ -3854,7 +4062,6 @@ create-extra-nodes,~ create-medium-nodes,~ create-large-nodes,~ - end-of-row,~ extra-left-margin,~ extra-right-margin,~ first-col,~ @@ -3867,9 +4074,10 @@ light-syntax,~ name,~ nullify-dots,~ - parallelize-diags,~ renew-dots,~ right-margin,~ + rules/color,~ + rules/width,~ t,~ vlines,~ xdots/color,~ @@ -3900,85 +4108,6 @@ and~R~in~the~preamble~of~your~environment. \\ This~error~is~fatal. } -\file_input_stop: -\NewDocumentEnvironment { pNiceArrayC } { } - { - \int_zero:N \l__nicematrix_last_col_int - \pNiceArray - } - { \endpNiceArray } - \NewDocumentEnvironment { bNiceArrayC } { } - { - \int_zero:N \l__nicematrix_last_col_int - \bNiceArray - } - { \endbNiceArray } -\NewDocumentEnvironment { BNiceArrayC } { } - { - \int_zero:N \l__nicematrix_last_col_int - \BNiceArray - } - { \endBNiceArray } -\NewDocumentEnvironment { vNiceArrayC } { } - { - \int_zero:N \l__nicematrix_last_col_int - \vNiceArray - } - { \endvNiceArray } -\NewDocumentEnvironment { VNiceArrayC } { } - { - \int_zero:N \l__nicematrix_last_col_int - \VNiceArray - } - { \endVNiceArray } -\NewDocumentEnvironment { pNiceArrayRC } { } - { - \int_zero:N \l__nicematrix_last_col_int - \int_zero:N \l__nicematrix_first_row_int - \pNiceArray - } - { \endpNiceArray } -\NewDocumentEnvironment { bNiceArrayRC } { } - { - \int_zero:N \l__nicematrix_last_col_int - \int_zero:N \l__nicematrix_first_row_int - \bNiceArray - } - { \endbNiceArray } -\NewDocumentEnvironment { BNiceArrayRC } { } - { - \int_zero:N \l__nicematrix_last_col_int - \int_zero:N \l__nicematrix_first_row_int - \BNiceArray - } - { \endBNiceArray } -\NewDocumentEnvironment { vNiceArrayRC } { } - { - \int_zero:N \l__nicematrix_last_col_int - \int_zero:N \l__nicematrix_first_row_int - \vNiceArray - } - { \endvNiceArray } -\NewDocumentEnvironment { VNiceArrayRC } { } - { - \int_zero:N \l__nicematrix_last_col_int - \int_zero:N \l__nicematrix_first_row_int - \VNiceArray - } - { \endVNiceArray } -\NewDocumentEnvironment { NiceArrayCwithDelims } { } - { - \int_zero:N \l__nicematrix_last_col_int - \NiceArrayWithDelims - } - { \endNiceArrayWithDelims } -\NewDocumentEnvironment { NiceArrayRCwithDelims } { } - { - \int_zero:N \l__nicematrix_last_col_int - \int_zero:N \l__nicematrix_first_row_int - \NiceArrayWithDelims - } - { \endNiceArrayWithDelims } \endinput %% |