diff options
author | Karl Berry <karl@freefriends.org> | 2019-06-23 21:03:20 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2019-06-23 21:03:20 +0000 |
commit | 0d626fef69361eb0ff9bc0bf8aecff696be3f7da (patch) | |
tree | bae4a363da27060ed2be41a67d76f82419880da4 /Master/texmf-dist/tex | |
parent | 2848dc4a0a5ab87e1713f6822a0f0fa6281feb81 (diff) |
nicematrix (23jun19)
git-svn-id: svn://tug.org/texlive/trunk@51438 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty | 218 |
1 files changed, 189 insertions, 29 deletions
diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty index dea687e5f4a..20432043d69 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{2.1.5} -\def\myfiledate{2019/05/27} +\def\myfileversion{2.2} +\def\myfiledate{2019/06/23} \RequirePackage{tikz} \usetikzlibrary{fit} \RequirePackage{expl3}[2019/02/15] @@ -116,7 +116,7 @@ { \seq_gput_left:Nn \g__nm_names_seq { #1 } } \str_set:Nn \l__nm_name_str { #1 } , name .value_required:n = true , - code-after .tl_set:N = \l__nm_code_after_tl , + code-after .tl_gset:N = \g__nm_code_after_tl , code-after .initial:n = \c_empty_tl , code-after .value_required:n = true , } @@ -165,6 +165,9 @@ allow-duplicate-names .code:n = \__nm_msg_redirect_name:nn { Duplicate~name } {none} , allow-duplicate-names .value_forbidden:n = true , + letter-for-dotted-lines .tl_set:N = \l__nm_letter_for_dotted_lines_str , + letter-for-dotted-lines .value_required:n = true , + letter-for-dotted-lines .initial:n = \c_colon_str , unknown .code:n = \__nm_error:n { Unknown~key~for~NiceMatrixOptions } } \__nm_msg_new:nnn { Unknown~key~for~NiceMatrixOptions } { @@ -179,6 +182,7 @@ code-for-last-col,~ exterior-arraycolsep,~ left-margin,~ + letter-for-dotted-lines,~ nullify-dots,~ parallelize-diags,~ renew-dots,~ @@ -330,7 +334,7 @@ \__nm_msg_new:nn { Yet~in~NiceArray } { Environments~\{NiceArray\}~(or~\{NiceMatrix\},~etc.)~can't~be~ - nested.~We~can~go~on,~but,~maybe,~you~will~have~errors~or~an~incorrect~ + nested.~You~can~go~on,~but,~maybe,~you~will~have~errors~or~an~incorrect~ result. } \cs_new_protected:Npn \__nm_define_dots: @@ -369,6 +373,60 @@ \cs_set_eq:NN \hdotsfor \__nm_Hdotsfor } } +\cs_new_protected:Nn \__nm_renewcolumntype:nn + { + \newcolumntype #1 [ 2 ] + { + > { + \hbox_set:Nw \l_tmpa_box + \__nm_Cell: + } + c + < { + \__nm_end_Cell: + \hbox_set_end: + #2 + \hbox_set:Nn \l_tmpb_box + { \makebox [ ##2 ] [ ##1 ] { \box_use:N \l_tmpa_box } } + \dim_set:Nn \l_tmpa_dim { \box_dp:N \l_tmpb_box } + \box_move_down:nn \l_tmpa_dim + { + \vbox:n + { \hbox_to_wd:nn { \box_wd:N \l_tmpb_box } + { + \hfil + \tikz [ remember~picture , overlay ] + \coordinate (__nm~north~east) ; + } + \hbox:n + { + \tikz [ remember~picture , overlay ] + \coordinate (__nm~south~west) ; + \box_move_up:nn \l_tmpa_dim { \box_use:N \l_tmpb_box } + } + } + } + \tikz [ remember~picture , overlay ] + \node + [ + node~contents = { } , + name = nm - \int_use:N \g__nm_env_int - + \int_use:N \g__nm_row_int - + \int_use:N \g__nm_column_int - w, + alias = + \str_if_empty:NF \l__nm_name_str + { + \l__nm_name_str - + \int_use:N \g__nm_row_int - + \int_use:N \g__nm_column_int - w + } , + inner~sep = \c_zero_dim , + fit = (__nm~south~west) (__nm~north~east) + ] + ; + } + } + } \NewDocumentEnvironment { NiceArray } { O { } m ! O { } } { \bool_if:NT \l__nm_in_NiceArray_bool @@ -407,7 +465,6 @@ \dim_gset_eq:NN \g__nm_left_margin_dim \l__nm_left_margin_dim \dim_gset_eq:NN \g__nm_right_margin_dim \l__nm_right_margin_dim \dim_gset_eq:NN \g__nm_extra_right_margin_dim \l__nm_extra_right_margin_dim - \tl_gset_eq:NN \g__nm_code_after_tl \l__nm_code_after_tl \tl_gset_eq:NN \g__nm_name_str \l__nm_name_str \cs_set:Npn \ialign { @@ -434,35 +491,34 @@ } \cs_set_eq:NN \NC@find@w \relax \cs_set_eq:NN \NC@find@W \relax - \newcolumntype w [ 2 ] - { - > { - \hbox_set:Nw \l_tmpa_box - \__nm_Cell:} - c - < { - \__nm_end_Cell: - \hbox_set_end: - \makebox [ ##2 ] [ ##1 ] { \box_use:N \l_tmpa_box } - } - } - \newcolumntype W [ 2 ] + \__nm_renewcolumntype:nn w { } + \__nm_renewcolumntype:nn W { \cs_set_eq:NN \hss \hfil } + \exp_args:Nx \newcolumntype \l__nm_letter_for_dotted_lines_str { - > { - \hbox_set:Nw \l_tmpa_box - \__nm_Cell: + ! + { + \skip_horizontal:n { 0.53 pt } + \bool_gset_true:N \g__nm_extra_nodes_bool + \int_compare:nNnT \g__nm_row_int = 1 + { + \int_compare:nNnTF \g__nm_column_int = \c_zero_dim + { \__nm_error:n { Use~of~:~in~first~position } } + { + \tl_gput_right:Nx \g__nm_code_after_tl + { + \exp_not:N \__nm_vdottedline:n + \exp_not:N { + \int_use:N \g__nm_column_int + \exp_not:N } + } + } + } } - c - < { - \__nm_end_Cell: - \hbox_set_end: - \cs_set_eq:NN \hss \hfil - \makebox [ ##2 ] [ ##1 ] { \box_use:N \l_tmpa_box } - } } \bool_if:NTF \c__nm_draft_bool \__nm_define_dots_to_nil: \__nm_define_dots: + \cs_set_eq:NN \hdottedline \__nm_hdottedline: \cs_set_eq:NN \Hspace \__nm_Hspace: \cs_set_eq:NN \Hdotsfor \__nm_Hdotsfor \cs_set_eq:NN \multicolumn \__nm_multicolumn:nnn @@ -600,6 +656,7 @@ } \cs_set_eq:NN \line \__nm_line:nn \g__nm_code_after_tl + \tl_gclear:N \g__nm_code_after_tl \group_end: } \cs_new_protected:Nn \__nm_find_extremities_of_line:nnnn @@ -908,7 +965,8 @@ \int_set:Nn \l_tmpa_int { \dim_ratio:nn { \l__nm_l_dim - 0.3 em } { 0.45 em } } } - { \int_set:Nn \l_tmpa_int + { + \int_set:Nn \l_tmpa_int { \dim_ratio:nn { \l__nm_l_dim - 0.6 em } { 0.45 em }} } } @@ -1081,6 +1139,108 @@ \end { tikzpicture } \__nm_draw_tikz_line: } +\cs_new:Nn \__nm_hdottedline: + { + \noalign { \skip_vertical:n { 0.53 pt } } + \__nm_hdottedline_i: + } +\cs_new_protected:Nn \__nm_hdottedline_i: + { + \int_compare:nNnTF \g__nm_row_int < 2 + { \__nm_error:n { Use~of~hdottedline~in~first~position } } + { + \bool_gset_true:N \g__nm_extra_nodes_bool + \bool_if:NF \c__nm_draft_bool + { + \tl_gput_right:Nx \g__nm_code_after_tl + { + \exp_not:N \__nm_hdottedline:n + \exp_not:N { + \int_eval:n { \g__nm_row_int - 1 } + \exp_not:N } + } + } + } + } +\cs_new_protected:Nn \__nm_hdottedline:n + { + \__nm_create_extra_nodes: + \dim_zero_new:N \g__nm_x_initial_dim + \dim_zero_new:N \g__nm_y_initial_dim + \dim_zero_new:N \g__nm_x_final_dim + \dim_zero_new:N \g__nm_y_final_dim + \bool_set_true:N \l__nm_initial_open_bool + \bool_set_true:N \l__nm_final_open_bool + \begin { tikzpicture } [ remember~picture ] + \tikz@parse@node\pgfutil@firstofone + ( #1 - 1 -large .south~west ) + \dim_gset:Nn \g__nm_x_initial_dim \pgf@x + \dim_gset:Nn \g__nm_y_initial_dim \pgf@y + \tikz@parse@node\pgfutil@firstofone + ( #1 - \int_use:N \g__nm_column_int -large .south~east ) + \dim_gset:Nn \g__nm_x_final_dim \pgf@x + \dim_gset:Nn \g__nm_y_final_dim \pgf@y + \end { tikzpicture } + \__nm_draw_tikz_line: + } +\__nm_msg_new:nn { Use~of~hdottedline~in~first~position } + { + You~can't~use~the~command~\token_to_str:N\hdottedline\ in~the~first~row~ + of~the~environment~\{\@currenvir\}. \\ + If~you~go~on,~this~dotted~line~will~be~ignored. + } +\cs_new_protected:Nn \__nm_vdottedline:n + { + \int_compare:nNnTF #1 = \c_zero_int + { \__nm_error:n { Use~of~:~in~first~position } } + { + \__nm_create_extra_nodes: + \bool_if:NF \c__nm_draft_bool + { + \dim_zero_new:N \g__nm_x_initial_dim + \dim_zero_new:N \g__nm_y_initial_dim + \dim_zero_new:N \g__nm_x_final_dim + \dim_zero_new:N \g__nm_y_final_dim + \bool_set_true:N \l__nm_initial_open_bool + \bool_set_true:N \l__nm_final_open_bool + \cs_if_exist:cTF + { pgf@sh@ns@nm -\int_use:N \g__nm_env_int - 1 - #1 - w } + { + \begin { tikzpicture } [ remember~picture ] + \tikz@parse@node\pgfutil@firstofone + ( 1 - #1 - w .north~east ) + \dim_gset:Nn \g__nm_x_initial_dim \pgf@x + \dim_gset:Nn \g__nm_y_initial_dim \pgf@y + \tikz@parse@node\pgfutil@firstofone + ( \int_use:N \g__nm_row_int - #1 - w .south~east ) + \dim_gset:Nn \g__nm_x_final_dim \pgf@x + \dim_gset:Nn \g__nm_y_final_dim \pgf@y + \end { tikzpicture } + \dim_gadd:Nn \g__nm_x_initial_dim \arraycolsep + \dim_gadd:Nn \g__nm_x_final_dim \arraycolsep + } + { + \begin { tikzpicture } [ remember~picture ] + \tikz@parse@node\pgfutil@firstofone + ( 1 - #1 - large .north~east ) + \dim_gset:Nn \g__nm_x_initial_dim \pgf@x + \dim_gset:Nn \g__nm_y_initial_dim \pgf@y + \tikz@parse@node\pgfutil@firstofone + ( \int_use:N \g__nm_row_int - #1 - large .south~east ) + \dim_gset:Nn \g__nm_x_final_dim \pgf@x + \dim_gset:Nn \g__nm_y_final_dim \pgf@y + \end { tikzpicture } + } + \__nm_draw_tikz_line: + } + } + } +\__nm_msg_new:nn { Use~of~:~in~first~position } + { + You~can't~use~the~column~specifier~"\l__nm_letter_for_dotted_lines_str"~in~the~ + first~position~of~the~preamble~of~the~environment~\{\@currenvir\}. \\ + If~you~go~on,~this~dotted~line~will~be~ignored. + } \bool_new:N \l__nm_block_auto_columns_width_bool \keys_define:nn { NiceMatrix / NiceMatrixBlock } { |