diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty | 218 |
1 files changed, 161 insertions, 57 deletions
diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty index e51cb549e77..fa0c20dbd66 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{1.2} -\def\myfiledate{2018/03/11} +\def\myfileversion{1.3} +\def\myfiledate{2018/03/31} \RequirePackage{l3keys2e} \ProvidesExplPackage {nicematrix} @@ -40,54 +40,88 @@ \hbox{.}} \mkern 1mu}} \cs_new_protected:Nn \__nm_multicolumn:nn - {\msg_error:nn {nicematrix} {multicolumn~forbidden}} + {\msg_error:nn {nicematrix} {Multicolumn~forbidden}} \int_new:N \g__nm_env_int +\tl_new:N \l__nm_pos_env_tl +\tl_set:Nn \l__nm_pos_env_tl c \bool_new:N \l__nm_exterior_arraycolsep_bool \bool_new:N \l__nm_parallelize_diags_bool \bool_set_true:N \l__nm_parallelize_diags_bool \bool_new:N \l__nm_nullify_dots_bool \bool_new:N \l__nm_renew_matrix_bool -\keys_define:nn {NiceMatrix} - {ParallelizeDiagonals .bool_set:N = \l__nm_parallelize_diags_bool, - ParallelizeDiagonals .default:n = true, - RenewDots .bool_set:N = \l__nm_renew_dots_bool, - RenewDots .default:n = true, - RenewMatrix .code:n = {\cs_set_eq:NN \env@matrix \NiceMatrix - \bool_set_true:N \l__nm_renew_matrix_bool}, - RenewMatrix .default:n = true, - Transparent .meta:n = {RenewDots,RenewMatrix}, - Transparent .value_forbidden:n = true, - NullifyDots .bool_set:N = \l__nm_nullify_dots_bool , - NullifyDots .default:n = true, - Silent .code:n = {\msg_redirect_name:nnn {nicematrix} - {Impossible~instruction} - {none}} , - Silent .value_forbidden:n = true} +\tl_new:N \l__nm_code_for_last_col_tl +\keys_define:nn {NiceMatrix/NiceMatrixOptions} + {parallelize-diags .bool_set:N = \l__nm_parallelize_diags_bool, + parallelize-diags .default:n = true, + ParallelizeDiagonals .meta:n = parallelize-diags, + renew-dots .bool_set:N = \l__nm_renew_dots_bool, + renew-dots .default:n = true, + RenewDots .meta:n = renew-dots, + renew-matrix .code:n = {\cs_set_eq:NN \env@matrix \NiceMatrix + \bool_set_true:N \l__nm_renew_matrix_bool}, + renew-matrix .value_forbidden:n = true, + RenewMatrix .meta:n = renew-matrix, + transparent .meta:n = {renew-dots,renew-matrix}, + transparent .value_forbidden:n = true, + Transparent .meta:n = transparent, + nullify-dots .bool_set:N = \l__nm_nullify_dots_bool , + nullify-dots .default:n = true, + NullifyDots .meta:n = nullify-dots, + silent .code:n = {\msg_redirect_name:nnn {nicematrix} + {Impossible~instruction} + {none}} , + silent .value_forbidden:n = true, + Silent .meta:n = silent, + code-for-last-col .tl_set:N = \l__nm_code_for_last_col_tl, + code-for-last-col .value_required:n = true, + exterior-arraycolsep .bool_set:N = \l__nm_exterior_arraycolsep_bool , + exterior-arraycolsep .default:n = true, + unknown .code:n = \msg_error:nn {nicematrix} {Option~unknown}} \NewDocumentCommand \NiceMatrixOptions {m} - {\keys_set:nn {NiceMatrix} {#1}} -\keys_define:nn {NiceArray} - {exterior-arraycolsep .bool_set:N = \l__nm_exterior_arraycolsep_bool , - exterior-arraycolsep .default:n = true} + {\keys_set:nn {NiceMatrix/NiceMatrixOptions} {#1}} +\keys_define:nn {NiceMatrix/NiceMatrix} + {parallelize-diags .bool_set:N = \l__nm_parallelize_diags_bool, + parallelize-diags .default:n = true, + renew-dots .bool_set:N = \l__nm_renew_dots_bool, + renew-dots .default:n = true, + nullify-dots .bool_set:N = \l__nm_nullify_dots_bool , + nullify-dots .default:n = true, + unknown .code:n = \msg_error:nn {nicematrix} {Option~unknown}} +\keys_define:nn {NiceMatrix/NiceArray} + {parallelize-diags .bool_set:N = \l__nm_parallelize_diags_bool, + parallelize-diags .default:n = true, + renew-dots .bool_set:N = \l__nm_renew_dots_bool, + renew-dots .default:n = true, + nullify-dots .bool_set:N = \l__nm_nullify_dots_bool , + nullify-dots .default:n = true, + exterior-arraycolsep .bool_set:N = \l__nm_exterior_arraycolsep_bool , + exterior-arraycolsep .default:n = true, + c .code:n = \tl_set:Nn \l__nm_pos_env_tl c, + t .code:n = \tl_set:Nn \l__nm_pos_env_tl t, + b .code:n = \tl_set:Nn \l__nm_pos_env_tl b, + unknown .code:n = \msg_error:nn {nicematrix} {Option~unknown}} \cs_new_protected:Nn \__nm_Cell:n { \tl_gput_right:Nn \g__nm_preamble_aux_tl {#1} \int_gincr:N \g__nm_column_int \tikz[remember~picture, inner~sep = 0pt, minimum~width = 0pt, baseline] \node [anchor=base] (nm-\int_use:N \g__nm_env_int- - \int_use:N \g__nm_line_int- + \int_use:N \g__nm_row_int- \int_use:N \g__nm_column_int) \bgroup $} % $ \cs_new_protected:Nn \__nm_end_Cell: {$\egroup ;} % $ -\NewDocumentEnvironment {NiceMatrix} {} - {\bool_set_false:N \l__nm_exterior_arraycolsep_bool +\NewDocumentEnvironment {NiceMatrix} {O{}} + {\keys_set:nn {NiceMatrix/NiceMatrix} {#1} + \tl_set:Nn \l__nm_pos_env_tl c + \bool_set_false:N \l__nm_exterior_arraycolsep_bool \NiceArray{*\c@MaxMatrixCols{C}}} {\endarray \skip_horizontal:n {-\arraycolsep}} -\NewDocumentEnvironment {NiceArray} {O{} m} +\NewDocumentEnvironment {NiceArray} {O{} m O{}} {\aftergroup \__nm_draw_lines: - \keys_set_known:nnN {NiceArray} {#1} \l_tmpa_tl + \keys_set:nn {NiceMatrix/NiceArray} {#1,#3} \cs_set:Npn \ialign - {\everycr{\noalign{\int_gincr:N \g__nm_line_int + {\everycr{\noalign{\int_gincr:N \g__nm_row_int \int_gzero:N \g__nm_column_int \int_compare:nNnT {\tl_count:N \g__nm_preamble_aux_tl} > {\tl_count:N \g__nm_preamble_tl} @@ -116,19 +150,19 @@ \cs_set_eq:NN \iddots \__nm_Iddots} \bool_if:NF \l__nm_renew_matrix_bool {\cs_set_eq:NN \multicolumn \__nm_multicolumn:nn} - \int_gincr:N \g__nm_env_int + \int_gincr:N \g__nm_env_int \tl_clear_new:N \g__nm_preamble_tl \tl_clear_new:N \g__nm_preamble_aux_tl - \seq_gclear_new:N \g__nm_empty_cells_seq - \int_gzero_new:N \g__nm_instruction_int - \int_gzero_new:N \g__nm_line_int - \int_gzero_new:N \g__nm_column_int - \cs_set_eq:NN \@ifnextchar \new@ifnextchar - \bool_if:NF \l__nm_exterior_arraycolsep_bool + \seq_gclear_new:N \g__nm_empty_cells_seq + \int_gzero_new:N \g__nm_instruction_int + \int_gzero_new:N \g__nm_row_int + \int_gzero_new:N \g__nm_column_int + \cs_set_eq:NN \@ifnextchar \new@ifnextchar + \bool_if:NF \l__nm_exterior_arraycolsep_bool {\skip_horizontal:n {-\arraycolsep}} - \array[\l_tmpa_tl]{#2}} - {\endarray - \bool_if:NF \l__nm_exterior_arraycolsep_bool + \array[\l__nm_pos_env_tl]{#2}} + {\endarray + \bool_if:NF \l__nm_exterior_arraycolsep_bool {\skip_horizontal:n {-\arraycolsep}}} \NewDocumentEnvironment {pNiceMatrix} {} {\left(\begin{NiceMatrix}} @@ -138,13 +172,13 @@ {\end{NiceMatrix}\right]} \NewDocumentEnvironment {BNiceMatrix} {} {\left\{\begin{NiceMatrix}} - {\end{BNiceMatrix}\right\}} + {\end{NiceMatrix}\right\}} \NewDocumentEnvironment {vNiceMatrix} {} {\left\lvert\begin{NiceMatrix}} - {\end{BNiceMatrix}\right\rvert} + {\end{NiceMatrix}\right\rvert} \NewDocumentEnvironment {VNiceMatrix} {} {\left\lVert\begin{NiceMatrix}} - {\end{BNiceMatrix}\right\rVert} + {\end{NiceMatrix}\right\rVert} \prg_set_conditional:Npnn \__nm_if_not_empty_cell:nn #1#2 {T} {\cs_if_exist:cTF {pgf@sh@ns@nm-\int_use:N \g__nm_env_int- \int_use:N #1- @@ -170,7 +204,7 @@ \cs_new_protected:Nn \__nm_instruction_of_type:n {\int_gincr:N \g__nm_instruction_int \prop_put:Nnn \l_tmpa_prop {type} {#1} - \prop_put:NnV \l_tmpa_prop {line} \g__nm_line_int + \prop_put:NnV \l_tmpa_prop {row} \g__nm_row_int \prop_put:NnV \l_tmpa_prop {column} \g__nm_column_int \prop_gclear_new:c {g__nm_instruction_\int_use:N\g__nm_instruction_int _prop} @@ -180,13 +214,12 @@ } \cs_new_protected:Nn \__nm_draw_lines: - {\int_compare:nNnT {\tl_count:N \g__nm_preamble_aux_tl} - > {\tl_count:N \g__nm_preamble_tl} - {\tl_set_eq:NN \g__nm_preamble_tl \g__nm_preamble_aux_tl} + { + \int_decr:N \g__nm_row_int \int_set:Nn \g__nm_column_int {\tl_count:N \g__nm_preamble_tl} \seq_clear_new:N \l__nm_yet_drawn_seq \int_zero_new:N \l__nm_type_int - \int_zero_new:N \l__nm_line_int + \int_zero_new:N \l__nm_row_int \int_zero_new:N \l__nm_column_int \int_zero_new:N \l__nm_di_int \int_zero_new:N \l__nm_dj_int @@ -205,8 +238,8 @@ {type} \l_tmpa_tl \int_set:Nn \l__nm_type_int {\l_tmpa_tl} \prop_get:cnN {g__nm_instruction_\int_use:N \l__nm_instruction_int _prop} - {line} \l_tmpa_tl - \int_set:Nn \l__nm_line_int {\l_tmpa_tl} + {row} \l_tmpa_tl + \int_set:Nn \l__nm_row_int {\l_tmpa_tl} \prop_get:cnN {g__nm_instruction_\int_use:N \l__nm_instruction_int _prop} {column} \l_tmpa_tl \int_set:Nn \l__nm_column_int {\l_tmpa_tl} @@ -226,7 +259,7 @@ {\bool_new:N \l__nm_impossible_instruction_bool} \int_zero_new:N \l__nm_final_i_int \int_zero_new:N \l__nm_final_j_int - \int_set:Nn \l__nm_final_i_int \l__nm_line_int + \int_set:Nn \l__nm_final_i_int \l__nm_row_int \int_set:Nn \l__nm_final_j_int \l__nm_column_int \bool_if_exist:NTF \l__nm_stop_loop_bool {\bool_set_false:N \l__nm_stop_loop_bool} @@ -235,7 +268,7 @@ {\int_add:Nn \l__nm_final_i_int \l__nm_di_int \int_add:Nn \l__nm_final_j_int \l__nm_dj_int \bool_if:nTF { \int_compare_p:nNn \l__nm_final_i_int < 1 - || \int_compare_p:nNn \l__nm_final_i_int > \g__nm_line_int + || \int_compare_p:nNn \l__nm_final_i_int > \g__nm_row_int || \int_compare_p:nNn \l__nm_final_j_int < 1 || \int_compare_p:nNn \l__nm_final_j_int > \g__nm_column_int} {\bool_set_true:N \l__nm_impossible_instruction_bool @@ -245,7 +278,7 @@ } \int_zero_new:N \l__nm_initial_i_int \int_zero_new:N \l__nm_initial_j_int - \int_set:Nn \l__nm_initial_i_int \l__nm_line_int + \int_set:Nn \l__nm_initial_i_int \l__nm_row_int \int_set:Nn \l__nm_initial_j_int \l__nm_column_int \bool_set_eq:NN \l__nm_stop_loop_bool \l__nm_impossible_instruction_bool \bool_do_until:Nn \l__nm_stop_loop_bool @@ -253,7 +286,7 @@ \int_sub:Nn \l__nm_initial_j_int \l__nm_dj_int \bool_if:nTF { \int_compare_p:nNn \l__nm_initial_i_int < 1 - || \int_compare_p:nNn \l__nm_initial_i_int > \g__nm_line_int + || \int_compare_p:nNn \l__nm_initial_i_int > \g__nm_row_int || \int_compare_p:nNn \l__nm_initial_j_int < 1 || \int_compare_p:nNn \l__nm_initial_j_int > \g__nm_column_int} {\bool_set_true:N \l__nm_impossible_instruction_bool @@ -382,7 +415,7 @@ \cs_set_eq:NN \__nm_iddots \iddots \cs_new_protected:Nn \__nm_add_to_empty_cells: {\seq_gput_right:Nx \g__nm_empty_cells_seq - {\int_use:N \g__nm_line_int- + {\int_use:N \g__nm_row_int- \int_use:N \g__nm_column_int}} \NewDocumentCommand \__nm_Ldots {s} {\IfBooleanF {#1} {\__nm_instruction_of_type:n 0} @@ -417,21 +450,92 @@ {0 {\token_to_str:N \Ldots} 1 {\token_to_str:N \Cdots} 2 {\token_to_str:N \Vdots} - 3 {\token_to_str:N \Ddots}}~in~the~line~\int_use:N\l__nm_line_int\ + 3 {\token_to_str:N \Ddots}}~in~the~row~\int_use:N\l__nm_row_int\ ~and~the~column~\int_use:N\l__nm_column_int\space of~the~matrix~ because~it's~impossible~to~find~one~of~its~extremities~ (both~extremities~must~be~non~empty~cells~of~the~matrix).~ If~you~go~on,~the~instruction~will~be~ignored.} - {You~can~specify~a~end~of~line~on~a~empty~cell~ + {You~can~specify~an~end~of~line~on~a~empty~cell~ with~\token_to_str:N \NiceMatrixEndPoint.} \msg_new:nnn {nicematrix} - {multicolumn~forbidden} + {Multicolumn~forbidden} {The~command~\token_to_str:N \multicolumn\ is~forbidden~in~the~environment~\{NiceMatrix\}~ and~its~variants.~The~command~\token_to_str:N \hdotsfor\ of~amsmath~is~also~forbidden~since~it~uses~ \token_to_str:N \multicolumn.~You~can~go~on~but~your~line~will~ probably~be~wrong.} +\msg_new:nnn {nicematrix} + {Option~unknown} + {The~option~"\tl_use:N\l_keys_key_tl"~is~unknown~or~ + meaningless~in~the~context.~If~you~go~on,~it~will~be~ignored.} +\keys_define:nn {NiceMatrix/NiceArrayC} + {parallelize-diags .bool_set:N = \l__nm_parallelize_diags_bool, + parallelize-diags .default:n = true, + renew-dots .bool_set:N = \l__nm_renew_dots_bool, + renew-dots .default:n = true, + nullify-dots .bool_set:N = \l__nm_nullify_dots_bool , + nullify-dots .default:n = true, + code-for-last-col .tl_set:N = \l__nm_code_for_last_col_tl, + code-for-last-col .value_required:n = true, + unknown .code:n = \msg_error:nn {nicematrix} {Option~unknown}} +\cs_new_protected:Nn \__nm_NiceArrayC:nn + {\dim_gzero_new:N \g__nm_width_last_col_dim + \keys_set:nn {NiceMatrix/NiceArrayC} {#1} + \bool_set_false:N \l__nm_exterior_arraycolsep_bool + \tl_set:Nn \l__nm_pos_env_tl c + \begin{NiceArray} + {#2 + >{\hbox_set:Nw \l_tmpa_box + \l__nm_code_for_last_col_tl + \__nm_Cell:n l} + l + <{\__nm_end_Cell: + \hbox_set_end: + \dim_gset:Nn \g__nm_width_last_col_dim + {\dim_max:nn \g__nm_width_last_col_dim + {\box_wd:N \l_tmpa_box}} + \skip_horizontal:n {-2\arraycolsep} + \hbox_overlap_right:n + {\skip_horizontal:n {2\arraycolsep} + \box_use:N \l_tmpa_box}}}} +\cs_new:Nn \__nm_after_last_col: + {\dim_compare:nNnF \g__nm_width_last_col_dim = \c_zero_dim + {\skip_horizontal:n {\g__nm_width_last_col_dim}{}}} +\NewDocumentEnvironment {pNiceArrayC} {O{} m O{}} + {\left( + \__nm_NiceArrayC:nn {#1,#3} {#2}} + {\end{NiceArray} + \right) + \__nm_after_last_col:} + +\NewDocumentEnvironment {vNiceArrayC} {O{} m O{}} + {\left| + \__nm_NiceArrayC:nn {#1,#3} {#2}} + {\end{NiceArray} + \right| + \__nm_after_last_col:} + +\NewDocumentEnvironment {VNiceArrayC} {O{} m O{}} + {\left\| + \__nm_NiceArrayC:nn {#1,#3} {#2}} + {\end{NiceArray} + \right\| + \__nm_after_last_col:} + +\NewDocumentEnvironment {bNiceArrayC} {O{} m O{}} + {\left[ + \__nm_NiceArrayC:nn {#1,#3} {#2}} + {\end{NiceArray} + \right] + \__nm_after_last_col:} + +\NewDocumentEnvironment {BNiceArrayC} {O{} m O{}} + {\left\{ + \__nm_NiceArrayC:nn {#1,#3} {#2}} + {\end{NiceArray} + \right\} + \__nm_after_last_col:} \endinput %% %% End of file `nicematrix.sty'. |