diff options
author | Karl Berry <karl@freefriends.org> | 2018-02-26 23:16:50 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-02-26 23:16:50 +0000 |
commit | 50ac47bcadbdf7f9fda1f19d5e1eae599006bfa5 (patch) | |
tree | 0d783c06eaaf66a84ae14558989b2dcde3c00dae /Master/texmf-dist/tex/latex/nicematrix | |
parent | 468ba45a95f1adb9c950eae06fbabace68c4b561 (diff) |
nicematrix (27feb18)
git-svn-id: svn://tug.org/texlive/trunk@46747 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 | 142 |
1 files changed, 80 insertions, 62 deletions
diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty index d0c2e771cc6..a11a958ad7b 100644 --- a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty +++ b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty @@ -18,10 +18,8 @@ %% and version 1.3 or later is part of all distributions of %% LaTeX version 2005/12/01 or later. %% -\def\myfileversion{1.0} -\def\myfiledate{2018/02/13} -\RequirePackage{tikz} -\usetikzlibrary{calc,math} +\def\myfileversion{1.1} +\def\myfiledate{2018/02/26} \RequirePackage{l3keys2e} \ProvidesExplPackage {nicematrix} @@ -30,16 +28,17 @@ {Draws nice dotted lines in matrix environments} \RequirePackage{array} \RequirePackage{mathtools} +\RequirePackage{tikz} \RequirePackage{xparse} \ProvideDocumentCommand \iddots {} {\mathinner{\mkern 1mu - \raise 1pt \hbox{.} + \raise \p@ \hbox{.} \mkern 2mu - \raise 4pt\hbox{.} + \raise 4\p@ \hbox{.} \mkern 2mu - \raise7pt \vbox{\kern 7pt - \hbox{.}} - \mkern1mu}} + \raise 7\p@ \vbox{\kern 7pt + \hbox{.}} + \mkern 1mu}} \cs_new_protected:Nn \__nm_multicolumn:nn {\msg_error:nn {nicematrix} {multicolumn~forbidden}} \int_new:N \g__nm_env_int @@ -58,7 +57,11 @@ Transparent .meta:n = {RenewDots,RenewMatrix}, Transparent .value_forbidden:n = true, NullifyDots .bool_set:N = \l__nm_nullify_dots_bool , - NullifyDots .default:n = true} + NullifyDots .default:n = true, + Silent .code:n = {\msg_redirect_name:nnn {nicematrix} + {Impossible~instruction} + {none}} , + Silent .value_forbidden:n = true} \NewDocumentCommand \NiceMatrixOptions {m} {\keys_set:nn {NiceMatrix} {#1}} \cs_new_protected:Nn \__nm_Cell: @@ -124,28 +127,25 @@ {\left\lVert\begin{NiceMatrix}} {\end{BNiceMatrix}\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- - \int_use:N #2} + {\cs_if_exist:cTF {pgf@sh@ns@nm-\int_use:N \g__nm_env_int- + \int_use:N #1- + \int_use:N #2} {\seq_if_in:NxTF \g__nm_empty_cells_seq {\int_use:N #1-\int_use:N #2} {\prg_return_false:} - {\tikz[remember~picture] - \path let \p1 = (nm- - \int_use:N \g__nm_env_int- - \int_use:N #1- - \int_use:N #2.east), - \p2 = (nm- - \int_use:N \g__nm_env_int- - \int_use:N #1- - \int_use:N #2.west) - in \pgfextra {\dim_gset:Nn \g_tmpa_dim {\x1} - \dim_gset:Nn \g_tmpb_dim {\x2}} ; - \dim_gsub:Nn \g_tmpa_dim \g_tmpb_dim - \dim_compare:nNnTF {\dim_abs:n \g_tmpa_dim} < {0.5 pt} + {\begin{pgfpicture} + \tl_set:Nx \l_tmpa_tl {nm-\int_use:N \g__nm_env_int- + \int_use:N #1- + \int_use:N #2} + \pgfpointanchor \l_tmpa_tl {east} + \dim_gset:Nn \g_tmpa_dim \pgf@x + \pgfpointanchor \l_tmpa_tl {west} + \dim_gset:Nn \g_tmpb_dim \pgf@x + \end{pgfpicture} + \dim_compare:nNnTF {\dim_abs:n {\g_tmpb_dim-\g_tmpa_dim}} < {0.5 pt} {\prg_return_false:} - {\prg_return_true:}}} + {\prg_return_true:} + }} {\prg_return_false:} } \cs_new_protected:Nn \__nm_instruction_of_type:n @@ -261,28 +261,31 @@ } } \cs_new_protected:Nn \__nm_retrieve_coords:nn - {\tikz[remember~picture] - \path let \p1 = (nm-\int_use:N \g__nm_env_int- - \int_use:N \l__nm_initial_i_int- - \int_use:N \l__nm_initial_j_int #1), - \p2 = (nm-\int_use:N \g__nm_env_int- - \int_use:N \l__nm_final_i_int- - \int_use:N \l__nm_final_j_int #2) - in \pgfextra {\dim_gset:Nn \g__nm_x_initial_dim {\x1} - \dim_gset:Nn \g__nm_y_initial_dim {\y1} - \dim_gset:Nn \g__nm_x_final_dim {\x2} - \dim_gset:Nn \g__nm_y_final_dim {\y2}} ; } + {\begin{tikzpicture}[remember~picture] + \tikz@parse@node\pgfutil@firstofone + (nm-\int_use:N \g__nm_env_int- + \int_use:N \l__nm_initial_i_int- + \int_use:N \l__nm_initial_j_int.#1) + \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 + (nm-\int_use:N \g__nm_env_int- + \int_use:N \l__nm_final_i_int- + \int_use:N \l__nm_final_j_int.#2) + \dim_gset:Nn \g__nm_x_final_dim \pgf@x + \dim_gset:Nn \g__nm_y_final_dim \pgf@y + \end{tikzpicture} } \cs_new_protected:Nn \__nm_draw_ldots_line: - {\__nm_retrieve_coords:nn {.south~east} {.south~west} + {\__nm_retrieve_coords:nn {south~east} {south~west} \__nm_draw_tikz_line:} \cs_new_protected:Nn \__nm_draw_cdots_line: - {\__nm_retrieve_coords:nn {.mid~east} {.mid~west} + {\__nm_retrieve_coords:nn {mid~east} {mid~west} \__nm_draw_tikz_line:} \cs_new_protected:Nn \__nm_draw_vdots_line: - {\__nm_retrieve_coords:nn {.south} {.north} + {\__nm_retrieve_coords:nn {south} {north} \__nm_draw_tikz_line:} \cs_new_protected:Nn \__nm_draw_ddots_line: - {\__nm_retrieve_coords:nn {.south~east} {.north~west} + {\__nm_retrieve_coords:nn {south~east} {north~west} \bool_if:NT \l__nm_parallelize_diags_bool {\int_incr:N \l__nm_ddots_int \int_compare:nNnTF \l__nm_ddots_int = 1 @@ -294,7 +297,7 @@ * \dim_ratio:nn \l__nm_delta_y_one_dim \l__nm_delta_x_one_dim }}} \__nm_draw_tikz_line:} \cs_new_protected:Nn \__nm_draw_iddots_line: - {\__nm_retrieve_coords:nn {.south~west} {.north~east} + {\__nm_retrieve_coords:nn {south~west} {north~east} \bool_if:NT \l__nm_parallelize_diags_bool {\int_incr:N \l__nm_iddots_int \int_compare:nNnTF \l__nm_iddots_int = 1 @@ -305,25 +308,40 @@ (\g__nm_x_final_dim - \g__nm_x_initial_dim) * \dim_ratio:nn \l__nm_delta_y_two_dim \l__nm_delta_x_two_dim }}} \__nm_draw_tikz_line:} - \cs_new_protected:Nn \__nm_draw_tikz_line: - {\begin{tikzpicture}[overlay] - \tikzmath{ - coordinate~\a , \b ; - real~\l, \x, \d ; - integer~\n ; - \a = (\g__nm_x_initial_dim, \g__nm_y_initial_dim) ; - \b = (\g__nm_x_final_dim, \g__nm_y_final_dim) ; - \l = veclen(\bx-\ax,\by-\ay) ; - \n = (\l - 0.54em)/(0.45em) ; - \x = (\l - \n*0.45em)/(2*\l) ; - \d = 0.45em / \l ; - if~\n>0 - then~{ for~\k in~{0,...,\n} - { {\node at ($(\a)!\x+\k*\d!(\b)$) {.} ; } ; } ; - } ; - } - \end{tikzpicture}} + { + \dim_zero_new:N \l__nm_l_dim + \dim_set:Nn \l__nm_l_dim + { \fp_to_dim:n + { sqrt( ( \dim_use:N \g__nm_x_final_dim + -\dim_use:N \g__nm_x_initial_dim) ^2 + +( \dim_use:N \g__nm_y_final_dim + -\dim_use:N \g__nm_y_initial_dim) ^2 )} + } + \int_set:Nn \l_tmpa_int {\dim_ratio:nn {\l__nm_l_dim - 0.54em} + {0.45em}} + \dim_set:Nn \l_tmpa_dim { (\g__nm_x_final_dim - \g__nm_x_initial_dim) + * \dim_ratio:nn {0.45em} \l__nm_l_dim} + \dim_set:Nn \l_tmpb_dim { (\g__nm_y_final_dim - \g__nm_y_initial_dim) + * \dim_ratio:nn {0.45em} \l__nm_l_dim} + \dim_gadd:Nn \g__nm_x_initial_dim + { (\g__nm_x_final_dim - \g__nm_x_initial_dim) + * \dim_ratio:nn {\l__nm_l_dim - 0.45 em * \l_tmpa_int} + {\l__nm_l_dim * 2}} + \dim_gadd:Nn \g__nm_y_initial_dim + { (\g__nm_y_final_dim - \g__nm_y_initial_dim) + * \dim_ratio:nn {\l__nm_l_dim - 0.45 em * \l_tmpa_int} + {\l__nm_l_dim * 2}} + \begin{tikzpicture}[overlay] + \int_step_inline:nnnn 0 1 \l_tmpa_int + { \pgfpathcircle{\pgfpoint{\g__nm_x_initial_dim} + {\g__nm_y_initial_dim}} + {0.53pt} + \pgfusepath{fill} + \dim_gadd:Nn \g__nm_x_initial_dim \l_tmpa_dim + \dim_gadd:Nn \g__nm_y_initial_dim \l_tmpb_dim } + \end{tikzpicture} +} \cs_set_eq:NN \__nm_ldots \ldots \cs_set_eq:NN \__nm_cdots \cdots \cs_set_eq:NN \__nm_vdots \vdots |