diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty | 255 |
1 files changed, 137 insertions, 118 deletions
diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty index c50867a21dd..2a006ddef02 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.1} -\def\myfiledate{2021/08/20} +\def\myfileversion{6.2} +\def\myfiledate{2021/09/09} \RequirePackage{pgfcore} \usepgfmodule{shapes} \RequirePackage{l3keys2e} @@ -46,6 +46,7 @@ \bool_new:N \c__nicematrix_arydshln_loaded_bool \bool_new:N \c__nicematrix_booktabs_loaded_bool \bool_new:N \c__nicematrix_enumitem_loaded_bool +\bool_new:N \c__nicematrix_tabularx_loaded_bool \bool_new:N \c__nicematrix_tikz_loaded_bool \AtBeginDocument { @@ -58,6 +59,9 @@ \@ifpackageloaded { enumitem } { \bool_set_true:N \c__nicematrix_enumitem_loaded_bool } { } + \@ifpackageloaded { tabularx } + { \bool_set_true:N \c__nicematrix_tabularx_loaded_bool } + { } \@ifpackageloaded { tikz } { \bool_set_true:N \c__nicematrix_tikz_loaded_bool @@ -168,8 +172,16 @@ } \cs_set:Npn \__nicematrix_cline { \__nicematrix_cline_i:en \l__nicematrix_first_col_int } -\cs_set:Npn \__nicematrix_cline_i:nn #1 #2 { \__nicematrix_cline_i:w #1-#2 \q_stop } -\cs_set:Npn \__nicematrix_cline_i:w #1-#2-#3 \q_stop +\cs_set:Npn \__nicematrix_cline_i:nn #1 #2 { \__nicematrix_cline_i:w #1|#2- \q_stop } +\cs_set:Npn \__nicematrix_cline_i:w #1|#2-#3 \q_stop + { + \tl_if_empty:nTF { #3 } + { \__nicematrix_cline_iii:w #1|#2-#2 \q_stop } + { \__nicematrix_cline_ii:w #1|#2-#3 \q_stop } + } +\cs_set:Npn \__nicematrix_cline_ii:w #1|#2-#3-\q_stop + { \__nicematrix_cline_iii:w #1|#2-#3 \q_stop } +\cs_set:Npn \__nicematrix_cline_iii:w #1|#2-#3 \q_stop { \int_compare:nNnT { #1 } < { #2 } { \multispan { \int_eval:n { #2 - #1 } } & } @@ -347,6 +359,8 @@ \clist_new:N \l__nicematrix_vlines_clist \clist_new:N \l__nicematrix_submatrix_hlines_clist \clist_new:N \l__nicematrix_submatrix_vlines_clist +\bool_new:N \l__nicematrix_dotted_bool +\dim_new:N \l__nicematrix_trim_dim \int_new:N \l__nicematrix_first_row_int \int_set:Nn \l__nicematrix_first_row_int 1 \int_new:N \l__nicematrix_first_col_int @@ -884,6 +898,7 @@ \c_math_toggle_token \bool_if:NT \l__nicematrix_small_bool \scriptstyle } + \color { nicematrix } \g__nicematrix_row_style_tl \int_compare:nNnTF \c@iRow = 0 { @@ -1065,27 +1080,15 @@ { \exp_not:n { #3 } } } } -\cs_new_protected:Npn \__nicematrix_revtex_array: - { - \cs_set_eq:NN \@acoll \@arrayacol - \cs_set_eq:NN \@acolr \@arrayacol - \cs_set_eq:NN \@acol \@arrayacol - \cs_set_nopar:Npn \@halignto { } - \@array@array - } \cs_new_protected:Npn \__nicematrix_array: { - \bool_if:NTF \c__nicematrix_revtex_bool - \__nicematrix_revtex_array: - { - \bool_if:NTF \l__nicematrix_NiceTabular_bool - { \dim_set_eq:NN \col@sep \tabcolsep } - { \dim_set_eq:NN \col@sep \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 } } - \@tabarray - } + \bool_if:NTF \l__nicematrix_NiceTabular_bool + { \dim_set_eq:NN \col@sep \tabcolsep } + { \dim_set_eq:NN \col@sep \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 } } + \@tabarray [ \str_if_eq:VnTF \l__nicematrix_baseline_tl c c t ] } \cs_set_eq:NN \__nicematrix_old_ialign: \ialign @@ -1167,6 +1170,7 @@ } \cs_new_protected:Npn \__nicematrix_pre_array_ii: { + \xglobal \colorlet { nicematrix } { . } \int_gzero:N \g__nicematrix_total_X_weight_int \bool_if:NT \c__nicematrix_booktabs_loaded_bool { \tl_put_left:Nn \@BTnormal \__nicematrix_create_row_node: } @@ -1285,6 +1289,7 @@ { \dim_max:nn \g__nicematrix_dp_last_row_dim { \box_dp:N \l__nicematrix_cell_box } } } } + \seq_gclear:N \g__nicematrix_cols_vlism_seq \seq_gclear:N \g__nicematrix_submatrix_seq \bool_if:NT \l__nicematrix_code_before_bool \__nicematrix_exec_code_before: \seq_gclear:N \g__nicematrix_pos_of_blocks_seq @@ -1468,9 +1473,26 @@ } \__nicematrix_create_extra_nodes: } +\cs_new_protected:Npn \__nicematrix_patch_for_revtex: + { + \cs_set_eq:NN \@addamp \@addamp@LaTeX + \cs_set_eq:NN \insert@column \insert@column@array + \cs_set_eq:NN \@classx \@classx@array + \cs_set_eq:NN \@xarraycr \@xarraycr@array + \cs_set_eq:NN \@arraycr \@arraycr@array + \cs_set_eq:NN \@xargarraycr \@xargarraycr@array + \cs_set_eq:NN \array \array@array + \cs_set_eq:NN \@array \@array@array + \cs_set_eq:NN \@tabular \@tabular@array + \cs_set_eq:NN \@mkpream \@mkpream@array + \cs_set_eq:NN \endarray \endarray@array + \cs_set:Npn \@tabarray { \@ifnextchar [ { \@array } { \@array [ c ] } } + \cs_set:Npn \endtabular { \endarray $\egroup} % $ + } \NewDocumentEnvironment { NiceArrayWithDelims } { m m O { } m ! O { } t \CodeBefore } { + \bool_if:NT \c__nicematrix_revtex_bool \__nicematrix_patch_for_revtex: \__nicematrix_provide_pgfsyspdfmark: \bool_if:NT \c__nicematrix_footnote_bool \savenotes \bgroup @@ -1767,6 +1789,7 @@ ] { \__nicematrix_patch_preamble_viii:nn #1 } \} { \__nicematrix_patch_preamble_viii:nn #1 } X { \__nicematrix_patch_preamble_ix:n } + \__nicematrix_X { \__nicematrix_patch_preamble_ix:n } \q_stop { } } { @@ -2920,8 +2943,19 @@ \NiceArray { #2 } } { \endNiceArray } +\cs_set_protected:Npn \__nicematrix_newcolumntype #1 + { + \cs_if_free:cT { NC @ find @ #1 } + { \NC@list \expandafter { \the \NC@list \NC@do #1 } } + \cs_set:cpn {NC @ find @ #1 } ##1 #1 { \NC@ { ##1 } } + \peek_meaning:NTF [ + { \newcol@ #1 } + { \newcol@ #1 [ 0 ] } + } \NewDocumentEnvironment { NiceTabularX } { m O { } m ! O { } } { + \bool_if:NT \c__nicematrix_tabularx_loaded_bool + { \newcolumntype { X } { \__nicematrix_X } } \str_gset:Nn \g__nicematrix_name_env_str { NiceTabularX } \dim_zero_new:N \l__nicematrix_width_dim \dim_set:Nn \l__nicematrix_width_dim { #1 } @@ -3003,16 +3037,6 @@ \__nicematrix_draw_dotted_lines: \__nicematrix_compute_corners: \__nicematrix_adjust_pos_of_blocks_seq: - % \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_corners_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 - % } \tl_if_empty:NF \l__nicematrix_hlines_clist \__nicematrix_draw_hlines: \tl_if_empty:NF \l__nicematrix_vlines_clist \__nicematrix_draw_vlines: \cs_set_eq:NN \SubMatrix \__nicematrix_SubMatrix @@ -3342,9 +3366,9 @@ \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_min:nn \l__nicematrix_initial_j_int \l__nicematrix_final_j_int } { \int_use:N \l__nicematrix_final_i_int } - { \int_use:N \l__nicematrix_final_j_int } + { \int_max:nn \l__nicematrix_initial_j_int \l__nicematrix_final_j_int } } } \cs_new_protected:Npn \__nicematrix_adjust_to_submatrix:nn #1 #2 @@ -3749,22 +3773,22 @@ \pgf@relevantforpicturesizefalse \tl_if_eq:NNTF \l__nicematrix_xdots_line_style_tl \c__nicematrix_standard_tl \__nicematrix_draw_standard_dotted_line: - \__nicematrix_draw_non_standard_dotted_line: + \__nicematrix_draw_unstandard_dotted_line: } -\cs_new_protected:Npn \__nicematrix_draw_non_standard_dotted_line: +\cs_new_protected:Npn \__nicematrix_draw_unstandard_dotted_line: { \begin { scope } - \exp_args:No \__nicematrix_draw_non_standard_dotted_line:n + \exp_args:No \__nicematrix_draw_unstandard_dotted_line:n { \l__nicematrix_xdots_line_style_tl , \l__nicematrix_xdots_color_tl } } -\cs_new_protected:Npn \__nicematrix_draw_non_standard_dotted_line:n #1 +\cs_new_protected:Npn \__nicematrix_draw_unstandard_dotted_line:n #1 { - \__nicematrix_draw_non_standard_dotted_line:nVV + \__nicematrix_draw_unstandard_dotted_line:nVV { #1 } \l__nicematrix_xdots_up_tl \l__nicematrix_xdots_down_tl } -\cs_new_protected:Npn \__nicematrix_draw_non_standard_dotted_line:nnn #1 #2 #3 +\cs_new_protected:Npn \__nicematrix_draw_unstandard_dotted_line:nnn #1 #2 #3 { \draw [ @@ -3778,7 +3802,7 @@ ( \l__nicematrix_x_final_dim , \l__nicematrix_y_final_dim ) ; \end { scope } } -\cs_generate_variant:Nn \__nicematrix_draw_non_standard_dotted_line:nnn { n V V } +\cs_generate_variant:Nn \__nicematrix_draw_unstandard_dotted_line:nnn { n V V } \cs_new_protected:Npn \__nicematrix_draw_standard_dotted_line: { \bool_lazy_and:nnF @@ -4699,6 +4723,12 @@ } \cs_new_protected:Npn \__nicematrix_vline_ii:nnnn #1 #2 #3 #4 { + \bool_if:NTF \l__nicematrix_dotted_bool + { \__nicematrix_vline_iv:nnn { #1 } { #3 } { #4 } } + { \__nicematrix_vline_iii:nnnn { #1 } { #2 } { #3 } { #4 } } + } +\cs_new_protected:Npn \__nicematrix_vline_iii:nnnn #1 #2 #3 #4 + { \pgfrememberpicturepositiononpagetrue \pgf@relevantforpicturesizefalse \__nicematrix_qpoint:n { row - #3 } @@ -4710,7 +4740,7 @@ \bool_lazy_all:nT { { \int_compare_p:nNn { #2 } > 1 } - { \cs_if_exist_p:N \CT@drsc@ } % condition added in version 5.18a + { \cs_if_exist_p:N \CT@drsc@ } { ! \tl_if_blank_p:V \CT@drsc@ } } { @@ -4740,8 +4770,19 @@ \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_vline_iv:nnn #1 #2 #3 + { + \pgfrememberpicturepositiononpagetrue + \pgf@relevantforpicturesizefalse + \__nicematrix_qpoint:n { col - #1 } + \dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf@x + \dim_set_eq:NN \l__nicematrix_x_final_dim \pgf@x + \__nicematrix_qpoint:n { row - #2 } + \dim_set_eq:NN \l__nicematrix_y_initial_dim \pgf@y + \__nicematrix_qpoint:n { row - \__nicematrix_succ:n { #3 } } + \dim_set_eq:NN \l__nicematrix_y_final_dim \pgf@y + \__nicematrix_draw_line: + } \cs_new_protected:Npn \__nicematrix_draw_vlines: { \int_step_inline:nnn @@ -4837,6 +4878,12 @@ } \cs_new_protected:Npn \__nicematrix_hline_ii:nnnn #1 #2 #3 #4 { + \bool_if:NTF \l__nicematrix_dotted_bool + { \__nicematrix_hline_iv:nnn { #1 } { #3 } { #4 } } + { \__nicematrix_hline_iii:nnnn { #1 } { #2 } { #3 } { #4 } } + } +\cs_new_protected:Npn \__nicematrix_hline_iii:nnnn #1 #2 #3 #4 + { \pgfrememberpicturepositiononpagetrue \pgf@relevantforpicturesizefalse \__nicematrix_qpoint:n { col - #3 } @@ -4848,7 +4895,7 @@ \bool_lazy_all:nT { { \int_compare_p:nNn { #2 } > 1 } - { \cs_if_exist_p:N \CT@drsc@ } % condition added in version 6.0 + { \cs_if_exist_p:N \CT@drsc@ } { ! \tl_if_blank_p:V \CT@drsc@ } } { @@ -4876,8 +4923,35 @@ \pgfsetrectcap \pgfusepathqstroke } -\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_hline_iv:nnn #1 #2 #3 + { + \pgfrememberpicturepositiononpagetrue + \pgf@relevantforpicturesizefalse + \__nicematrix_qpoint:n { row - #1 } + \dim_set_eq:NN \l__nicematrix_y_initial_dim \pgf@y + \dim_set_eq:NN \l__nicematrix_y_final_dim \pgf@y + \__nicematrix_qpoint:n { col - #2 } + \dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf@x + \int_compare:nNnT { #2 } = 1 + { + \dim_sub:Nn \l__nicematrix_x_initial_dim \l__nicematrix_left_margin_dim + \bool_if:NT \l__nicematrix_NiceArray_bool + { \dim_sub:Nn \l__nicematrix_x_initial_dim \arraycolsep } + \tl_if_eq:NnF \g__nicematrix_left_delim_tl ( + { \dim_add:Nn \l__nicematrix_x_initial_dim { 0.5 \l__nicematrix_inter_dots_dim } } + } + \__nicematrix_qpoint:n { col - \__nicematrix_succ:n { #3 } } + \dim_set_eq:NN \l__nicematrix_x_final_dim \pgf@x + \int_compare:nNnT { #3 } = \c@jCol + { + \dim_add:Nn \l__nicematrix_x_final_dim \l__nicematrix_right_margin_dim + \bool_if:NT \l__nicematrix_NiceArray_bool + { \dim_add:Nn \l__nicematrix_x_final_dim \arraycolsep } + \tl_if_eq:NnF \g__nicematrix_right_delim_tl ) + { \dim_gsub:Nn \l__nicematrix_x_final_dim { 0.5 \l__nicematrix_inter_dots_dim } } + } + \__nicematrix_draw_line: + } \cs_new_protected:Npn \__nicematrix_draw_hlines: { \int_step_inline:nnn @@ -5081,74 +5155,19 @@ \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl { \__nicematrix_hdottedline:n { \int_use:N \c@iRow } } } -\AtBeginDocument +\cs_new_protected:Npn \__nicematrix_hdottedline:n #1 { - \cs_new_protected:Npx \__nicematrix_hdottedline:n #1 - { - \bool_set_true:N \exp_not:N \l__nicematrix_initial_open_bool - \bool_set_true:N \exp_not:N \l__nicematrix_final_open_bool - \c__nicematrix_pgfortikzpicture_tl - \__nicematrix_hdottedline_i:n { #1 } - \c__nicematrix_endpgfortikzpicture_tl - } - } -\cs_new_protected:Npn \__nicematrix_hdottedline_i:n #1 - { - \pgfrememberpicturepositiononpagetrue - \__nicematrix_qpoint:n { row - #1 } - \dim_set_eq:NN \l__nicematrix_y_initial_dim \pgf@y - \dim_sub:Nn \l__nicematrix_y_initial_dim \l__nicematrix_radius_dim - \dim_set_eq:NN \l__nicematrix_y_final_dim \l__nicematrix_y_initial_dim - \__nicematrix_qpoint:n { col - 1 } - \dim_set:Nn \l__nicematrix_x_initial_dim - { - \pgf@x + - \bool_if:NTF \l__nicematrix_NiceArray_bool \c_zero_dim \arraycolsep - - \l__nicematrix_left_margin_dim - } - \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \c@jCol } - \dim_set:Nn \l__nicematrix_x_final_dim - { - \pgf@x - - \bool_if:NTF \l__nicematrix_NiceArray_bool \c_zero_dim \arraycolsep - + \l__nicematrix_right_margin_dim - } - \tl_if_eq:NnF \g__nicematrix_left_delim_tl ( - { \dim_gadd:Nn \l__nicematrix_x_initial_dim { 0.5 \l__nicematrix_inter_dots_dim } } - \tl_if_eq:NnF \g__nicematrix_right_delim_tl ) - { \dim_gsub:Nn \l__nicematrix_x_final_dim { 0.5 \l__nicematrix_inter_dots_dim } } - \tl_set_eq:NN \l__nicematrix_xdots_line_style_tl \c__nicematrix_standard_tl - \__nicematrix_draw_line: + \group_begin: + \bool_set_true:N \l__nicematrix_dotted_bool + \__nicematrix_hline:nnnn { #1 } { 1 } { 1 } { \int_use:N \c@jCol } + \group_end: } \cs_new_protected:Npn \__nicematrix_vdottedline:n #1 { - \bool_set_true:N \l__nicematrix_initial_open_bool - \bool_set_true:N \l__nicematrix_final_open_bool - \bool_if:NTF \c__nicematrix_tikz_loaded_bool - { - \tikzpicture - \__nicematrix_vdottedline_i:n { #1 } - \endtikzpicture - } - { - \pgfpicture - \__nicematrix_vdottedline_i:n { #1 } - \endpgfpicture - } - } -\cs_new_protected:Npn \__nicematrix_vdottedline_i:n #1 - { - \CT@arc@ - \pgfrememberpicturepositiononpagetrue - \__nicematrix_qpoint:n { col - \int_eval:n { #1 + 1 } } - \dim_set:Nn \l__nicematrix_x_initial_dim { \pgf@x - \l__nicematrix_radius_dim } - \dim_set:Nn \l__nicematrix_x_final_dim { \pgf@x - \l__nicematrix_radius_dim } - \__nicematrix_qpoint:n { row - 1 } - \dim_set:Nn \l__nicematrix_y_initial_dim { \pgf@y - 0.5 \l__nicematrix_inter_dots_dim } - \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \c@iRow } - \dim_set:Nn \l__nicematrix_y_final_dim { \pgf@y + 0.5 \l__nicematrix_inter_dots_dim } - \tl_set_eq:NN \l__nicematrix_xdots_line_style_tl \c__nicematrix_standard_tl - \__nicematrix_draw_line: + \group_begin: + \bool_set_true:N \l__nicematrix_dotted_bool + \__nicematrix_vline:nnnn { \int_eval:n { #1 + 1 } } { 1 } { 1 } { \int_use:N \c@iRow } + \group_end: } \bool_new:N \l__nicematrix_block_auto_columns_width_bool \keys_define:nn { NiceMatrix / NiceMatrixBlock } @@ -5402,7 +5421,7 @@ color .tl_set:N = \l__nicematrix_color_tl , color .value_required:n = true } -\NewExpandableDocumentCommand \__nicematrix_Block: { O { } m D < > { } m } +\NewExpandableDocumentCommand \__nicematrix_Block: { O { } m D < > { } +m } { \peek_remove_spaces:n { @@ -5480,7 +5499,7 @@ \int_compare:nNnT { #1 } = 1 \g__nicematrix_row_style_tl \group_begin: \cs_set:Npn \arraystretch { 1 } - \dim_set_eq:NN \extrarowheight \c_zero_dim + \dim_zero:N \extrarowheight #4 \bool_if:NT \g__nicematrix_rotate_bool { \str_set:Nn \l__nicematrix_hpos_block_str c } \bool_if:NTF \l__nicematrix_NiceTabular_bool @@ -5489,7 +5508,7 @@ { \int_compare_p:nNn { #2 } = 1 } { \dim_compare_p:n { \l__nicematrix_col_width_dim >= \c_zero_dim } } { - \begin { minipage } [ l__nicematrix_vpos_of_block_tl ] + \begin { minipage } [ \l__nicematrix_vpos_of_block_tl ] { \l__nicematrix_col_width_dim } \str_case:Vn \l__nicematrix_hpos_block_str { @@ -5586,7 +5605,7 @@ { \group_begin: \cs_set:Npn \arraystretch { 1 } - \dim_set_eq:NN \extrarowheight \c_zero_dim + \dim_zero:N \extrarowheight #4 \bool_if:NT \g__nicematrix_rotate_bool { \str_set:Nn \l__nicematrix_hpos_block_str c } @@ -5602,7 +5621,7 @@ { \group_begin: \cs_set:Npn \arraystretch { 1 } - \dim_set_eq:NN \extrarowheight \c_zero_dim + \dim_zero:N \extrarowheight #4 \bool_if:NT \g__nicematrix_rotate_bool { \str_set:Nn \l__nicematrix_hpos_block_str c } @@ -6492,7 +6511,7 @@ \l__nicematrix_y_initial_dim - \l__nicematrix_y_final_dim + \l__nicematrix_submatrix_extra_height_dim - \arrayrulewidth } - \dim_set_eq:NN \nulldelimiterspace \c_zero_dim + \dim_zero:N \nulldelimiterspace \group_begin: \pgfsetlinewidth { 1.1 \arrayrulewidth } \tl_if_empty:NF \l__nicematrix_rules_color_tl |