diff options
author | Karl Berry <karl@freefriends.org> | 2023-08-14 20:19:43 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2023-08-14 20:19:43 +0000 |
commit | e8c287902ec1b75e743163e0d27a58fa379ee843 (patch) | |
tree | cd973e97488d3b3030d0fc8fc562a5c4c5683dcb /Master/texmf-dist/tex/latex | |
parent | 2b1293b804ab57d0ea23e022cc2b090462870e39 (diff) |
nicematrix (14aug23)
git-svn-id: svn://tug.org/texlive/trunk@67925 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty | 824 |
1 files changed, 521 insertions, 303 deletions
diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty index ec8850c8956..9c5f41a0223 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{6.21a} -\def\myfiledate{2023/07/17} +\def\myfileversion{6.22} +\def\myfiledate{2023/08/14} \RequirePackage{pgfcore} \usepgfmodule{shapes} \RequirePackage{l3keys2e} @@ -40,13 +40,14 @@ \cs_new_protected:Npn \__nicematrix_msg_new:nn { \msg_new:nnn { nicematrix } } \cs_new_protected:Npn \__nicematrix_msg_new:nnn #1 #2 #3 { - \bool_if:NTF \c__nicematrix_messages_for_Overleaf_bool + \bool_if:NTF \g__nicematrix_messages_for_Overleaf_bool { \msg_new:nnn { nicematrix } { #1 } { #2 \\ #3 } } { \msg_new:nnnn { nicematrix } { #1 } { #2 } { #3 } } } \cs_new_protected:Npn \__nicematrix_error_or_warning:n - { \bool_if:NTF \c__nicematrix_messages_for_Overleaf_bool \__nicematrix_warning:n \__nicematrix_error:n } -\bool_set:Nn \c__nicematrix_messages_for_Overleaf_bool + { \bool_if:NTF \g__nicematrix_messages_for_Overleaf_bool \__nicematrix_warning:n \__nicematrix_error:n } +\bool_new:N \g__nicematrix_messages_for_Overleaf_bool +\bool_gset:Nn \g__nicematrix_messages_for_Overleaf_bool { \str_if_eq_p:Vn \c_sys_jobname_str { _region_ } % for Emacs || \str_if_eq_p:Vn \c_sys_jobname_str { output } % for Overleaf @@ -101,7 +102,7 @@ \IfPackageLoadedTF { mdwtab } { \__nicematrix_fatal:n { mdwtab~loaded } } { - \bool_if:NF \c__nicematrix_no_test_for_array_bool + \bool_if:NF \g__nicematrix_no_test_for_array_bool { \group_begin: \hbox_set:Nn \l_tmpa_box @@ -114,6 +115,24 @@ } } } +\cs_new_protected:Npn \__nicematrix_collect_options:n #1 + { + \peek_meaning:NTF [ + { \__nicematrix_collect_options:nw { #1 } } + { #1 { } } + } +\NewDocumentCommand \__nicematrix_collect_options:nw { m r[] } + { \__nicematrix_collect_options:nn { #1 } { #2 } } + +\cs_new_protected:Npn \__nicematrix_collect_options:nn #1 #2 + { + \peek_meaning:NTF [ + { \__nicematrix_collect_options:nnw { #1 } { #2 } } + { #1 { #2 } } + } + +\cs_new_protected:Npn \__nicematrix_collect_options:nnw #1#2[#3] + { \__nicematrix_collect_options:nn { #1 } { #2 , #3 } } \tl_new:N \l__nicematrix_argspec_tl \cs_generate_variant:Nn \seq_set_split:Nnn { N V n } \cs_generate_variant:Nn \keys_define:nn { n x } @@ -356,9 +375,17 @@ \bool_new:N \l__nicematrix_X_column_bool \bool_new:N \g__nicematrix_caption_finished_bool \tl_new:N \g__nicematrix_aux_tl +\bool_new:N \g__nicematrix_aux_found_bool +\seq_new:N \g__nicematrix_size_seq +\tl_new:N \g__nicematrix_left_delim_tl +\tl_new:N \g__nicematrix_right_delim_tl +\tl_new:N \g__nicematrix_preamble_tl \tl_new:N \l__nicematrix_columns_type_tl \hook_gput_code:nnn { begindocument } { . } { \__nicematrix_set_preamble:Nn \l__nicematrix_columns_type_tl { c } } +\tl_new:N \l__nicematrix_xdots_down_tl +\tl_new:N \l__nicematrix_xdots_up_tl +\tl_new:N \l__nicematrix_xdots_middle_tl \cs_new_protected:Npn \__nicematrix_test_if_math_mode: { \if_mode_math: \else: @@ -424,6 +451,7 @@ \seq_new:N \g__nicematrix_submatrix_seq \int_new:N \g__nicematrix_static_num_of_col_int \tl_new:N \l__nicematrix_fill_tl +\tl_new:N \l__nicematrix_opacity_tl \tl_new:N \l__nicematrix_draw_tl \seq_new:N \l__nicematrix_tikz_seq \clist_new:N \l__nicematrix_borders_clist @@ -486,6 +514,12 @@ \tl_set_eq:NN #1 \l_tmpa_clist } } +\hook_gput_code:nnn { begindocument } { . } + { + \dim_const:Nn \c__nicematrix_shift_Ldots_last_row_dim { 0.5 em } + \dim_const:Nn \c__nicematrix_shift_exterior_Vdots_dim { 0.6 em } + \dim_const:Nn \c__nicematrix_innersep_middle_dim { 0.17 em } + } \newcounter { tabularnote } \seq_new:N \g__nicematrix_notes_seq \seq_new:N \g__nicematrix_notes_in_caption_seq @@ -649,7 +683,6 @@ \begin { pgfscope } \pgfset { - % outer~sep = \c_zero_dim , inner~sep = \c_zero_dim , minimum~size = \c_zero_dim } @@ -674,7 +707,6 @@ \begin { pgfscope } \pgfset { - % outer~sep = \c_zero_dim , inner~sep = \c_zero_dim , minimum~size = \c_zero_dim } @@ -747,6 +779,21 @@ \bool_new:N \l__nicematrix_delimiters_max_width_bool \keys_define:nn { NiceMatrix / xdots } { + shorten-start .code:n = + \hook_gput_code:nnn { begindocument } { . } + { \dim_set:Nn \l__nicematrix_xdots_shorten_start_dim { #1 } } , + shorten-end .code:n = + \hook_gput_code:nnn { begindocument } { . } + { \dim_set:Nn \l__nicematrix_xdots_shorten_end_dim { #1 } } , + shorten-start .value_required:n = true , + shorten-end .value_required:n = true , + shorten .code:n = + \hook_gput_code:nnn { begindocument } { . } + { + \dim_set:Nn \l__nicematrix_xdots_shorten_start_dim { #1 } + \dim_set:Nn \l__nicematrix_xdots_shorten_end_dim { #1 } + } , + shorten .value_required:n = true , horizontal-labels .bool_set:N = \l__nicematrix_xdots_h_labels_bool , horizontal-labels .default:n = true , line-style .code:n = @@ -760,21 +807,6 @@ line-style .value_required:n = true , color .tl_set:N = \l__nicematrix_xdots_color_tl , color .value_required:n = true , - shorten .code:n = - \hook_gput_code:nnn { begindocument } { . } - { - \dim_set:Nn \l__nicematrix_xdots_shorten_start_dim { #1 } - \dim_set:Nn \l__nicematrix_xdots_shorten_end_dim { #1 } - } , - shorten-start .code:n = - \hook_gput_code:nnn { begindocument } { . } - { \dim_set:Nn \l__nicematrix_xdots_shorten_start_dim { #1 } } , - shorten-end .code:n = - \hook_gput_code:nnn { begindocument } { . } - { \dim_set:Nn \l__nicematrix_xdots_shorten_end_dim { #1 } } , - shorten .value_required:n = true , - shorten-start .value_required:n = true , - shorten-end .value_required:n = true , radius .code:n = \hook_gput_code:nnn { begindocument } { . } { \dim_set:Nn \l__nicematrix_xdots_radius_dim { #1 } } , @@ -783,8 +815,9 @@ \hook_gput_code:nnn { begindocument } { . } { \dim_set:Nn \l__nicematrix_xdots_inter_dim { #1 } } , radius .value_required:n = true , - down .tl_set:N = \l__nicematrix_xdots_down_tl , - up .tl_set:N = \l__nicematrix_xdots_up_tl , + down .code:n = \tl_put_right:Nn \l__nicematrix_xdots_down_tl { #1 } , % modified 2023-08-09 + up .code:n = \tl_put_right:Nn \l__nicematrix_xdots_up_tl { #1 } , + middle .code:n = \tl_put_right:Nn \l__nicematrix_xdots_middle_tl { #1 } , draw-first .code:n = \prg_do_nothing: , unknown .code:n = \__nicematrix_error:n { Unknown~key~for~xdots } } @@ -1355,9 +1388,9 @@ } \cs_new_protected:Npn \__nicematrix_array:n { - \bool_if:NTF \l__nicematrix_tabular_bool - { \dim_set_eq:NN \col@sep \tabcolsep } - { \dim_set_eq:NN \col@sep \arraycolsep } + % modified 05-08-23 + \dim_set:Nn \col@sep + { \bool_if:NTF \l__nicematrix_tabular_bool \tabcolsep \arraycolsep } \dim_compare:nNnTF \l__nicematrix_tabular_width_dim = \c_zero_dim { \cs_set_nopar:Npn \@halignto { } } { \cs_set_nopar:Npx \@halignto { to \dim_use:N \l__nicematrix_tabular_width_dim } } @@ -1605,8 +1638,10 @@ \dim_set:Nn \l__nicematrix_right_delim_dim { \box_wd:N \l_tmpa_box } } { - \dim_gset:Nn \l__nicematrix_left_delim_dim { 2 \arraycolsep } - \dim_gset:Nn \l__nicematrix_right_delim_dim { 2 \arraycolsep } + % modified 05-08-23 + \dim_gset:Nn \l__nicematrix_left_delim_dim + { 2 \bool_if:NTF \l__nicematrix_tabular_bool \tabcolsep \arraycolsep } + \dim_gset_eq:NN \l__nicematrix_right_delim_dim \l__nicematrix_left_delim_dim } \hbox_set:Nw \l__nicematrix_the_array_box \skip_horizontal:N \l__nicematrix_left_margin_dim @@ -1802,7 +1837,7 @@ { \bool_if:NT \c__nicematrix_revtex_bool \__nicematrix_patch_for_revtex: \__nicematrix_provide_pgfsyspdfmark: - \bool_if:NT \c__nicematrix_footnote_bool \savenotes + \bool_if:NT \g__nicematrix_footnote_bool \savenotes \bgroup \tl_gset:Nn \g__nicematrix_left_delim_tl { #1 } \tl_gset:Nn \g__nicematrix_right_delim_tl { #2 } @@ -1834,12 +1869,12 @@ \seq_gclear:N \g__nicematrix_pos_of_xdots_seq \tl_gclear_new:N \g__nicematrix_code_before_tl \tl_gclear:N \g__nicematrix_row_style_tl - \bool_gset_false:N \g__nicematrix_aux_found_bool - \tl_if_exist:cT { c__nicematrix _ \int_use:N \g__nicematrix_env_int _ tl } + \tl_if_exist:cTF { c__nicematrix _ \int_use:N \g__nicematrix_env_int _ tl } { \bool_gset_true:N \g__nicematrix_aux_found_bool \use:c { c__nicematrix _ \int_use:N \g__nicematrix_env_int _ tl } } + { \bool_gset_false:N \g__nicematrix_aux_found_bool } \tl_gclear:N \g__nicematrix_aux_tl \tl_if_empty:NF \g__nicematrix_code_before_tl { @@ -1916,7 +1951,7 @@ \int_compare:nNnT \l__nicematrix_last_row_int > { -1 } { \int_gdecr:N \c@iRow } \int_compare:nNnT \l__nicematrix_first_col_int = 0 { - \skip_horizontal:N \col@sep + % \skip_horizontal:N \col@sep % 05-08-23 \skip_horizontal:N \g__nicematrix_width_first_col_dim } \bool_if:nTF { ! \g__nicematrix_delims_bool } @@ -1975,7 +2010,7 @@ \bool_if:NT \g__nicematrix_last_col_found_bool { \skip_horizontal:N \g__nicematrix_width_last_col_dim - \skip_horizontal:N \col@sep + % \skip_horizontal:N \col@sep % 2023-08-05 } \bool_if:NT \l__nicematrix_preamble_bool { @@ -1992,7 +2027,7 @@ { \exp_not:V \g__nicematrix_aux_tl } } \iow_now:Nn \@mainaux { \ExplSyntaxOff } - \bool_if:NT \c__nicematrix_footnote_bool \endsavenotes + \bool_if:NT \g__nicematrix_footnote_bool \endsavenotes } \cs_new_protected:Npn \__nicematrix_transform_preamble: { @@ -2866,8 +2901,11 @@ { \bool_if:NT \l__nicematrix_NiceMatrix_without_vlines_bool { - \box_set_wd:Nn \l__nicematrix_the_array_box - { \box_wd:N \l__nicematrix_the_array_box - \arraycolsep } + \int_compare:nNnT \c@jCol > 1 % added 2023-08-13 + { + \box_set_wd:Nn \l__nicematrix_the_array_box + { \box_wd:N \l__nicematrix_the_array_box - \arraycolsep } + } } \begin { minipage } [ t ] { \box_wd:N \l__nicematrix_the_array_box } \bool_if:NT \l__nicematrix_caption_above_bool @@ -3605,6 +3643,8 @@ } { \bool_set_true:N \l__nicematrix_except_borders_bool + \clist_if_empty:NF \l__nicematrix_corners_clist + { \__nicematrix_error:n { hvlines,~rounded-corners~and~corners } } \tl_gput_right:Nn \g__nicematrix_pre_code_after_tl { \__nicematrix_stroke_block:nnn @@ -4019,6 +4059,13 @@ { } % for the name of the block } } +\cs_new_protected:Npn \__nicematrix_open_shorten: + { + \bool_if:NT \l__nicematrix_initial_open_bool + { \dim_zero:N \l__nicematrix_xdots_shorten_start_dim } + \bool_if:NT \l__nicematrix_final_open_bool + { \dim_zero:N \l__nicematrix_xdots_shorten_end_dim } + } \cs_new_protected:Npn \__nicematrix_adjust_to_submatrix:nn #1 #2 { \int_set:Nn \l__nicematrix_row_min_int 1 @@ -4127,6 +4174,7 @@ { \__nicematrix_find_extremities_of_line:nnnn { #1 } { #2 } 0 1 \group_begin: + \__nicematrix_open_shorten: \int_compare:nNnTF { #1 } = 0 { \color { nicematrix-first-row } } { @@ -4155,8 +4203,20 @@ \dim_set_eq:NN \l__nicematrix_y_final_dim \pgf@y } { \__nicematrix_set_final_coords_from_anchor:n { base~west } } - \dim_add:Nn \l__nicematrix_y_initial_dim \l__nicematrix_xdots_radius_dim - \dim_add:Nn \l__nicematrix_y_final_dim \l__nicematrix_xdots_radius_dim + \bool_lazy_all:nTF + { + \l__nicematrix_initial_open_bool + \l__nicematrix_final_open_bool + { \int_compare_p:nNn \l__nicematrix_initial_i_int = \l__nicematrix_last_row_int } + } + { + \dim_add:Nn \l__nicematrix_y_initial_dim \c__nicematrix_shift_Ldots_last_row_dim + \dim_add:Nn \l__nicematrix_y_final_dim \c__nicematrix_shift_Ldots_last_row_dim + } + { + \dim_add:Nn \l__nicematrix_y_initial_dim \l__nicematrix_xdots_radius_dim + \dim_add:Nn \l__nicematrix_y_final_dim \l__nicematrix_xdots_radius_dim + } \__nicematrix_draw_line: } \cs_new_protected:Npn \__nicematrix_draw_Cdots:nnn #1 #2 #3 @@ -4166,6 +4226,7 @@ { \__nicematrix_find_extremities_of_line:nnnn { #1 } { #2 } 0 1 \group_begin: + \__nicematrix_open_shorten: \int_compare:nNnTF { #1 } = 0 { \color { nicematrix-first-row } } { @@ -4206,15 +4267,7 @@ } \cs_new_protected:Npn \__nicematrix_open_y_initial_dim: { - \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_initial_i_int - base } - \dim_set:Nn \l__nicematrix_y_initial_dim - { - \fp_to_dim:n - { - \pgf@y - + ( \box_ht:N \strutbox + \extrarowheight ) * \arraystretch - } - } % modified 6.13c + \dim_set:Nn \l__nicematrix_y_initial_dim { - \c_max_dim } \int_step_inline:nnn \l__nicematrix_first_col_int \g__nicematrix_col_total_int { \cs_if_exist:cT @@ -4227,13 +4280,23 @@ { \dim_max:nn \l__nicematrix_y_initial_dim \pgf@y } } } + % modified 2023-08-10 + \dim_compare:nNnT \l__nicematrix_y_initial_dim = { - \c_max_dim } + { + \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_initial_i_int - base } + \dim_set:Nn \l__nicematrix_y_initial_dim + { + \fp_to_dim:n + { + \pgf@y + + ( \box_ht:N \strutbox + \extrarowheight ) * \arraystretch + } + } + } } \cs_new_protected:Npn \__nicematrix_open_y_final_dim: { - \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_final_i_int - base } - \dim_set:Nn \l__nicematrix_y_final_dim - { \fp_to_dim:n { \pgf@y - ( \box_dp:N \strutbox ) * \arraystretch } } - % modified 6.13c + \dim_set_eq:NN \l__nicematrix_y_final_dim \c_max_dim \int_step_inline:nnn \l__nicematrix_first_col_int \g__nicematrix_col_total_int { \cs_if_exist:cT @@ -4246,6 +4309,13 @@ { \dim_min:nn \l__nicematrix_y_final_dim \pgf@y } } } + % modified 2023-08-10 + \dim_compare:nNnT \l__nicematrix_y_final_dim = \c_max_dim + { + \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_final_i_int - base } + \dim_set:Nn \l__nicematrix_y_final_dim + { \fp_to_dim:n { \pgf@y - ( \box_dp:N \strutbox ) * \arraystretch } } + } } \cs_new_protected:Npn \__nicematrix_draw_Vdots:nnn #1 #2 #3 { @@ -4254,6 +4324,7 @@ { \__nicematrix_find_extremities_of_line:nnnn { #1 } { #2 } 1 0 \group_begin: + \__nicematrix_open_shorten: \int_compare:nNnTF { #2 } = 0 { \color { nicematrix-first-col } } { @@ -4269,60 +4340,80 @@ } \cs_new_protected:Npn \__nicematrix_actually_draw_Vdots: { - \bool_set_false:N \l_tmpa_bool - \bool_lazy_or:nnF \l__nicematrix_initial_open_bool \l__nicematrix_final_open_bool - { - \__nicematrix_set_initial_coords_from_anchor:n { south~west } - \__nicematrix_set_final_coords_from_anchor:n { north~west } - \bool_set:Nn \l_tmpa_bool - { \dim_compare_p:nNn \l__nicematrix_x_initial_dim = \l__nicematrix_x_final_dim } - } - \bool_if:NTF \l__nicematrix_initial_open_bool - \__nicematrix_open_y_initial_dim: - { \__nicematrix_set_initial_coords_from_anchor:n { south } } - \bool_if:NTF \l__nicematrix_final_open_bool - \__nicematrix_open_y_final_dim: - { \__nicematrix_set_final_coords_from_anchor:n { north } } - \bool_if:NTF \l__nicematrix_initial_open_bool + \bool_lazy_and:nnTF \l__nicematrix_initial_open_bool \l__nicematrix_final_open_bool { - \bool_if:NTF \l__nicematrix_final_open_bool + \__nicematrix_open_y_initial_dim: + \__nicematrix_open_y_final_dim: + \int_compare:nNnTF \l__nicematrix_initial_j_int = \c_zero_int { - \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_initial_j_int } - \dim_set_eq:NN \l_tmpa_dim \pgf@x - \__nicematrix_qpoint:n { col - \int_eval:n { \l__nicematrix_initial_j_int + 1 } } - \dim_set:Nn \l__nicematrix_x_initial_dim { ( \pgf@x + \l_tmpa_dim ) / 2 } - \dim_set_eq:NN \l__nicematrix_x_final_dim \l__nicematrix_x_initial_dim - \int_compare:nNnT \l__nicematrix_last_col_int > { -2 } + \__nicematrix_qpoint:n { col - 1 } + \dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf@x + \dim_sub:Nn \l__nicematrix_x_initial_dim \l__nicematrix_left_margin_dim + \dim_sub:Nn \l__nicematrix_x_initial_dim \l__nicematrix_extra_left_margin_dim + % \bool_if:NT \g__nicematrix_delims_bool + % { + \dim_sub:Nn \l__nicematrix_x_initial_dim \c__nicematrix_shift_exterior_Vdots_dim + % } + } + { + \bool_lazy_and:nnTF + { \int_compare_p:nNn \l__nicematrix_last_col_int > { -2 } } + { \int_compare_p:nNn \l__nicematrix_initial_j_int = \g__nicematrix_col_total_int } { - \int_compare:nNnT \l__nicematrix_initial_j_int = \g__nicematrix_col_total_int - { - \dim_set:Nn \l_tmpa_dim - { - \l__nicematrix_right_margin_dim + \l__nicematrix_extra_right_margin_dim - + 2 mm - } - \dim_add:Nn \l__nicematrix_x_initial_dim \l_tmpa_dim - \dim_add:Nn \l__nicematrix_x_final_dim \l_tmpa_dim - } + \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_initial_j_int } + \dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf@x + \dim_add:Nn \l__nicematrix_x_initial_dim \l__nicematrix_right_margin_dim + \dim_add:Nn \l__nicematrix_x_initial_dim \l__nicematrix_extra_right_margin_dim + % \bool_if:NT \g__nicematrix_delims_bool + % { + \dim_add:Nn + \l__nicematrix_x_initial_dim + \c__nicematrix_shift_exterior_Vdots_dim + % } + } + { + \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_initial_j_int } + \dim_set_eq:NN \l_tmpa_dim \pgf@x + \__nicematrix_qpoint:n { col - \int_eval:n { \l__nicematrix_initial_j_int + 1 } } + \dim_set:Nn \l__nicematrix_x_initial_dim { ( \pgf@x + \l_tmpa_dim ) / 2 } } } - { \dim_set_eq:NN \l__nicematrix_x_initial_dim \l__nicematrix_x_final_dim } } { - \bool_if:NTF \l__nicematrix_final_open_bool - { \dim_set_eq:NN \l__nicematrix_x_final_dim \l__nicematrix_x_initial_dim } + \bool_set_false:N \l_tmpa_bool + \bool_lazy_and:nnT + { ! \l__nicematrix_initial_open_bool } + { ! \l__nicematrix_final_open_bool } + { + \__nicematrix_set_initial_coords_from_anchor:n { south~west } + \__nicematrix_set_final_coords_from_anchor:n { north~west } + \bool_set:Nn \l_tmpa_bool + { \dim_compare_p:nNn \l__nicematrix_x_initial_dim = \l__nicematrix_x_final_dim } + } + \bool_if:NTF \l__nicematrix_initial_open_bool + { + \__nicematrix_open_y_initial_dim: + \__nicematrix_set_final_coords_from_anchor:n { north } + \dim_set_eq:NN \l__nicematrix_x_initial_dim \l__nicematrix_x_final_dim + } { - \dim_compare:nNnF \l__nicematrix_x_initial_dim = \l__nicematrix_x_final_dim + \__nicematrix_set_initial_coords_from_anchor:n { south } + \bool_if:NTF \l__nicematrix_final_open_bool + \__nicematrix_open_y_final_dim: { - \dim_set:Nn \l__nicematrix_x_initial_dim + \__nicematrix_set_final_coords_from_anchor:n { north } + \dim_compare:nNnF \l__nicematrix_x_initial_dim = \l__nicematrix_x_final_dim { - \bool_if:NTF \l_tmpa_bool \dim_min:nn \dim_max:nn - \l__nicematrix_x_initial_dim \l__nicematrix_x_final_dim + \dim_set:Nn \l__nicematrix_x_initial_dim + { + \bool_if:NTF \l_tmpa_bool \dim_min:nn \dim_max:nn + \l__nicematrix_x_initial_dim \l__nicematrix_x_final_dim + } } - \dim_set_eq:NN \l__nicematrix_x_final_dim \l__nicematrix_x_initial_dim } } } + \dim_set_eq:NN \l__nicematrix_x_final_dim \l__nicematrix_x_initial_dim \__nicematrix_draw_line: } \cs_new_protected:Npn \__nicematrix_draw_Ddots:nnn #1 #2 #3 @@ -4332,6 +4423,7 @@ { \__nicematrix_find_extremities_of_line:nnnn { #1 } { #2 } 1 1 \group_begin: + \__nicematrix_open_shorten: \keys_set:nn { NiceMatrix / xdots } { #3 } \tl_if_empty:VF \l__nicematrix_xdots_color_tl { \color { \l__nicematrix_xdots_color_tl } } \__nicematrix_actually_draw_Ddots: @@ -4380,6 +4472,7 @@ { \__nicematrix_find_extremities_of_line:nnnn { #1 } { #2 } 1 { -1 } \group_begin: + \__nicematrix_open_shorten: \keys_set:nn { NiceMatrix / xdots } { #3 } \tl_if_empty:VF \l__nicematrix_xdots_color_tl { \color { \l__nicematrix_xdots_color_tl } } \__nicematrix_actually_draw_Iddots: @@ -4439,10 +4532,11 @@ } \cs_new_protected:Npn \__nicematrix_draw_unstandard_dotted_line:n #1 { - \__nicematrix_draw_unstandard_dotted_line:nVV + \__nicematrix_draw_unstandard_dotted_line:nVVV { #1 } \l__nicematrix_xdots_up_tl \l__nicematrix_xdots_down_tl + \l__nicematrix_xdots_middle_tl } \cs_generate_variant:Nn \__nicematrix_draw_unstandard_dotted_line:n { o } \hook_gput_code:nnn { begindocument } { . } @@ -4452,85 +4546,87 @@ \tikzset { __nicematrix_node_above / .style = { sloped , above } , - __nicematrix_node_below / .style = { sloped , below } + __nicematrix_node_below / .style = { sloped , below } , + __nicematrix_node_middle / .style = + { + sloped , + inner~sep = \c__nicematrix_innersep_middle_dim + } } } { } } -\cs_new_protected:Npn \__nicematrix_draw_unstandard_dotted_line:nnn #1 #2 #3 +\cs_new_protected:Npn \__nicematrix_draw_unstandard_dotted_line:nnnn #1 #2 #3 #4 { + \dim_zero_new:N \l__nicematrix_l_dim + \dim_set:Nn \l__nicematrix_l_dim + { + \fp_to_dim:n + { + sqrt + ( + ( \l__nicematrix_x_final_dim - \l__nicematrix_x_initial_dim ) ^ 2 + + + ( \l__nicematrix_y_final_dim - \l__nicematrix_y_initial_dim ) ^ 2 + ) + } + } + \bool_lazy_and:nnT % security + { \dim_compare_p:nNn { \dim_abs:n \l__nicematrix_l_dim } < \c__nicematrix_max_l_dim } + { \dim_compare_p:nNn { \dim_abs:n \l__nicematrix_l_dim } > { 1 pt } } + { + \dim_set:Nn \l_tmpa_dim + { + \l__nicematrix_x_initial_dim + + ( \l__nicematrix_x_final_dim - \l__nicematrix_x_initial_dim ) + * \dim_ratio:nn \l__nicematrix_xdots_shorten_start_dim \l__nicematrix_l_dim + } + \dim_set:Nn \l_tmpb_dim + { + \l__nicematrix_y_initial_dim + + ( \l__nicematrix_y_final_dim - \l__nicematrix_y_initial_dim ) + * \dim_ratio:nn \l__nicematrix_xdots_shorten_start_dim \l__nicematrix_l_dim + } + \dim_set:Nn \l__nicematrix_tmpc_dim + { + \l__nicematrix_x_final_dim + - ( \l__nicematrix_x_final_dim - \l__nicematrix_x_initial_dim ) + * \dim_ratio:nn \l__nicematrix_xdots_shorten_end_dim \l__nicematrix_l_dim + } + \dim_set:Nn \l__nicematrix_tmpd_dim + { + \l__nicematrix_y_final_dim + - ( \l__nicematrix_y_final_dim - \l__nicematrix_y_initial_dim ) + * \dim_ratio:nn \l__nicematrix_xdots_shorten_end_dim \l__nicematrix_l_dim + } + \dim_set_eq:NN \l__nicematrix_x_initial_dim \l_tmpa_dim + \dim_set_eq:NN \l__nicematrix_y_initial_dim \l_tmpb_dim + \dim_set_eq:NN \l__nicematrix_x_final_dim \l__nicematrix_tmpc_dim + \dim_set_eq:NN \l__nicematrix_y_final_dim \l__nicematrix_tmpd_dim + } \bool_if:NT \l__nicematrix_xdots_h_labels_bool { \tikzset { __nicematrix_node_above / .style = { auto = left } , - __nicematrix_node_below / .style = { auto = right } + __nicematrix_node_below / .style = { auto = right } , + __nicematrix_node_middle / .style = { inner~sep = \c__nicematrix_innersep_middle_dim } } } + \tl_if_empty:nF { #4 } + { \tikzset { __nicematrix_node_middle / .append~style = { fill = white } } } \draw - [ - shorten~> = \l__nicematrix_xdots_shorten_end_dim , - shorten~< = \l__nicematrix_xdots_shorten_start_dim , - #1 - ] + [ #1 ] ( \l__nicematrix_x_initial_dim , \l__nicematrix_y_initial_dim ) - -- node [ __nicematrix_node_above ] { $ \scriptstyle #2 $ } + -- node [ __nicematrix_node_middle] { $ \scriptstyle #4 $ } node [ __nicematrix_node_below ] { $ \scriptstyle #3 $ } + node [ __nicematrix_node_above ] { $ \scriptstyle #2 $ } ( \l__nicematrix_x_final_dim , \l__nicematrix_y_final_dim ) ; \end { scope } } -\cs_generate_variant:Nn \__nicematrix_draw_unstandard_dotted_line:nnn { n V V } +\cs_generate_variant:Nn \__nicematrix_draw_unstandard_dotted_line:nnnn { n V V V } \cs_new_protected:Npn \__nicematrix_draw_standard_dotted_line: { - \bool_lazy_and:nnF - { \tl_if_empty_p:N \l__nicematrix_xdots_up_tl } - { \tl_if_empty_p:N \l__nicematrix_xdots_down_tl } - { - \pgfscope - \pgftransformshift - { - \pgfpointlineattime { 0.5 } - { \pgfpoint \l__nicematrix_x_initial_dim \l__nicematrix_y_initial_dim } - { \pgfpoint \l__nicematrix_x_final_dim \l__nicematrix_y_final_dim } - } - \fp_set:Nn \l_tmpa_fp - { - atand - ( - \l__nicematrix_y_final_dim - \l__nicematrix_y_initial_dim , - \l__nicematrix_x_final_dim - \l__nicematrix_x_initial_dim - ) - } - \pgftransformrotate { \fp_use:N \l_tmpa_fp } - \bool_if:NF \l__nicematrix_xdots_h_labels_bool { \fp_zero:N \l_tmpa_fp } - \pgfnode - { rectangle } - { south } - { - \rotatebox { \fp_eval:n { - \l_tmpa_fp } } - { - \c_math_toggle_token - \scriptstyle \l__nicematrix_xdots_up_tl - \c_math_toggle_token - } - } - { } - { \pgfusepath { } } - \pgfnode - { rectangle } - { north } - { - \rotatebox { \fp_eval:n { - \l_tmpa_fp } } - { - \c_math_toggle_token - \scriptstyle \l__nicematrix_xdots_down_tl - \c_math_toggle_token - } - } - { } - { \pgfusepath { } } - \endpgfscope - } \group_begin: \dim_zero_new:N \l__nicematrix_l_dim \dim_set:Nn \l__nicematrix_l_dim @@ -4550,47 +4646,26 @@ { \dim_compare_p:nNn \l__nicematrix_l_dim = \c_zero_dim } \__nicematrix_draw_standard_dotted_line_i: \group_end: + \bool_lazy_all:nF + { + { \tl_if_empty_p:N \l__nicematrix_xdots_up_tl } + { \tl_if_empty_p:N \l__nicematrix_xdots_down_tl } + { \tl_if_empty_p:N \l__nicematrix_xdots_middle_tl } + } + \l__nicematrix_labels_standard_dotted_line: } \dim_const:Nn \c__nicematrix_max_l_dim { 50 cm } \cs_new_protected:Npn \__nicematrix_draw_standard_dotted_line_i: { - \bool_if:NTF \l__nicematrix_initial_open_bool + \int_set:Nn \l_tmpa_int { - \bool_if:NTF \l__nicematrix_final_open_bool - { - \int_set:Nn \l_tmpa_int - { \dim_ratio:nn \l__nicematrix_l_dim \l__nicematrix_xdots_inter_dim } - } - { - \int_set:Nn \l_tmpa_int - { - \dim_ratio:nn - { \l__nicematrix_l_dim - \l__nicematrix_xdots_shorten_start_dim } - \l__nicematrix_xdots_inter_dim - } - } - } - { - \bool_if:NTF \l__nicematrix_final_open_bool - { - \int_set:Nn \l_tmpa_int - { - \dim_ratio:nn - { \l__nicematrix_l_dim - \l__nicematrix_xdots_shorten_end_dim } - \l__nicematrix_xdots_inter_dim - } - } + \dim_ratio:nn { - \int_set:Nn \l_tmpa_int - { - \dim_ratio:nn - { - \l__nicematrix_l_dim - - \l__nicematrix_xdots_shorten_start_dim - \l__nicematrix_xdots_shorten_end_dim - } - \l__nicematrix_xdots_inter_dim - } + \l__nicematrix_l_dim + - \l__nicematrix_xdots_shorten_start_dim + - \l__nicematrix_xdots_shorten_end_dim } + \l__nicematrix_xdots_inter_dim } \dim_set:Nn \l_tmpa_dim { @@ -4618,7 +4693,7 @@ \dim_ratio:nn { \l__nicematrix_l_dim - \l__nicematrix_xdots_inter_dim * \l_tmpa_int - + \l__nicematrix_xdots_shorten_start_dim - \l__nicematrix_xdots_shorten_end_dim + + \l__nicematrix_xdots_shorten_start_dim - \l__nicematrix_xdots_shorten_end_dim } { 2 \l__nicematrix_l_dim } } @@ -4633,11 +4708,88 @@ } \pgfusepathqfill } +\cs_new_protected:Npn \l__nicematrix_labels_standard_dotted_line: + { + \pgfscope + \pgftransformshift + { + \pgfpointlineattime { 0.5 } + { \pgfpoint \l__nicematrix_x_initial_dim \l__nicematrix_y_initial_dim } + { \pgfpoint \l__nicematrix_x_final_dim \l__nicematrix_y_final_dim } + } + \fp_set:Nn \l_tmpa_fp + { + atand + ( + \l__nicematrix_y_final_dim - \l__nicematrix_y_initial_dim , + \l__nicematrix_x_final_dim - \l__nicematrix_x_initial_dim + ) + } + \pgftransformrotate { \fp_use:N \l_tmpa_fp } + \bool_if:NF \l__nicematrix_xdots_h_labels_bool { \fp_zero:N \l_tmpa_fp } + \tl_if_empty:NF \l__nicematrix_xdots_middle_tl + { + \begin { pgfscope } + \pgfset { inner~sep = \c__nicematrix_innersep_middle_dim } + \pgfnode + { rectangle } + { center } + { + \rotatebox { \fp_eval:n { - \l_tmpa_fp } } + { + \c_math_toggle_token + \scriptstyle \l__nicematrix_xdots_middle_tl + \c_math_toggle_token + } + } + { } + { + \pgfsetfillcolor { white } + \pgfusepath { fill } + } + \end { pgfscope } + } + \tl_if_empty:NF \l__nicematrix_xdots_up_tl + { + \pgfnode + { rectangle } + { south } + { + \rotatebox { \fp_eval:n { - \l_tmpa_fp } } + { + \c_math_toggle_token + \scriptstyle \l__nicematrix_xdots_up_tl + \c_math_toggle_token + } + } + { } + { \pgfusepath { } } + } + \tl_if_empty:NF \l__nicematrix_xdots_down_tl + { + \pgfnode + { rectangle } + { north } + { + \rotatebox { \fp_eval:n { - \l_tmpa_fp } } + { + \c_math_toggle_token + \scriptstyle \l__nicematrix_xdots_down_tl + \c_math_toggle_token + } + } + { } + { \pgfusepath { } } + } + \endpgfscope + } \hook_gput_code:nnn { begindocument } { . } { - \tl_set:Nn \l__nicematrix_argspec_tl { O { } E { _ ^ } { { } { } } } + \tl_set:Nn \l__nicematrix_argspec_tl { m E { _ ^ : } { { } { } { } } } \tl_set_rescan:Nno \l__nicematrix_argspec_tl { } \l__nicematrix_argspec_tl - \exp_args:NNV \NewDocumentCommand \__nicematrix_Ldots \l__nicematrix_argspec_tl + \cs_new_protected:Npn \__nicematrix_Ldots + { \__nicematrix_collect_options:n { \__nicematrix_Ldots_i } } + \exp_args:NNV \NewDocumentCommand \__nicematrix_Ldots_i \l__nicematrix_argspec_tl { \int_compare:nNnTF \c@jCol = 0 { \__nicematrix_error:nn { in~first~col } \Ldots } @@ -4646,14 +4798,16 @@ { \__nicematrix_error:nn { in~last~col } \Ldots } { \__nicematrix_instruction_of_type:nnn \c_false_bool { Ldots } - { #1 , down = #2 , up = #3 } + { #1 , down = #2 , up = #3 , middle = #4 } } } \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom { \ensuremath { \__nicematrix_old_ldots } } } \bool_gset_true:N \g__nicematrix_empty_cell_bool } - \exp_args:NNV \NewDocumentCommand \__nicematrix_Cdots \l__nicematrix_argspec_tl + \cs_new_protected:Npn \__nicematrix_Cdots + { \__nicematrix_collect_options:n { \__nicematrix_Cdots_i } } + \exp_args:NNV \NewDocumentCommand \__nicematrix_Cdots_i \l__nicematrix_argspec_tl { \int_compare:nNnTF \c@jCol = 0 { \__nicematrix_error:nn { in~first~col } \Cdots } @@ -4662,14 +4816,16 @@ { \__nicematrix_error:nn { in~last~col } \Cdots } { \__nicematrix_instruction_of_type:nnn \c_false_bool { Cdots } - { #1 , down = #2 , up = #3 } + { #1 , down = #2 , up = #3 , middle = #4 } } } \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom { \ensuremath { \__nicematrix_old_cdots } } } \bool_gset_true:N \g__nicematrix_empty_cell_bool } - \exp_args:NNV \NewDocumentCommand \__nicematrix_Vdots \l__nicematrix_argspec_tl + \cs_new_protected:Npn \__nicematrix_Vdots + { \__nicematrix_collect_options:n { \__nicematrix_Vdots_i } } + \exp_args:NNV \NewDocumentCommand \__nicematrix_Vdots_i \l__nicematrix_argspec_tl { \int_compare:nNnTF \c@iRow = 0 { \__nicematrix_error:nn { in~first~row } \Vdots } @@ -4678,14 +4834,16 @@ { \__nicematrix_error:nn { in~last~row } \Vdots } { \__nicematrix_instruction_of_type:nnn \c_false_bool { Vdots } - { #1 , down = #2 , up = #3 } + { #1 , down = #2 , up = #3 , middle = #4 } } } \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom { \ensuremath { \__nicematrix_old_vdots } } } \bool_gset_true:N \g__nicematrix_empty_cell_bool } - \exp_args:NNV \NewDocumentCommand \__nicematrix_Ddots \l__nicematrix_argspec_tl + \cs_new_protected:Npn \__nicematrix_Ddots + { \__nicematrix_collect_options:n { \__nicematrix_Ddots_i } } + \exp_args:NNV \NewDocumentCommand \__nicematrix_Ddots_i \l__nicematrix_argspec_tl { \int_case:nnF \c@iRow { @@ -4701,7 +4859,7 @@ { \keys_set_known:nn { NiceMatrix / Ddots } { #1 } \__nicematrix_instruction_of_type:nnn \l__nicematrix_draw_first_bool { Ddots } - { #1 , down = #2 , up = #3 } + { #1 , down = #2 , up = #3 , middle = #4 } } } @@ -4709,7 +4867,9 @@ { \phantom { \ensuremath { \__nicematrix_old_ddots } } } \bool_gset_true:N \g__nicematrix_empty_cell_bool } - \exp_args:NNV \NewDocumentCommand \__nicematrix_Iddots \l__nicematrix_argspec_tl + \cs_new_protected:Npn \__nicematrix_Iddots + { \__nicematrix_collect_options:n { \__nicematrix_Iddots_i } } + \exp_args:NNV \NewDocumentCommand \__nicematrix_Iddots_i \l__nicematrix_argspec_tl { \int_case:nnF \c@iRow { @@ -4725,7 +4885,7 @@ { \keys_set_known:nn { NiceMatrix / Ddots } { #1 } \__nicematrix_instruction_of_type:nnn \l__nicematrix_draw_first_bool { Iddots } - { #1 , down = #2 , up = #3 } + { #1 , down = #2 , up = #3 , middle = #4 } } } \bool_if:NF \l__nicematrix_nullify_dots_bool @@ -4765,9 +4925,11 @@ } \hook_gput_code:nnn { begindocument } { . } { - \tl_set:Nn \l__nicematrix_argspec_tl { O { } m O { } E { _ ^ } { { } { } } } + \tl_set:Nn \l__nicematrix_argspec_tl { m m O { } E { _ ^ : } { { } { } { } } } \tl_set_rescan:Nno \l__nicematrix_argspec_tl { } \l__nicematrix_argspec_tl - \exp_args:NNV \NewDocumentCommand \__nicematrix_Hdotsfor_i \l__nicematrix_argspec_tl + \cs_new_protected:Npn \__nicematrix_Hdotsfor_i + { \__nicematrix_collect_options:n { \__nicematrix_Hdotsfor_ii } } + \exp_args:NNV \NewDocumentCommand \__nicematrix_Hdotsfor_ii \l__nicematrix_argspec_tl { \tl_gput_right:Nx \g__nicematrix_HVdotsfor_lines_tl { @@ -4778,7 +4940,8 @@ { #1 , #3 , down = \exp_not:n { #4 } , - up = \exp_not:n { #5 } + up = \exp_not:n { #5 } , + middle = \exp_not:n { #6 } } } \prg_replicate:nn { #2 - 1 } { & \multicolumn { 1 } { c } { } } @@ -4827,12 +4990,16 @@ } } \group_begin: + + \__nicematrix_open_shorten: + \int_compare:nNnTF { #1 } = 0 { \color { nicematrix-first-row } } { \int_compare:nNnT { #1 } = \g__nicematrix_row_total_int { \color { nicematrix-last-row } } } + \keys_set:nn { NiceMatrix / xdots } { #4 } \tl_if_empty:VF \l__nicematrix_xdots_color_tl { \color { \l__nicematrix_xdots_color_tl } } \__nicematrix_actually_draw_Ldots: @@ -4842,9 +5009,11 @@ } \hook_gput_code:nnn { begindocument } { . } { - \tl_set:Nn \l__nicematrix_argspec_tl { O { } m O { } E { _ ^ } { { } { } } } + \tl_set:Nn \l__nicematrix_argspec_tl { m m O { } E { _ ^ : } { { } { } { } } } \tl_set_rescan:Nno \l__nicematrix_argspec_tl { } \l__nicematrix_argspec_tl - \exp_args:NNV \NewDocumentCommand \__nicematrix_Vdotsfor: \l__nicematrix_argspec_tl + \cs_new_protected:Npn \__nicematrix_Vdotsfor: + { \__nicematrix_collect_options:n { \__nicematrix_Vdotsfor_i } } + \exp_args:NNV \NewDocumentCommand \__nicematrix_Vdotsfor_i \l__nicematrix_argspec_tl { \bool_gset_true:N \g__nicematrix_empty_cell_bool \tl_gput_right:Nx \g__nicematrix_HVdotsfor_lines_tl @@ -4855,7 +5024,9 @@ { #2 } { #1 , #3 , - down = \exp_not:n { #4 } , up = \exp_not:n { #5 } + down = \exp_not:n { #4 } , + up = \exp_not:n { #5 } , + middle = \exp_not:n { #6 } } } } @@ -4903,6 +5074,8 @@ } } \group_begin: + \__nicematrix_open_shorten: + \int_compare:nNnTF { #2 } = 0 { \color { nicematrix-first-col } } { @@ -4918,8 +5091,11 @@ } \NewDocumentCommand \__nicematrix_rotate: { O { } } { - \bool_gset_true:N \g__nicematrix_rotate_bool - \keys_set:nn { NiceMatrix / rotate } { #1 } + \peek_remove_spaces:n + { + \bool_gset_true:N \g__nicematrix_rotate_bool + \keys_set:nn { NiceMatrix / rotate } { #1 } + } } \keys_define:nn { NiceMatrix / rotate } { @@ -4937,7 +5113,7 @@ { \int_eval:n { #1 } - \int_eval:n { #2 } } \hook_gput_code:nnn { begindocument } { . } { - \tl_set:Nn \l__nicematrix_argspec_tl { O { } m m ! O { } E { _ ^ } { { } { } } } + \tl_set:Nn \l__nicematrix_argspec_tl { O { } m m ! O { } E { _ ^ : } { { } { } { } } } \tl_set_rescan:Nno \l__nicematrix_argspec_tl { } \l__nicematrix_argspec_tl \exp_args:NNV \NewDocumentCommand \__nicematrix_line \l__nicematrix_argspec_tl { @@ -5112,12 +5288,11 @@ } \cs_generate_variant:Nn \__nicematrix_add_to_colors_seq:nn { x n } \cs_generate_variant:Nn \__nicematrix_add_to_colors_seq:nn { x x } -\cs_new_protected:Npn \__nicematrix_actually_color: +\cs_new_protected:Npn \__nicematrix_clip_with_rounded_corners: { - \pgfpicture - \pgf@relevantforpicturesizefalse \dim_compare:nNnT \l__nicematrix_tab_rounded_corners_dim > \c_zero_dim { + \group_begin: \pgfsetcornersarced { \pgfpoint @@ -5154,7 +5329,14 @@ } } \pgfusepath { clip } + \group_end: } + } +\cs_new_protected:Npn \__nicematrix_actually_color: + { + \pgfpicture + \pgf@relevantforpicturesizefalse + \__nicematrix_clip_with_rounded_corners: \seq_map_indexed_inline:Nn \g__nicematrix_colors_seq { \begin { pgfscope } @@ -5480,7 +5662,8 @@ \tl_gput_right:Nx \g__nicematrix_pre_code_before_tl { \__nicematrix_rowlistcolors - [ #1 ] { \int_use:N \c@iRow } { #2 } [ restart, #3 ] + [ #1 ] { \int_use:N \c@iRow } { #2 } + [ restart, cols = \int_use:N \c@jCol - , #3 ] } } } @@ -5812,7 +5995,6 @@ } \cs_new_protected:Npn \__nicematrix_hline_ii: { - % \bool_set_false:N \l__nicematrix_dotted_bool \keys_set:nV { NiceMatrix / RulesBis } \l__nicematrix_other_keys_tl \bool_if:NTF \l__nicematrix_dotted_bool \__nicematrix_hline_iv: @@ -5981,6 +6163,7 @@ \str_clear_new:N \l__nicematrix_command_str \str_clear_new:N \l__nicematrix_ccommand_str \str_clear_new:N \l__nicematrix_letter_str + \tl_clear_new:N \l__nicematrix_other_keys_tl \keys_set_known:nnN { NiceMatrix / custom-line } { #1 } \l__nicematrix_other_keys_tl \bool_lazy_all:nTF { @@ -6096,7 +6279,6 @@ } \seq_put_left:NV \l__nicematrix_custom_line_commands_seq \l__nicematrix_command_str } -\cs_generate_variant:Nn \__nicematrix_h_custom_line:nn { n V } \cs_new_protected:Npn \__nicematrix_c_custom_line:n #1 { \exp_args:Nc \NewExpandableDocumentCommand @@ -6131,7 +6313,6 @@ } } } -\cs_generate_variant:Nn \__nicematrix_c_custom_line:nn { n V } \cs_new_protected:Npn \__nicematrix_compute_rule_width:n #1 { \bool_set_false:N \l__nicematrix_tikz_rule_bool @@ -6367,6 +6548,7 @@ } \iow_shipout:Nn \@mainaux \ExplSyntaxOff } + \ignorespacesafterend } \cs_generate_variant:Nn \dim_min:nn { v n } \cs_generate_variant:Nn \dim_max:nn { v n } @@ -6580,24 +6762,24 @@ C .value_forbidden:n = true , t .code:n = \str_set:Nn \l__nicematrix_vpos_of_block_str t , t .value_forbidden:n = true , + T .code:n = \str_set:Nn \l__nicematrix_vpos_of_block_str T , + T .value_forbidden:n = true , b .code:n = \str_set:Nn \l__nicematrix_vpos_of_block_str b , b .value_forbidden:n = true , - color .tl_set:N = \l__nicematrix_color_tl , + B .code:n = \str_set:Nn \l__nicematrix_vpos_of_block_str B , + B .value_forbidden:n = true , + color .code:n = + \__nicematrix_color:n { #1 } + \tl_set_rescan:Nnn + \l__nicematrix_draw_tl + { \char_set_catcode_other:N ! } + { #1 } , color .value_required:n = true , respect-arraystretch .bool_set:N = \l__nicematrix_respect_arraystretch_bool , - respect-arraystretch .default:n = true , + respect-arraystretch .default:n = true } -\cs_new_protected:Npn \__nicematrix_block:n #1 - { - \peek_meaning:NTF [ - { \__nicematrix_block_i:n { #1 } } - { \__nicematrix_Block_i:[#1] } - } - -\cs_new_protected:Npn \__nicematrix_block_i:n #1[#2] { \__nicematrix_block:n {#1,#2} } - -\cs_new_protected:Npn \__nicematrix_Block: { \__nicematrix_block:n { } } -\NewExpandableDocumentCommand \__nicematrix_Block_i: { O { } m D < > { } +m } +\cs_new_protected:Npn \__nicematrix_Block: { \__nicematrix_collect_options:n { \__nicematrix_Block_i: } } +\NewExpandableDocumentCommand \__nicematrix_Block_i: { m m D < > { } +m } { \peek_remove_spaces:n { @@ -6690,12 +6872,11 @@ } \g__nicematrix_row_style_tl } - \group_begin: \bool_if:NF \l__nicematrix_respect_arraystretch_bool { \cs_set:Npn \arraystretch { 1 } } \dim_zero:N \extrarowheight #4 - \bool_if:NT \g__nicematrix_rotate_bool { \str_set:Nn \l__nicematrix_hpos_block_str c } + \__nicematrix_adjust_hpos_rotate: \bool_if:NTF \l__nicematrix_tabular_bool { \bool_lazy_all:nTF @@ -6711,11 +6892,7 @@ [ \str_lowercase:V { \l__nicematrix_vpos_of_block_str } ] { \l__nicematrix_col_width_dim } \str_case:Vn \l__nicematrix_hpos_block_str - { - c \centering - r \raggedleft - l \raggedright - } + { c \centering r \raggedleft l \raggedright } } #5 \end { minipage } @@ -6743,29 +6920,8 @@ \end { array } \c_math_toggle_token } - \group_end: - } - \bool_if:NT \g__nicematrix_rotate_bool - { - \box_grotate:cn - { g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box } - { 90 } - \bool_if:NT \g__nicematrix_rotate_c_bool - { - \hbox_gset:cn - { g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box } - { - \c_math_toggle_token - \vcenter - { - \box_use:c - { g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box } - } - \c_math_toggle_token - } - } - \bool_gset_false:N \g__nicematrix_rotate_bool } + \bool_if:NT \g__nicematrix_rotate_bool \__nicematrix_rotate_box_of_block: \int_compare:nNnT { #2 } = 1 { \dim_gset:Nn \g__nicematrix_blocks_wd_dim @@ -6805,7 +6961,13 @@ { \exp_not:n { #3 } , \l__nicematrix_hpos_block_str , - \bool_if:NT \g__nicematrix_rotate_c_bool { v-center } + \bool_if:NT \g__nicematrix_rotate_bool + { + \bool_if:NTF \g__nicematrix_rotate_c_bool + { v-center } + { \int_compare:nNnT \c@iRow = \l__nicematrix_last_row_int T } + } + } { \box_use_drop:c @@ -6814,6 +6976,52 @@ } \bool_set_false:N \g__nicematrix_rotate_c_bool } +\cs_new:Npn \__nicematrix_adjust_hpos_rotate: + { + \bool_if:NT \g__nicematrix_rotate_bool + { + \str_set:Nx \l__nicematrix_hpos_block_str + { + \bool_if:NTF \g__nicematrix_rotate_c_bool + { c } + { + \str_case:VnF \l__nicematrix_vpos_of_block_str + { b l B l t r T r } + { \int_compare:nNnTF \c@iRow = \l__nicematrix_last_row_int r l } + } + } + } + } +\cs_new_protected:Npn \__nicematrix_rotate_box_of_block: + { + \box_grotate:cn + { g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box } + { 90 } + \int_compare:nNnT \c@iRow = \l__nicematrix_last_row_int + { + \vbox_gset_top:cn + { g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box } + { + \skip_vertical:n { 0.8 ex } + \box_use:c + { g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box } + } + } + \bool_if:NT \g__nicematrix_rotate_c_bool + { + \hbox_gset:cn + { g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box } + { + \c_math_toggle_token + \vcenter + { + \box_use:c + { g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box } + } + \c_math_toggle_token + } + } + } \cs_new_protected:Npn \__nicematrix_Block_v:nnnnn #1 #2 #3 #4 #5 { \seq_gput_right:Nx \g__nicematrix_blocks_seq @@ -6830,8 +7038,7 @@ { \dim_zero:N \extrarowheight #4 - \bool_if:NT \g__nicematrix_rotate_bool - { \str_set:Nn \l__nicematrix_hpos_block_str c } + % \__nicematrix_adjust_hpos_rotate: \use:x { \exp_not:N \begin { tabular } [ \l__nicematrix_vpos_of_block_str ] @@ -6850,9 +7057,8 @@ { \dim_zero:N \extrarowheight #4 - \bool_if:NT \g__nicematrix_rotate_bool - { \str_set:Nn \l__nicematrix_hpos_block_str c } - \c_math_toggle_token + % \__nicematrix_adjust_hpos_rotate: + \c_math_toggle_token % :n c \use:x { \exp_not:N \begin { array } [ \l__nicematrix_vpos_of_block_str ] @@ -6880,6 +7086,8 @@ { \char_set_catcode_other:N ! } { #1 } , fill .value_required:n = true , + opacity .tl_set:N = \l__nicematrix_opacity_tl , + opacity .value_required:n = true , draw .code:n = \tl_set_rescan:Nnn \l__nicematrix_draw_tl @@ -6894,7 +7102,6 @@ \l__nicematrix_draw_tl { \char_set_catcode_other:N ! } { #1 } , - color .value_required:n = true , borders .clist_set:N = \l__nicematrix_borders_clist , borders .value_required:n = true , hvlines .meta:n = { vlines , hlines } , @@ -6905,35 +7112,24 @@ line-width .dim_set:N = \l__nicematrix_line_width_dim , line-width .value_required:n = true , l .code:n = \str_set:Nn \l__nicematrix_hpos_block_str l , - l .value_forbidden:n = true , r .code:n = \str_set:Nn \l__nicematrix_hpos_block_str r , - r .value_forbidden:n = true , c .code:n = \str_set:Nn \l__nicematrix_hpos_block_str c , - c .value_forbidden:n = true , L .code:n = \str_set:Nn \l__nicematrix_hpos_block_str l \bool_set_true:N \l__nicematrix_hpos_of_block_cap_bool , - L .value_forbidden:n = true , R .code:n = \str_set:Nn \l__nicematrix_hpos_block_str r \bool_set_true:N \l__nicematrix_hpos_of_block_cap_bool , - R .value_forbidden:n = true , C .code:n = \str_set:Nn \l__nicematrix_hpos_block_str c \bool_set_true:N \l__nicematrix_hpos_of_block_cap_bool , - C .value_forbidden:n = true , t .code:n = \str_set:Nn \l__nicematrix_vpos_of_block_str t , - t .value_forbidden:n = true , T .code:n = \str_set:Nn \l__nicematrix_vpos_of_block_str T , - T .value_forbidden:n = true , b .code:n = \str_set:Nn \l__nicematrix_vpos_of_block_str b , - b .value_forbidden:n = true , B .code:n = \str_set:Nn \l__nicematrix_vpos_of_block_str B , - B .value_forbidden:n = true , v-center .code:n = \str_set:Nn \l__nicematrix_vpos_of_block_str { c } , v-center .value_forbidden:n = true , name .tl_set:N = \l__nicematrix_block_name_str , name .value_required:n = true , name .initial:n = , respect-arraystretch .bool_set:N = \l__nicematrix_respect_arraystretch_bool , - respect-arraystretch .default:n = true , transparent .bool_set:N = \l__nicematrix_transparent_bool , transparent .default:n = true , transparent .initial:n = false , @@ -7034,6 +7230,21 @@ } \tl_if_empty:NF \l__nicematrix_fill_tl { + \tl_if_empty:NF \l__nicematrix_opacity_tl + { + \tl_if_head_eq_meaning:nNTF \l__nicematrix_fill_tl [ + { + \tl_set:Nx \l__nicematrix_fill_tl + { + [ opacity = \l__nicematrix_opacity_tl , + \tl_tail:V \l__nicematrix_fill_tl + } + } + { + \tl_set:Nx \l__nicematrix_fill_tl + { [ opacity = \l__nicematrix_opacity_tl ] { \l__nicematrix_fill_tl } } + } + } \tl_gput_right:Nx \g__nicematrix_pre_code_before_tl { \exp_not:N \roundedrectanglecolor @@ -7162,8 +7373,7 @@ { \str_if_eq_p:Vn \l__nicematrix_vpos_of_block_str { B } } } { - \int_compare:nNnT { #2 } = 0 - { \str_set:Nn \l__nicematrix_hpos_block_str r } + \int_compare:nNnT { #2 } = 0 { \str_set:Nn \l__nicematrix_hpos_block_str r } \bool_if:nT \g__nicematrix_last_col_found_bool { \int_compare:nNnT { #2 } = \g__nicematrix_col_total_int @@ -7279,8 +7489,8 @@ \pgfsetcornersarced { \pgfpoint - { \dim_use:N \l__nicematrix_rounded_corners_dim } - { \dim_use:N \l__nicematrix_rounded_corners_dim } + { \l__nicematrix_rounded_corners_dim } + { \l__nicematrix_rounded_corners_dim } } \__nicematrix_cut_on_hyphen:w #2 \q_stop \bool_lazy_and:nnT @@ -7288,22 +7498,22 @@ { \int_compare_p:n { \l_tmpb_tl <= \c@jCol } } { \__nicematrix_qpoint:n { row - \l_tmpa_tl } - \dim_set:Nn \l_tmpb_dim { \pgf@y } + \dim_set_eq:NN \l_tmpb_dim \pgf@y \__nicematrix_qpoint:n { col - \l_tmpb_tl } - \dim_set:Nn \l__nicematrix_tmpc_dim { \pgf@x } + \dim_set_eq:NN \l__nicematrix_tmpc_dim \pgf@x \__nicematrix_cut_on_hyphen:w #3 \q_stop \int_compare:nNnT \l_tmpa_tl > \c@iRow { \tl_set:Nx \l_tmpa_tl { \int_use:N \c@iRow } } \int_compare:nNnT \l_tmpb_tl > \c@jCol { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } } \__nicematrix_qpoint:n { row - \int_eval:n { \l_tmpa_tl + 1 } } - \dim_set:Nn \l_tmpa_dim { \pgf@y } + \dim_set_eq:NN \l_tmpa_dim \pgf@y \__nicematrix_qpoint:n { col - \int_eval:n { \l_tmpb_tl + 1 } } - \dim_set:Nn \l__nicematrix_tmpd_dim { \pgf@x } + \dim_set_eq:NN \l__nicematrix_tmpd_dim \pgf@x + \pgfsetlinewidth { 1.1 \l__nicematrix_line_width_dim } \pgfpathrectanglecorners { \pgfpoint \l__nicematrix_tmpc_dim \l_tmpb_dim } { \pgfpoint \l__nicematrix_tmpd_dim \l_tmpa_dim } - \pgfsetlinewidth { 1.1 \l__nicematrix_line_width_dim } \dim_compare:nNnTF \l__nicematrix_rounded_corners_dim = \c_zero_dim { \pgfusepathqstroke } { \pgfusepath { stroke } } @@ -7364,7 +7574,7 @@ position = ##1 , start = \l__nicematrix_tmpd_tl , end = \int_eval:n { \l_tmpb_tl - 1 } , - total-width = \dim_use:N \l__nicematrix_line_width_dim % added 2022-08-06 + total-width = \dim_use:N \l__nicematrix_line_width_dim } } } @@ -7474,6 +7684,7 @@ \cs_new_protected:Npn \__nicematrix_block_tikz:nnnnn #1 #2 #3 #4 #5 { \begin { tikzpicture } + \__nicematrix_clip_with_rounded_corners: \clist_map_inline:nn { #5 } { \path [ ##1 ] @@ -7659,6 +7870,7 @@ delimiters / color .value_required:n = true , rules .code:n = \keys_set:nn { NiceMatrix / rules } { #1 } , rules .value_required:n = true , + xdots .code:n = \keys_set:nn { NiceMatrix / xdots } { #1 } , unknown .code:n = \__nicematrix_error:n { Unknown~key~for~CodeAfter } } \cs_new:Npn \__nicematrix_CodeAfter: { \omit \__nicematrix_CodeAfter_ii:n } @@ -8460,8 +8672,8 @@ } } } -\bool_new:N \c__nicematrix_footnotehyper_bool -\bool_new:N \c__nicematrix_footnote_bool +\bool_new:N \g__nicematrix_footnotehyper_bool +\bool_new:N \g__nicematrix_footnote_bool \msg_new:nnnn { nicematrix } { Unknown~key~for~package } { The~key~'\l_keys_key_str'~is~unknown. \\ @@ -8483,10 +8695,10 @@ renew-dots .value_forbidden:n = true , renew-matrix .code:n = \__nicematrix_renew_matrix: , renew-matrix .value_forbidden:n = true , - messages-for-Overleaf .bool_set:N = \c__nicematrix_messages_for_Overleaf_bool , - footnote .bool_set:N = \c__nicematrix_footnote_bool , - footnotehyper .bool_set:N = \c__nicematrix_footnotehyper_bool , - no-test-for-array .bool_set:N = \c__nicematrix_no_test_for_array_bool , + messages-for-Overleaf .bool_set:N = \g__nicematrix_messages_for_Overleaf_bool , + footnote .bool_set:N = \g__nicematrix_footnote_bool , + footnotehyper .bool_set:N = \g__nicematrix_footnotehyper_bool , + no-test-for-array .bool_set:N = \g__nicematrix_no_test_for_array_bool , no-test-for-array .default:n = true , unknown .code:n = \__nicematrix_error:n { Unknown~key~for~package } } @@ -8509,26 +8721,26 @@ of~the~package~footnote.\\ The~package~footnotehyper~won't~be~loaded. } -\bool_if:NT \c__nicematrix_footnote_bool +\bool_if:NT \g__nicematrix_footnote_bool { \IfClassLoadedTF { beamer } - { \bool_set_false:N \c__nicematrix_footnote_bool } + { \bool_set_false:N \g__nicematrix_footnote_bool } { \IfPackageLoadedTF { footnotehyper } { \__nicematrix_error:n { footnote~with~footnotehyper~package } } { \usepackage { footnote } } } } -\bool_if:NT \c__nicematrix_footnotehyper_bool +\bool_if:NT \g__nicematrix_footnotehyper_bool { \IfClassLoadedTF { beamer } - { \bool_set_false:N \c__nicematrix_footnote_bool } + { \bool_set_false:N \g__nicematrix_footnote_bool } { \IfPackageLoadedTF { footnote } { \__nicematrix_error:n { footnotehyper~with~footnote~package } } { \usepackage { footnotehyper } } } - \bool_set_true:N \c__nicematrix_footnote_bool + \bool_set_true:N \g__nicematrix_footnote_bool } \bool_new:N \l__nicematrix_underscore_loaded_bool \IfPackageLoadedTF { underscore } @@ -8543,7 +8755,7 @@ { } } } -\bool_if:NTF \c__nicematrix_messages_for_Overleaf_bool +\bool_if:NTF \g__nicematrix_messages_for_Overleaf_bool { \str_const:Nn \c__nicematrix_available_keys_str { } } { \str_const:Nn \c__nicematrix_available_keys_str @@ -8599,6 +8811,12 @@ \tl_if_empty:VF \g__nicematrix_HVdotsfor_lines_tl { ~Maybe~your~use~of~\token_to_str:N \Hdotsfor\ is~incorrect.} } +\__nicematrix_msg_new:nn { hvlines,~rounded-corners~and~corners } + { + Incompatible~options.\\ + You~should~not~use~'hvlines',~'rounded-corners'~and~'corners'~at~this~time.\\ + The~output~will~not~be~reliable. + } \__nicematrix_msg_new:nn { negative~weight } { Negative~weight.\\ @@ -8657,7 +8875,7 @@ The~preamble~of~your~\__nicematrix_full_name_env:\ announces~\int_use:N \g__nicematrix_static_num_of_col_int\ columns~but~you~use~only~\int_use:N \c@jCol.\\ The~columns~you~did~not~used~won't~be~created.\\ - We~won't~have~similar~error~till~the~end~of~the~document. + You~won't~have~similar~error~till~the~end~of~the~document. } \__nicematrix_msg_new:nn { in~first~col } { @@ -8926,7 +9144,7 @@ The~name~'#1'~is~already~used~for~a~\token_to_str:N \SubMatrix\ in~this~\__nicematrix_full_name_env:.\\ This~key~will~be~ignored.\\ - \bool_if:NF \c__nicematrix_messages_for_Overleaf_bool + \bool_if:NF \g__nicematrix_messages_for_Overleaf_bool { For~a~list~of~the~names~already~used,~type~H~<return>. } } { @@ -8984,7 +9202,7 @@ \__nicematrix_msg_new:nn { last-col~non~empty~for~NiceMatrixOptions } { Erroneous~use.\\ - In~\NiceMatrixoptions,~you~must~use~the~key~ + In~\token_to_str:N \NiceMatrixOptions,~you~must~use~the~key~ 'last-col'~without~value.\\ However,~you~can~go~on~for~this~time~ (the~value~'\l_keys_value_tl'~will~be~ignored). @@ -9142,8 +9360,8 @@ } { The~available~keys~are~(in~alphabetic~order):~b,~B,~borders,~c,~draw,~fill,~ - hlines,~hvlines,~l,~line-width,~name,~rounded-corners,~r,~respect-arraystretch,~ - t,~T,~tikz,~transparent~and~vlines. + hlines,~hvlines,~l,~line-width,~name,~opacity,~rounded-corners,~r,~ + respect-arraystretch,~t,~T,~tikz,~transparent~and~vlines. } \__nicematrix_msg_new:nn { Version~of~siunitx~too~old } { @@ -9485,7 +9703,7 @@ if~you~use~'columns-width=auto'.~If~you~don't~want~to~see~this~ message~again,~use~the~key~'allow-duplicate-names'~in~ '\token_to_str:N \NiceMatrixOptions'.\\ - \bool_if:NF \c__nicematrix_messages_for_Overleaf_bool + \bool_if:NF \g__nicematrix_messages_for_Overleaf_bool { For~a~list~of~the~names~already~used,~type~H~<return>. } } { |