diff options
author | Karl Berry <karl@freefriends.org> | 2020-08-20 21:11:01 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-08-20 21:11:01 +0000 |
commit | 09ce7eaab854b9d1a6d44d71e17f88d19424885a (patch) | |
tree | 89903ef57488cbb8661c1a36f7299d5a1dc09f0f /Master/texmf-dist/tex/latex/nicematrix | |
parent | 807f068b398c5941246eba117c4d14c205a493f1 (diff) |
nicematrix (20aug20)
git-svn-id: svn://tug.org/texlive/trunk@56142 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/nicematrix')
-rw-r--r-- | Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty | 750 |
1 files changed, 440 insertions, 310 deletions
diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty index a4b6441abf1..c4ffc2e87fa 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{5.1} -\def\myfiledate{2020/07/31} +\def\myfileversion{5.2} +\def\myfiledate{2020/08/19} \RequirePackage{pgfcore} \usepgfmodule{shapes} @@ -113,7 +113,14 @@ \cs_set:Npn \CT@arc #1 #2 { \dim_compare:nNnT \baselineskip = \c_zero_dim \noalign - { \cs_gset:Npn \CT@arc@ { \color #1 { #2 } } } + { \cs_gset:Npn \CT@arc@ { \color #1 { #2 } } } + } + \cs_set_protected:Npn \CT@drsc@ { } + \cs_set:Npn \doublerulesepcolor #1 # { \CT@drs { #1 } } + \cs_set:Npn\CT@drs #1 #2 + { + \dim_compare:nNnT \baselineskip = \c_zero_dim \noalign + { \cs_gset:Npn \CT@drsc@ { \color #1 { #2 } } } } \cs_set:Npn \hline { @@ -133,7 +140,11 @@ \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 } + { + \CT@arc@ + \leaders \hrule \@height \arrayrulewidth \hfill + \skip_horizontal:N \c_zero_dim + } \everycr { } \cr \noalign { \skip_vertical:N -\arrayrulewidth } @@ -146,7 +157,11 @@ \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 } + { + \CT@arc@ + \leaders \hrule \@height \arrayrulewidth \hfill + \skip_horizontal:N \c_zero_dim + } \peek_meaning_remove_ignore_spaces:NTF \cline { & \__nicematrix_cline_i:en { \__nicematrix_succ:n { #3 } } } { \everycr { } \cr } @@ -217,7 +232,7 @@ { \ExplSyntaxOn \cs_if_free:NT \pgfsyspdfmark - { \cs_set_eq:NN \pgfsyspdfmark \use:nnn } + { \cs_set_eq:NN \pgfsyspdfmark \@gobblethree } \ExplSyntaxOff } \cs_gset_eq:NN \__nicematrix_provide_pgfsyspdfmark: \prg_do_nothing: @@ -252,7 +267,7 @@ \colorlet { nicematrix-last-col } { . } \colorlet { nicematrix-last-row } { . } \str_new:N \g__nicematrix_name_env_str -\str_set:Nn \g__nicematrix_com_or_env_str { environment } +\tl_set:Nn \g__nicematrix_com_or_env_str { environment } \cs_new:Npn \__nicematrix_full_name_env: { \str_if_eq:VnTF \g__nicematrix_com_or_env_str { command } @@ -296,7 +311,7 @@ \newcounter { tabularnote } \seq_new:N \g__nicematrix_tabularnotes_seq \int_new:N \l__nicematrix_number_of_notes_int -\cs_new:Npn \__nicematrix_notes_style:n #1 { \emph { \alph { #1 } } } +\cs_new:Npn \__nicematrix_notes_style:n #1 { \textit { \alph { #1 } } } \cs_new:Npn \__nicematrix_notes_label_in_tabular:n #1 { \textsuperscript { #1 } } \cs_new:Npn \__nicematrix_notes_label_in_list:n #1 { \textsuperscript { #1 } } \cs_set:Npn \thetabularnote { { \__nicematrix_notes_style:n { tabularnote } } } @@ -420,14 +435,13 @@ \tl_set_eq:NN \l__nicematrix_xdots_line_style_tl \c__nicematrix_standard_tl \bool_new:N \l__nicematrix_light_syntax_bool \str_new:N \l__nicematrix_baseline_str -\str_set:Nn \l__nicematrix_baseline_str c +\tl_set:Nn \l__nicematrix_baseline_str c \bool_new:N \l__nicematrix_exterior_arraycolsep_bool \bool_new:N \l__nicematrix_parallelize_diags_bool \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_hvlines_except_corners_bool +\bool_new:N \l__nicematrix_hlines_bool +\clist_new:N \l__nicematrix_except_corners_clist \dim_new:N \l__nicematrix_notes_above_space_dim \dim_set:Nn \l__nicematrix_notes_above_space_dim { 1 mm } \bool_new:N \l__nicematrix_nullify_dots_bool @@ -499,7 +513,6 @@ vlines .bool_set:N = \l__nicematrix_vlines_bool , 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 } , @@ -525,23 +538,30 @@ } \keys_define:nn { NiceMatrix / Env } { - hvlines-except-corners .bool_set:N = \l__nicematrix_hvlines_except_corners_bool , - hvlines-except-corners .default:n = true , - code-before .code:n = + except-corners .clist_set:N = \l__nicematrix_except_corners_clist , + except-corners .default:n = { NW , SW , NE , SE } , + hvlines-except-corners .code:n = { - \tl_if_empty:nF { #1 } - { - \tl_put_right:Nn \l__nicematrix_code_before_tl { #1 } - \bool_set_true:N \l__nicematrix_code_before_bool - } + \clist_set:Nn \l__nicematrix_except_corners_clist { #1 } + \bool_set_true:N \l__nicematrix_vlines_bool + \bool_set_true:N \l__nicematrix_hlines_bool } , - c .code:n = \str_set:Nn \l__nicematrix_baseline_str c , - t .code:n = \str_set:Nn \l__nicematrix_baseline_str t , - b .code:n = \str_set:Nn \l__nicematrix_baseline_str b , + hvlines-except-corners .default:n = { NW , SW , NE , SE } , + code-before .code:n = + { + \tl_if_empty:nF { #1 } + { + \tl_put_right:Nn \l__nicematrix_code_before_tl { #1 } + \bool_set_true:N \l__nicematrix_code_before_bool + } + } , + c .code:n = \tl_set:Nn \l__nicematrix_baseline_str c , + t .code:n = \tl_set:Nn \l__nicematrix_baseline_str t , + b .code:n = \tl_set:Nn \l__nicematrix_baseline_str b , baseline .tl_set:N = \l__nicematrix_baseline_str , baseline .value_required:n = true , columns-width .code:n = - \str_if_eq:nnTF { #1 } { auto } + \tl_if_eq:nnTF { #1 } { auto } { \bool_set_true:N \l__nicematrix_auto_columns_width_bool } { \dim_set:Nn \l__nicematrix_columns_width_dim { #1 } } , columns-width .value_required:n = true , @@ -663,7 +683,7 @@ transparent .value_forbidden:n = true, exterior-arraycolsep .bool_set:N = \l__nicematrix_exterior_arraycolsep_bool , columns-width .code:n = - \str_if_eq:nnTF { #1 } { auto } + \tl_if_eq:nnTF { #1 } { auto } { \__nicematrix_error:n { Option~auto~for~columns-width } } { \dim_set:Nn \l__nicematrix_columns_width_dim { #1 } } , allow-duplicate-names .code:n = @@ -671,7 +691,7 @@ allow-duplicate-names .value_forbidden:n = true , letter-for-dotted-lines .code:n = { - \int_compare:nTF { \tl_count:n { #1 } = 1 } + \tl_if_single_token:nTF { #1 } { \str_set:Nx \l__nicematrix_letter_for_dotted_lines_str { #1 } } { \__nicematrix_error:n { Bad~value~for~letter~for~dotted~lines } } } , @@ -694,9 +714,6 @@ { \int_set:Nn \l__nicematrix_last_col_int { #1 } } , l .code:n = \tl_set:Nn \l__nicematrix_type_of_col_tl l , r .code:n = \tl_set:Nn \l__nicematrix_type_of_col_tl r , - S .code:n = \bool_if:NTF \c__nicematrix_siunitx_loaded_bool - { \tl_set:Nn \l__nicematrix_type_of_col_tl S } - { \__nicematrix_error:n { option~S~without~siunitx } } , small .bool_set:N = \l__nicematrix_small_bool , small .value_forbidden:n = true , unknown .code:n = \__nicematrix_error:n { Unknown~option~for~NiceMatrix } @@ -1002,6 +1019,7 @@ \cs_set_eq:NN \Ddots \__nicematrix_Ddots \cs_set_eq:NN \Iddots \__nicematrix_Iddots \cs_set_eq:NN \hdottedline \__nicematrix_hdottedline: + \cs_set_eq:NN \Hline \__nicematrix_Hline: \cs_set_eq:NN \Hspace \__nicematrix_Hspace: \cs_set_eq:NN \Hdotsfor \__nicematrix_Hdotsfor: \cs_set_eq:NN \Vdotsfor \__nicematrix_Vdotsfor: @@ -1009,7 +1027,7 @@ \cs_set_eq:NN \Block \__nicematrix_Block: \cs_set_eq:NN \rotate \__nicematrix_rotate: \cs_set_eq:NN \OnlyMainNiceMatrix \__nicematrix_OnlyMainNiceMatrix:n - \cs_set_eq:NN \dotfill \__nicematrix_dotfill: + \cs_set_eq:NN \dotfill \__nicematrix_old_dotfill: \cs_set_eq:NN \CodeAfter \__nicematrix_CodeAfter:n \cs_set_eq:NN \diagbox \__nicematrix_diagbox:nn \bool_if:NT \l__nicematrix_colortbl_like_bool \__nicematrix_colortbl_like: @@ -1028,7 +1046,7 @@ \tl_gclear_new:N \g__nicematrix_Ddots_lines_tl \tl_gclear_new:N \g__nicematrix_Iddots_lines_tl \tl_gclear_new:N \g__nicematrix_HVdotsfor_lines_tl - \tl_gclear_new:N \g__nicematrix_code_before_tl + \tl_gclear_new:N \g_nicematrix_code_before_tl } \NewDocumentEnvironment { NiceArrayWithDelims } { m m O { } m ! O { } } { @@ -1056,9 +1074,9 @@ \int_gincr:N \g__nicematrix_env_int \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 + \seq_gclear:N \g__nicematrix_blocks_seq + \seq_gclear:N \g__nicematrix_pos_of_blocks_seq + \seq_gclear:N \g__nicematrix_pos_of_xdots_seq \tl_if_exist:cT { g__nicematrix_code_before_ \int_use:N \g__nicematrix_env_int _ tl } { \bool_set_true:N \l__nicematrix_code_before_bool @@ -1364,7 +1382,6 @@ l { \__nicematrix_patch_preamble_i:n #1 } r { \__nicematrix_patch_preamble_i:n #1 } > { \__nicematrix_patch_preamble_ii:nn #1 } - < { \__nicematrix_patch_preamble_ii:nn #1 } ! { \__nicematrix_patch_preamble_ii:nn #1 } @ { \__nicematrix_patch_preamble_ii:nn #1 } | { \__nicematrix_patch_preamble_iii:n #1 } @@ -1386,12 +1403,7 @@ { \tl_gput_right:Nn \g__nicematrix_preamble_tl { > \__nicematrix_Cell: #1 < \__nicematrix_end_Cell: } \int_gincr:N \c@jCol - \bool_if:NT \l__nicematrix_vlines_bool - { - \tl_gput_right:Nn \g__nicematrix_preamble_tl - { ! { \skip_horizontal:N \arrayrulewidth } } - } - \__nicematrix_patch_preamble:n + \__nicematrix_patch_preamble_viii:n } \cs_new_protected:Npn \__nicematrix_patch_preamble_ii:nn #1 #2 { @@ -1423,7 +1435,7 @@ } } \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl - { \__nicematrix_vline:nn { \int_use:N \c@jCol } { \int_use:N \l_tmpa_int } } + { \__nicematrix_vline:nn { \__nicematrix_succ:n \c@jCol } { \int_use:N \l_tmpa_int } } \int_zero:N \l_tmpa_int \__nicematrix_patch_preamble:n #1 } @@ -1442,7 +1454,7 @@ < { \box_use:N \@arstrutbox \end { minipage } \__nicematrix_end_Cell: } } \int_gincr:N \c@jCol - \__nicematrix_patch_preamble:n + \__nicematrix_patch_preamble_viii:n } \cs_new_protected:Npn \__nicematrix_patch_preamble_v:nnnn #1 #2 #3 #4 { @@ -1461,18 +1473,13 @@ } } \int_gincr:N \c@jCol - \__nicematrix_patch_preamble:n + \__nicematrix_patch_preamble_viii:n } \cs_new_protected:Npn \__nicematrix_patch_preamble_vi:n #1 { \tl_gput_right:Nn \g__nicematrix_preamble_tl { c } \int_gincr:N \c@jCol - \bool_if:NT \l__nicematrix_vlines_bool - { - \tl_gput_right:Nn \g__nicematrix_preamble_tl - { ! { \skip_horizontal:N \arrayrulewidth } } - } - \__nicematrix_patch_preamble:n + \__nicematrix_patch_preamble_viii:n } \cs_new_protected:Npn \__nicematrix_patch_preamble_vii:n #1 { @@ -1482,6 +1489,24 @@ { \__nicematrix_vdottedline:n { \int_use:N \c@jCol } } \__nicematrix_patch_preamble:n } +\cs_new_protected:Npn \__nicematrix_patch_preamble_viii:n #1 + { + \str_if_eq:nnTF { #1 } { < } + \__nicematrix_patch_preamble_ix:n + { + \bool_if:NT \l__nicematrix_vlines_bool + { + \tl_gput_right:Nn \g__nicematrix_preamble_tl + { ! { \skip_horizontal:N \arrayrulewidth } } + } + \__nicematrix_patch_preamble:n { #1 } + } + } +\cs_new_protected:Npn \__nicematrix_patch_preamble_ix:n #1 + { + \tl_gput_right:Nn \g__nicematrix_preamble_tl { < { #1 } } + \__nicematrix_patch_preamble_viii:n + } \cs_new_protected:Npn \__nicematrix_put_box_in_flow: { \box_set_ht:Nn \l_tmpa_box { \box_ht:N \l_tmpa_box + \l_tmpa_dim } @@ -1492,30 +1517,41 @@ } \cs_new_protected:Npn \__nicematrix_put_box_in_flow_i: { - \str_case:VnF \l__nicematrix_baseline_str - { - { t } { \int_set:Nn \l_tmpa_int 1 } - { b } { \int_set_eq:NN \l_tmpa_int \c@iRow } - } - { \int_set:Nn \l_tmpa_int \l__nicematrix_baseline_str } - \bool_if:nT - { - \int_compare_p:nNn \l_tmpa_int < \l__nicematrix_first_row_int - || \int_compare_p:nNn \l_tmpa_int > \g__nicematrix_row_total_int - } - { - \__nicematrix_error:n { bad~value~for~baseline } - \int_set:Nn \l_tmpa_int 1 - } \pgfpicture \__nicematrix_qpoint:n { row - 1 } \dim_gset_eq:NN \g_tmpa_dim \pgf@y \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \c@iRow } \dim_gadd:Nn \g_tmpa_dim \pgf@y \dim_gset:Nn \g_tmpa_dim { 0.5 \g_tmpa_dim } - \__nicematrix_qpoint:n { row - \int_use:N \l_tmpa_int - base } + \str_if_in:NnTF \l__nicematrix_baseline_str { line- } + { + \int_set:Nn \l_tmpa_int + { + \str_range:Nnn + \l__nicematrix_baseline_str + 6 + { \str_count:N \l__nicematrix_baseline_str } + } + \__nicematrix_qpoint:n { row - \int_use:N \l_tmpa_int } + } + { + \str_case:VnF \l__nicematrix_baseline_str + { + { t } { \int_set:Nn \l_tmpa_int 1 } + { b } { \int_set_eq:NN \l_tmpa_int \c@iRow } + } + { \int_set:Nn \l_tmpa_int \l__nicematrix_baseline_str } + \bool_lazy_or:nnT + { \int_compare_p:nNn \l_tmpa_int < \l__nicematrix_first_row_int } + { \int_compare_p:nNn \l_tmpa_int > \g__nicematrix_row_total_int } + { + \__nicematrix_error:n { bad~value~for~baseline } + \int_set:Nn \l_tmpa_int 1 + } + \__nicematrix_qpoint:n { row - \int_use:N \l_tmpa_int - base } + \dim_gsub:Nn \g_tmpa_dim { \fontdimen22 \textfont2 } + } \dim_gsub:Nn \g_tmpa_dim \pgf@y - \dim_gsub:Nn \g_tmpa_dim { \fontdimen22 \textfont2 } \endpgfpicture \box_move_up:nn \g_tmpa_dim { \box_use_drop:N \l_tmpa_box } \box_use_drop:N \l_tmpa_box @@ -1578,7 +1614,7 @@ \cs_new_protected:Npn \__nicematrix_use_arraybox_with_notes: { \str_if_eq:VnT \l__nicematrix_baseline_str { t } - { \str_set:Nn \l__nicematrix_baseline_str { 1 } } + { \tl_set:Nn \l__nicematrix_baseline_str { 1 } } \int_set:Nn \l_tmpa_int \l__nicematrix_baseline_str \bool_lazy_or:nnT { \int_compare_p:nNn \l_tmpa_int < \l__nicematrix_first_row_int } @@ -1957,7 +1993,7 @@ \str_gset:Nn \g__nicematrix_name_env_str { #1 NiceMatrix } \tl_set:Nn \l__nicematrix_type_of_col_tl c \keys_set:nn { NiceMatrix / NiceMatrix } { ##1 } - \exp_args:Nnx \__nicematrix_begin_of_NiceMatrix:nn { #1 } \l__nicematrix_type_of_col_tl + \exp_args:Nne \__nicematrix_begin_of_NiceMatrix:nn { #1 } \l__nicematrix_type_of_col_tl } { \use:c { end #1 NiceArray } } } @@ -2043,6 +2079,9 @@ \int_use:N \g__nicematrix_col_total_int } + \seq_gset_from_clist:cn + { c__nicematrix_pos_of_blocks_ \int_use:N \g__nicematrix_env_int _ seq } + { \seq_use:Nnnn \g__nicematrix_pos_of_blocks_seq , , , } } \iow_now:Nn \@mainaux \ExplSyntaxOff } @@ -2075,18 +2114,23 @@ \dim_set:Nn \l__nicematrix_xdots_shorten_dim { 0.6 \l__nicematrix_xdots_shorten_dim } } \__nicematrix_draw_dotted_lines: - \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: - \bool_if:NT \l__nicematrix_hvlines_except_corners_bool - \__nicematrix_draw_hvlines_except_corners: - } - \cs_set_eq:NN \ialign \__nicematrix_old_ialign: - \seq_if_empty:NF \g__nicematrix_blocks_seq \__nicematrix_draw_blocks: + \__nicematrix_compute_corners: + % \bool_lazy_all:nT + % { + % { \seq_if_empty_p:N \g__nicematrix_pos_of_blocks_seq } + % { \seq_if_empty_p:N \g__nicematrix_pos_of_xdots_seq } + % { \seq_if_empty_p:N \l__nicematrix_empty_corner_cells_seq } + % } + % { + % \cs_set_eq:NN \__nicematrix_vline_i:nn \__nicematrix_vline_i_complete:nn + % \cs_set_eq:NN \__nicematrix_hline_i:nn \__nicematrix_hline_i_complete:nn + % } + \bool_if:NT \l__nicematrix_hlines_bool \__nicematrix_draw_hlines: + \bool_if:NT \l__nicematrix_vlines_bool \__nicematrix_draw_vlines: \g__nicematrix_internal_code_after_tl \tl_gclear:N \g__nicematrix_internal_code_after_tl + \cs_set_eq:NN \ialign \__nicematrix_old_ialign: + \seq_if_empty:NF \g__nicematrix_blocks_seq \__nicematrix_draw_blocks: \bool_if:NT \c__nicematrix_tikz_loaded_bool { \tikzset @@ -2104,7 +2148,7 @@ \g_nicematrix_code_after_tl \tl_gclear:N \g_nicematrix_code_after_tl \group_end: - \tl_if_empty:NF \g__nicematrix_code_before_tl + \tl_if_empty:NF \g_nicematrix_code_before_tl { \cs_set_protected:Npn \rectanglecolor { } \cs_set_protected:Npn \columncolor { } @@ -2113,7 +2157,7 @@ { \tl_gset:cn { g__nicematrix_code_before_ \int_use:N \g__nicematrix_env_int _ tl } - { \g__nicematrix_code_before_tl } + { \g_nicematrix_code_before_tl } } \iow_now:Nn \@mainaux \ExplSyntaxOff \bool_set_true:N \l__nicematrix_code_before_bool @@ -2290,15 +2334,12 @@ } } } - \bool_if:NT \l__nicematrix_hvlines_bool + \seq_gput_right:Nx \g__nicematrix_pos_of_xdots_seq { - \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 } - } + { \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: @@ -2899,10 +2940,21 @@ \__nicematrix_old_multicolumn { #1 } { - > \__nicematrix_Cell: - \bool_if:NT \c__nicematrix_define_L_C_R_bool \tl_lower_case:n - #2 - < \__nicematrix_end_Cell: + \exp_args:Ne \str_case:nn { \tl_lower_case:n { #2 } } + { + l { > \__nicematrix_Cell: l < \__nicematrix_end_Cell: } + r { > \__nicematrix_Cell: r < \__nicematrix_end_Cell: } + c { > \__nicematrix_Cell: c < \__nicematrix_end_Cell: } + { l | } { > \__nicematrix_Cell: l < \__nicematrix_end_Cell: | } + { r | } { > \__nicematrix_Cell: r < \__nicematrix_end_Cell: | } + { c | } { > \__nicematrix_Cell: c < \__nicematrix_end_Cell: | } + { | l } { | > \__nicematrix_Cell: l < \__nicematrix_end_Cell: } + { | r } { | > \__nicematrix_Cell: r < \__nicematrix_end_Cell: } + { | c } { | > \__nicematrix_Cell: c < \__nicematrix_end_Cell: } + { | l | } { | > \__nicematrix_Cell: l < \__nicematrix_end_Cell: | } + { | r | } { | > \__nicematrix_Cell: r < \__nicematrix_end_Cell: | } + { | c | } { | > \__nicematrix_Cell: c < \__nicematrix_end_Cell: | } + } } { #3 } \peek_remove_spaces:n @@ -3111,7 +3163,7 @@ \group_begin: \keys_set:nn { NiceMatrix / xdots } { #1 , #4 , down = #5 , up = #6 } \tl_if_empty:VF \l__nicematrix_xdots_color_tl { \color { \l__nicematrix_xdots_color_tl } } - \use:x + \use:e { \__nicematrix_line_i:nn { \__nicematrix_double_int_eval:n #2 \q_stop } @@ -3300,15 +3352,80 @@ \endpgfpicture } } -\NewDocumentCommand \__nicematrix_rowcolors { O { } m m m } +\keys_define:nn { NiceMatrix / rowcolors } + { + respect-blocks .bool_set:N = \l__nicematrix_respect_blocks_bool , + respect-blocks .default:n = true , + unknown .code:n = \__nicematrix_error:n { Unknown~option~for~rowcolors } + } +\NewDocumentCommand \__nicematrix_rowcolors { O { } m m m O { } } + { + \keys_set:nn { NiceMatrix / rowcolors } { #5 } + \bool_lazy_and:nnTF + \l__nicematrix_respect_blocks_bool + { \cs_if_exist_p:c { c__nicematrix_pos_of_blocks_ \int_use:N \g__nicematrix_env_int _ seq } } + { \__nicematrix_rowcolors_i:nnnn { #1 } { #2 } { #3 } { #4 } } + { + \int_step_inline:nnn { #2 } { \int_use:N \c@iRow } + { + \int_if_odd:nTF { ##1 } + { \__nicematrix_rowcolor [ #1 ] { #3 } } + { \__nicematrix_rowcolor [ #1 ] { #4 } } + { ##1 } + } + } + } +\cs_new_protected:Npn \__nicematrix_rowcolors_i:nnnn #1 #2 #3 #4 + { + \seq_set_eq:Nc \l_tmpb_seq + { c__nicematrix_pos_of_blocks_ \int_use:N \g__nicematrix_env_int _ seq } + \seq_set_filter:NNn \l_tmpa_seq \l_tmpb_seq + { \__nicematrix_not_in_exterior_p:nnnn ##1 } + \int_set:Nn \l_tmpa_int { #2 } + \bool_set_false:N \l_tmpa_bool + \int_do_until:nNnn \l_tmpa_int > \c@iRow + { + \seq_set_filter:NNn \l_tmpb_seq \l_tmpa_seq + { \__nicematrix_intersect_our_row_p:nnnn ##1 } + \int_set_eq:NN \l_tmpb_int \l_tmpa_int + \seq_map_inline:Nn \l_tmpb_seq { \__nicematrix_rowcolors_ii:nnnn ##1 } + \bool_if:NTF \l_tmpa_bool + { + \__nicematrix_rowcolor [ #1 ] { #4 } + { \int_use:N \l_tmpa_int - \int_use:N \l_tmpb_int } + \bool_set_false:N \l_tmpa_bool + } + { + \__nicematrix_rowcolor [ #1 ] { #3 } + { \int_use:N \l_tmpa_int - \int_use:N \l_tmpb_int } + \bool_set_true:N \l_tmpa_bool + } + \int_set:Nn \l_tmpa_int { \l_tmpb_int + 1 } + } + } +\cs_new_protected:Npn \__nicematrix_rowcolors_ii:nnnn #1 #2 #3 #4 { - \int_step_inline:nnn { #2 } { \int_use:N \c@iRow } + \int_compare:nNnT { #3 } > \l_tmpb_int + { \int_set:Nn \l_tmpb_int { #3 } } + } +\prg_new_conditional:Nnn \__nicematrix_not_in_exterior:nnnn p + { + \bool_lazy_or:nnTF + { \int_compare_p:nNn { #4 } = \c_zero_int } + { \int_compare_p:nNn { #2 } = { \__nicematrix_succ:n { \c@jCol } } } + \prg_return_false: + \prg_return_true: + } +\prg_new_conditional:Nnn \__nicematrix_intersect_our_row:nnnn p + { + \bool_if:nTF { - \int_if_odd:nTF { ##1 } - { \__nicematrix_rowcolor [ #1 ] { #3 } } - { \__nicematrix_rowcolor [ #1 ] { #4 } } - { ##1 } + \int_compare_p:n { #1 <= \l_tmpa_int } + && + \int_compare_p:n { \l_tmpa_int <= #3 } } + \prg_return_true: + \prg_return_false: } \NewDocumentCommand \__nicematrix_chessboardcolors { O { } m m } { @@ -3325,12 +3442,12 @@ } \NewDocumentCommand \__nicematrix_cellcolor_tabular { O { } m } { - \tl_gput_right:Nx \g__nicematrix_code_before_tl + \tl_gput_right:Nx \g_nicematrix_code_before_tl { \cellcolor [ #1 ] { #2 } { \int_use:N \c@iRow - \int_use:N \c@jCol } } } \NewDocumentCommand \__nicematrix_rowcolor_tabular { O { } m } { - \tl_gput_right:Nx \g__nicematrix_code_before_tl + \tl_gput_right:Nx \g_nicematrix_code_before_tl { \exp_not:N \rectanglecolor [ #1 ] { #2 } { \int_use:N \c@iRow - \int_use:N \c@jCol } @@ -3341,7 +3458,7 @@ { \int_compare:nNnT \c@iRow = 1 { - \tl_gput_left:Nx \g__nicematrix_code_before_tl + \tl_gput_left:Nx \g_nicematrix_code_before_tl { \exp_not:N \columncolor [ #1 ] { #2 } { \int_use:N \c@jCol } } } } @@ -3366,12 +3483,7 @@ } \cs_new_protected:Npn \__nicematrix_vline:nn #1 #2 { - \bool_if:NTF \c__nicematrix_tikz_loaded_bool - { - \tikzpicture - \__nicematrix_vline_i:nn { #1 } { #2 } - \endtikzpicture - } + \int_compare:nNnT { #1 } < { \c@jCol + 2 } { \pgfpicture \__nicematrix_vline_i:nn { #1 } { #2 } @@ -3380,18 +3492,72 @@ } \cs_new_protected:Npn \__nicematrix_vline_i:nn #1 #2 { - \CT@arc@ + \tl_set:Nx \l_tmpb_tl { #1 } + \int_step_variable:nNn \c@iRow \l_tmpa_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 } + \clist_if_empty:NF \l__nicematrix_except_corners_clist + \__nicematrix_test_in_corner_v: + \bool_if:NT \g_tmpa_bool + { \__nicematrix_vline_ii:nnnn { #1 } { #2 } \l_tmpa_tl \l_tmpa_tl } + } + } +\cs_new_protected:Npn \__nicematrix_test_in_corner_v: + { + \int_compare:nNnTF \l_tmpb_tl = { \__nicematrix_succ:n \c@jCol } + { + \seq_if_in:NxT + \l__nicematrix_empty_corner_cells_seq + { \l_tmpa_tl - \__nicematrix_pred:n \l_tmpb_tl } + { \bool_set_false:N \g_tmpa_bool } + } + { + \seq_if_in:NxT + \l__nicematrix_empty_corner_cells_seq + { \l_tmpa_tl - \l_tmpb_tl } + { + \int_compare:nNnTF \l_tmpb_tl = 1 + { \bool_set_false:N \g_tmpa_bool } + { + \seq_if_in:NxT + \l__nicematrix_empty_corner_cells_seq + { \l_tmpa_tl - \__nicematrix_pred:n \l_tmpb_tl } + { \bool_set_false:N \g_tmpa_bool } + } + } + } + } +\cs_new_protected:Npn \__nicematrix_vline_ii:nnnn #1 #2 #3 #4 + { \pgfrememberpicturepositiononpagetrue \pgf@relevantforpicturesizefalse - \pgfsetlinewidth { 1.1 \arrayrulewidth } - \pgfsetrectcap - \__nicematrix_qpoint:n { row - 1 } + \__nicematrix_qpoint:n { row - #3 } \dim_set_eq:NN \l_tmpa_dim \pgf@y - \__nicematrix_qpoint:n { col - \int_eval:n { #1 + 1 } } + \__nicematrix_qpoint:n { col - #1 } \dim_set_eq:NN \l_tmpb_dim \pgf@x - \pgfpathmoveto { \pgfpoint \l_tmpb_dim \l_tmpa_dim } - \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \c@iRow } + \__nicematrix_qpoint:n { row - \__nicematrix_succ:n { #4 } } \dim_set_eq:NN \l_tmpc_dim \pgf@y + \bool_lazy_and:nnT + { \int_compare_p:nNn { #2 } > 1 } + { ! \tl_if_blank_p:V \CT@drsc@ } + { + \group_begin: + \CT@drsc@ + \dim_add:Nn \l_tmpa_dim { 0.5 \arrayrulewidth } + \dim_sub:Nn \l_tmpc_dim { 0.5 \arrayrulewidth } + \dim_set:Nn \l_tmpd_dim + { \l_tmpb_dim - ( \doublerulesep + \arrayrulewidth ) * ( #2 - 1 ) } + \pgfpathrectanglecorners + { \pgfpoint \l_tmpb_dim \l_tmpa_dim } + { \pgfpoint \l_tmpd_dim \l_tmpc_dim } + \pgfusepathqfill + \group_end: + } + \pgfpathmoveto { \pgfpoint \l_tmpb_dim \l_tmpa_dim } \pgfpathlineto { \pgfpoint \l_tmpb_dim \l_tmpc_dim } \prg_replicate:nn { #2 - 1 } { @@ -3400,188 +3566,131 @@ \pgfpathmoveto { \pgfpoint \l_tmpb_dim \l_tmpa_dim } \pgfpathlineto { \pgfpoint \l_tmpb_dim \l_tmpc_dim } } + \CT@arc@ + \pgfsetlinewidth { 1.1 \arrayrulewidth } + \pgfsetrectcap \pgfusepathqstroke } +\cs_new_protected:Npn \__nicematrix_vline_i_complete:nn #1 #2 + { \__nicematrix_vline_ii:nnnn { #1 } { #2 } 1 { \int_use:N \c@iRow } } \cs_new_protected:Npn \__nicematrix_draw_vlines: { - \group_begin: - \CT@arc@ - \pgfpicture - \pgfrememberpicturepositiononpagetrue - \pgf@relevantforpicturesizefalse - \pgfsetlinewidth \arrayrulewidth - \pgfsetrectcap - \__nicematrix_qpoint:n { row - 1 } - \dim_set_eq:NN \l_tmpa_dim \pgf@y - \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \c@iRow } - \dim_set_eq:NN \l_tmpb_dim \pgf@y \int_step_inline:nnn { \bool_if:NTF \l__nicematrix_NiceArray_bool 1 2 } { \bool_if:NTF \l__nicematrix_NiceArray_bool { \__nicematrix_succ:n \c@jCol } \c@jCol } + { \__nicematrix_vline:nn { ##1 } 1 } + } +\cs_new_protected:Npn \__nicematrix_hline:nn #1 #2 + { + \pgfpicture + \__nicematrix_hline_i:nn { #1 } { #2 } + \endpgfpicture + } +\cs_new_protected:Npn \__nicematrix_hline_i:nn #1 #2 + { + \tl_set:Nn \l_tmpa_tl { #1 } + \int_step_variable:nNn \c@jCol \l_tmpb_tl { - \__nicematrix_qpoint:n { col - ##1 } - \dim_set_eq:NN \l_tmpc_dim \pgf@x - \pgfpathmoveto { \pgfpoint \l_tmpc_dim \l_tmpa_dim } - \pgfpathlineto { \pgfpoint \l_tmpc_dim \l_tmpb_dim } + \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 } + \clist_if_empty:NF \l__nicematrix_except_corners_clist \__nicematrix_test_in_corner_h: + \bool_if:NT \g_tmpa_bool + { \__nicematrix_hline_ii:nnnn { #1 } { #2 } \l_tmpb_tl \l_tmpb_tl } } - \pgfusepathqstroke - \endpgfpicture - \group_end: } -\cs_new_protected:Npn \__nicematrix_draw_hlines: +\cs_new_protected:Npn \__nicematrix_test_in_corner_h: + { + \int_compare:nNnTF \l_tmpa_tl = { \__nicematrix_succ:n \c@iRow } + { + \seq_if_in:NxT + \l__nicematrix_empty_corner_cells_seq + { \__nicematrix_pred:n \l_tmpa_tl - \l_tmpb_tl } + { \bool_set_false:N \g_tmpa_bool } + } + { + \seq_if_in:NxT + \l__nicematrix_empty_corner_cells_seq + { \l_tmpa_tl - \l_tmpb_tl } + { + \int_compare:nNnTF \l_tmpa_tl = 1 + { \bool_set_false:N \g_tmpa_bool } + { + \seq_if_in:NxT + \l__nicematrix_empty_corner_cells_seq + { \__nicematrix_pred:n \l_tmpa_tl - \l_tmpb_tl } + { \bool_set_false:N \g_tmpa_bool } + } + } + } + } +\cs_new_protected:Npn \__nicematrix_hline_ii:nnnn #1 #2 #3 #4 { - \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 { col - #3 } + \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 { #4 } } + \dim_set_eq:NN \l_tmpc_dim \pgf@x + \bool_lazy_and:nnT + { \int_compare_p:nNn { #2 } > 1 } + { ! \tl_if_blank_p:V \CT@drsc@ } { - \__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 } + \group_begin: + \CT@drsc@ + \dim_set:Nn \l_tmpd_dim + { \l_tmpb_dim - ( \doublerulesep + \arrayrulewidth ) * ( #2 - 1 ) } + \pgfpathrectanglecorners + { \pgfpoint \l_tmpa_dim \l_tmpb_dim } + { \pgfpoint \l_tmpc_dim \l_tmpd_dim } + \pgfusepathqfill + \group_end: } + \pgfpathmoveto { \pgfpoint \l_tmpa_dim \l_tmpb_dim } + \pgfpathlineto { \pgfpoint \l_tmpc_dim \l_tmpb_dim } + \prg_replicate:nn { #2 - 1 } + { + \dim_sub:Nn \l_tmpb_dim \arrayrulewidth + \dim_sub:Nn \l_tmpb_dim \doublerulesep + \pgfpathmoveto { \pgfpoint \l_tmpa_dim \l_tmpb_dim } + \pgfpathlineto { \pgfpoint \l_tmpc_dim \l_tmpb_dim } + } + \CT@arc@ + \pgfsetlinewidth { 1.1 \arrayrulewidth } + \pgfsetrectcap \pgfusepathqstroke - \endpgfpicture } -\cs_new_protected:Npn \__nicematrix_draw_hvlines: +\cs_new_protected:Npn \__nicematrix_hline_i_complete:nn #1 #2 + { \__nicematrix_hline_ii:nnnn #1 #2 1 { \int_use:N \c@jCol } } +\cs_new_protected:Npn \__nicematrix_draw_hlines: { - \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: + \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_hline:nn { ##1 } 1 } } -\cs_new_protected:Npn \__nicematrix_draw_hvlines_i: +\cs_set:Npn \__nicematrix_Hline: { \noalign { \ifnum 0 = `} \fi \__nicematrix_Hline_i:n { 1 } } +\cs_set:Npn \__nicematrix_Hline_i:n #1 { - \__nicematrix_draw_hlines: - \__nicematrix_draw_vlines: + \peek_meaning_ignore_spaces:NTF \Hline + { \__nicematrix_Hline_ii:nn { #1 + 1 } } + { \__nicematrix_Hline_iii:n { #1 } } } -\cs_new_protected:Npn \__nicematrix_draw_hvlines_ii: +\cs_set:Npn \__nicematrix_Hline_ii:nn #1 #2 { \__nicematrix_Hline_i:n { #1 } } +\cs_set:Npn \__nicematrix_Hline_iii:n #1 { - \group_begin: - \CT@arc@ - \int_step_variable:nnNn - { \bool_if:NTF \l__nicematrix_NiceArray_bool 1 2 } - { \bool_if:NTF \l__nicematrix_NiceArray_bool { \__nicematrix_succ:n \c@iRow } \c@iRow } - \l_tmpa_tl + \skip_vertical:n { - \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 \l__nicematrix_hvlines_except_corners_bool - { - \int_compare:nNnTF \l_tmpa_tl = { \c@iRow + 1 } - { - \seq_if_in:NxT - \l__nicematrix_empty_corner_cells_seq - { \__nicematrix_pred:n \l_tmpa_tl - \l_tmpb_tl } - { \bool_set_false:N \g_tmpa_bool } - } - { - \seq_if_in:NxT - \l__nicematrix_empty_corner_cells_seq - { \l_tmpa_tl - \l_tmpb_tl } - { - \int_compare:nNnTF \l_tmpa_tl = 1 - { \bool_set_false:N \g_tmpa_bool } - { - \seq_if_in:NxT - \l__nicematrix_empty_corner_cells_seq - { \__nicematrix_pred:n \l_tmpa_tl - \l_tmpb_tl } - { \bool_set_false:N \g_tmpa_bool } - } - } - } - } - \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 - } - } + \arrayrulewidth * ( #1 ) + + \doublerulesep * ( \int_max:nn 0 { #1 - 1 } ) } - \int_step_variable:nNn \c@iRow \l_tmpa_tl - { - \int_step_variable:nnNn - { \bool_if:NTF \l__nicematrix_NiceArray_bool 1 2 } - { \bool_if:NTF \l__nicematrix_NiceArray_bool { \__nicematrix_succ:n \c@jCol } \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 \l__nicematrix_hvlines_except_corners_bool - { - \int_compare:nNnTF \l_tmpb_tl = { \__nicematrix_succ:n \c@jCol } - { - \seq_if_in:NxT - \l__nicematrix_empty_corner_cells_seq - { \l_tmpa_tl - \__nicematrix_pred:n \l_tmpb_tl } - { \bool_set_false:N \g_tmpa_bool } - } - { - \seq_if_in:NxT - \l__nicematrix_empty_corner_cells_seq - { \l_tmpa_tl - \l_tmpb_tl } - { - \int_compare:nNnTF \l_tmpb_tl = 1 - { \bool_set_false:N \g_tmpa_bool } - { - \seq_if_in:NxT - \l__nicematrix_empty_corner_cells_seq - { \l_tmpa_tl - \__nicematrix_pred:n \l_tmpb_tl } - { \bool_set_false:N \g_tmpa_bool } - } - } - } - } - \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 + \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl + { \__nicematrix_hline:nn { \__nicematrix_succ:n { \c@iRow } } { #1 } } + \ifnum 0 = `{ \fi } } \cs_new_protected:Npn \__nicematrix_test_if_hline_in_block:nnnn #1 #2 #3 #4 { @@ -3605,29 +3714,39 @@ } { \bool_gset_false:N \g_tmpa_bool } } -\cs_new_protected:Npn \__nicematrix_draw_hvlines_except_corners: +\cs_new_protected:Npn \__nicematrix_compute_corners: { \seq_clear_new:N \l__nicematrix_empty_corner_cells_seq - \__nicematrix_compute_a_corner:nnnnnn 1 1 1 1 \c@iRow \c@jCol - \__nicematrix_compute_a_corner:nnnnnn 1 \c@jCol 1 { -1 } \c@iRow 1 - \__nicematrix_compute_a_corner:nnnnnn \c@iRow 1 { -1 } 1 1 \c@jCol - \__nicematrix_compute_a_corner:nnnnnn \c@iRow \c@jCol { -1 } { -1 } 1 1 - \__nicematrix_draw_hvlines_ii: + \clist_map_inline:Nn \l__nicematrix_except_corners_clist + { + \str_case:nnF { ##1 } + { + { NW } + { \__nicematrix_compute_a_corner:nnnnnn 1 1 1 1 \c@iRow \c@jCol } + { NE } + { \__nicematrix_compute_a_corner:nnnnnn 1 \c@jCol 1 { -1 } \c@iRow 1 } + { SW } + { \__nicematrix_compute_a_corner:nnnnnn \c@iRow 1 { -1 } 1 1 \c@jCol } + { SE } + { \__nicematrix_compute_a_corner:nnnnnn \c@iRow \c@jCol { -1 } { -1 } 1 1 } + } + { \__nicematrix_error:nn { bad~corner } { ##1 } } + } } \cs_new_protected:Npn \__nicematrix_compute_a_corner:nnnnnn #1 #2 #3 #4 #5 #6 { \bool_set_false:N \l_tmpa_bool \int_zero_new:N \l__nicematrix_last_empty_row_int + \int_set:Nn \l__nicematrix_last_empty_row_int { #1 } \int_step_inline:nnnn { #1 } { #3 } { #5 } { \__nicematrix_test_if_cell_in_a_block:nn { ##1 } { \int_eval:n { #2 } } - \bool_if:nTF + \bool_lazy_or:nnTF { \cs_if_exist_p:c { pgf @ sh @ ns @ \__nicematrix_env: - ##1 - \int_eval:n { #2 } } - || - \l_tmpb_bool } + \l_tmpb_bool { \bool_set_true:N \l_tmpa_bool } { \bool_if:NF \l_tmpa_bool @@ -3636,14 +3755,15 @@ } \bool_set_false:N \l_tmpa_bool \int_zero_new:N \l__nicematrix_last_empty_column_int + \int_set:Nn \l__nicematrix_last_empty_column_int { #2 } \int_step_inline:nnnn { #2 } { #4 } { #6 } { \__nicematrix_test_if_cell_in_a_block:nn { \int_eval:n { #1 } } { ##1 } - \bool_if:nTF + \bool_lazy_or:nnTF + \l_tmpb_bool { \cs_if_exist_p:c { pgf @ sh @ ns @ \__nicematrix_env: - \int_eval:n { #1 } - ##1 } - || \l_tmpb_bool } { \bool_set_true:N \l_tmpa_bool } { @@ -3657,11 +3777,11 @@ \int_step_inline:nnnn { #2 } { #4 } \l__nicematrix_last_empty_column_int { \__nicematrix_test_if_cell_in_a_block:nn { ##1 } { ####1 } - \bool_if:nTF + \bool_lazy_or:nnTF + \l_tmpb_bool { - \cs_if_exist_p:c - { pgf @ sh @ ns @ \__nicematrix_env: - ##1 - ####1 } - || \l_tmpb_bool + \cs_if_exist_p:c + { pgf @ sh @ ns @ \__nicematrix_env: - ##1 - ####1 } } { \bool_set_true:N \l_tmpa_bool } { @@ -3682,18 +3802,21 @@ \int_set:Nn \l_tmpb_int { #2 } \bool_set_false:N \l_tmpb_bool \seq_map_inline:Nn \g__nicematrix_pos_of_blocks_seq - { \__nicematrix_test_if_cell_in_block:nnnnnnn { \l_tmpa_int } { \l_tmpb_int } ##1 } + { \__nicematrix_test_if_cell_in_block:nnnnnnn \l_tmpa_int \l_tmpb_int ##1 } } \cs_new_protected:Npn \__nicematrix_test_if_cell_in_block:nnnnnnn #1 #2 #3 #4 #5 #6 { - \bool_lazy_all:nT + \int_compare:nNnT { #3 } < { \__nicematrix_succ:n { #1 } } { - { \int_compare_p:n { #3 <= #1 } } - { \int_compare_p:n { #1 <= #5 } } - { \int_compare_p:n { #4 <= #2 } } - { \int_compare_p:n { #2 <= #6 } } + \int_compare:nNnT { #1 } < { \__nicematrix_succ:n { #5 } } + { + \int_compare:nNnT { #4 } < { \__nicematrix_succ:n { #2 } } + { + \int_compare:nNnT { #2 } < { \__nicematrix_succ:n { #6 } } + { \bool_set_true:N \l_tmpb_bool } + } + } } - { \bool_set_true:N \l_tmpb_bool } } \cs_new:Npn \__nicematrix_hdottedline: { @@ -4034,7 +4157,7 @@ \keys_set:nn { NiceMatrix / Block } { #5 } \tl_if_empty:NF \l__nicematrix_color_tl { - \tl_gput_right:Nx \g__nicematrix_code_before_tl + \tl_gput_right:Nx \g_nicematrix_code_before_tl { \exp_not:N \rectanglecolor { \l__nicematrix_color_tl } @@ -4053,7 +4176,7 @@ } \bool_lazy_or:nnTF { \int_compare_p:nNn { #3 } > \g__nicematrix_row_total_int } - { \int_compare_p:nNn { #4 } > \c@jCol } + { \int_compare_p:nNn { #4 } > \g__nicematrix_col_total_int } { \msg_error:nnnn { nicematrix } { Block~too~large } { #1 } { #2 } } { \hbox_set:Nn \l__nicematrix_cell_box { #6 } @@ -4207,10 +4330,10 @@ \AutoNiceMatrixWithDelims . . { #2 } { #4 } [ #1 , #3 , #5 ] \group_end: } -\cs_set_eq:NN \__nicematrix_dotfill \dotfill +\cs_set_eq:NN \__nicematrix_old_dotfill \dotfill \cs_new_protected:Npn \__nicematrix_dotfill: { - \__nicematrix_dotfill + \__nicematrix_old_dotfill \bool_if:NT \l__nicematrix_NiceTabular_bool { \group_insert_after:N \__nicematrix_dotfill_ii: } { \group_insert_after:N \__nicematrix_dotfill_i: } @@ -4218,7 +4341,7 @@ \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 } + { \dim_compare:nNnT { \box_wd:N \l__nicematrix_cell_box } = \c_zero_dim \__nicematrix_old_dotfill } \cs_new_protected:Npn \__nicematrix_diagbox:nn #1 #2 { \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl @@ -4448,12 +4571,6 @@ You~can't~use~the~command~#1 in~the~last~row~(exterior)~of~the~array.\\ If~you~go~on,~this~command~will~be~ignored. } -\__nicematrix_msg_new:nn { option~S~without~siunitx } - { - You~can't~use~the~option~'S'~in~your~environment~\__nicematrix_full_name_env: - because~you~have~not~loaded~siunitx.\\ - If~you~go~on,~this~option~will~be~ignored. - } \__nicematrix_msg_new:nn { bad~option~for~line-style } { Since~you~haven't~loaded~Tikz,~the~only~value~you~can~give~to~'line-style'~ @@ -4465,6 +4582,12 @@ and~'shorten'~(and~you~try~to~use~'\l_keys_key_tl').~If~you~go~on,~ this~option~will~be~ignored. } +\__nicematrix_msg_new:nn { Unknown~option~for~rowcolors } + { + As~for~now~there~is~only~one~option~available~here:~'respect-blocks'~ + (and~you~try~to~use~'\l_keys_key_tl').~If~you~go~on,~ + this~option~will~be~ignored. + } \__nicematrix_msg_new:nn { ampersand~in~light-syntax } { You~can't~use~an~ampersand~(\token_to_str &)~to~separate~columns~because @@ -4496,6 +4619,13 @@ can't~be~executed~because~a~cell~doesn't~exist.\\ If~you~go~on~this~command~will~be~ignored. } +\__nicematrix_msg_new:nn { bad~corner } + { + #1~is~an~incorrect~specification~for~a~corner~(in~the~keys~ + 'except-corners'~and~'hvlines-except-corners').~The~available~ + values~are:~NW,~SW,~NE~and~SE.\\ + If~you~go~on,~this~specification~of~corner~will~be~ignored. + } \__nicematrix_msg_new:nn { last-col~non~empty~for~NiceArray } { In~the~\__nicematrix_full_name_env:,~you~must~use~the~option~ @@ -4717,7 +4847,6 @@ right-margin,~ rules/color,~ rules/width,~ - S,~ small,~ t,~ vlines,~ @@ -4779,7 +4908,8 @@ the~same~environment~name~twice.~You~can~go~on,~but,~ maybe,~you~will~have~incorrect~results~especially~ if~you~use~'columns-width=auto'.~If~you~don't~want~to~see~this~ - message~again,~use~the~option~'allow-duplicate-names'.\\ + message~again,~use~the~option~'allow-duplicate-names'~in~ + '\token_to_str:N \NiceMatrixOptions'.\\ For~a~list~of~the~names~already~used,~type~H~<return>. \\ } { |