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 | |
parent | 2848dc4a0a5ab87e1713f6822a0f0fa6281feb81 (diff) |
nicematrix (23jun19)
git-svn-id: svn://tug.org/texlive/trunk@51438 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf | bin | 387098 -> 418609 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx | 478 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty | 218 |
3 files changed, 606 insertions, 90 deletions
diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf b/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf Binary files differindex 908368d1d6e..80f13ee4382 100644 --- a/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf +++ b/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf diff --git a/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx b/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx index 618964b20c9..c3aaadec488 100644 --- a/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx +++ b/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx @@ -15,8 +15,8 @@ % % \fi % \iffalse -\def\myfileversion{2.1.5} -\def\myfiledate{2019/05/27} +\def\myfileversion{2.2} +\def\myfiledate{2019/06/23} % % %<*batchfile> @@ -61,9 +61,9 @@ version 2005/12/01 or later. \titlespacing*{\section}{0pt}{6.5ex plus 1ex minus .2ex}{4.3ex plus .2ex} \titlespacing*{\subsection}{0pt}{4.5ex plus 1ex minus .2ex}{2ex plus .2ex} \usepackage{multicol} +\usepackage{arydshln} \setlength{\columnseprule}{0.4pt} \usepackage{colortbl} -\usepackage{arydshln} \usepackage{footnotehyper} \parindent 0pt @@ -581,6 +581,9 @@ version 2005/12/01 or later. % \end{pmatrix}$ % \end{scope} % +% +% +% % \section{The Tikz nodes created by nicematrix} % % The package \pkg{nicematrix} creates a Tikz node for each cell of the @@ -1055,6 +1058,102 @@ version 2005/12/01 or later. % \end{pNiceArrayC}$ % % +% +% \section{The dotted lines to separate rows or columns} +% +% +% In the environments of the extension \pkg{nicematrix}, it's possible to use +% the command |\hdottedline| which is a counterpart of the classical commands +% |\hline| and |\hdashline| (of \pkg{arydshln}). +% +% \medskip +% \begin{BVerbatim}[baseline=c,boxwidth=9.5cm] +% \begin{pNiceMatrix} +% 1 & 2 & 3 & 4 & 5 \\ +% ~emphase#\hdottedline@ +% 6 & 7 & 8 & 9 & 10 \\ +% 11 & 12 & 13 & 14 & 15 +% \end{pNiceMatrix} +% \end{BVerbatim} +% $\begin{pNiceMatrix} +% 1 & 2 & 3 & 4 & 5 \\ +% \hdottedline +% 6 & 7 & 8 & 9 & 10 \\ +% 11 & 12 & 13 & 14 & 15 +% \end{pNiceMatrix}$ +% +% \bigskip +% In the environments with an explicit preamble (like |{NiceArray}|, etc.), it's +% possible to draw a vertical dotted line with the specifier ``|:|''. +% +% \medskip +% \begin{BVerbatim}[baseline=c,boxwidth=9.5cm] +% \left(\begin{NiceArray}{CCCC~emphase#:@C} +% 1 & 2 & 3 & 4 & 5 \\ +% 6 & 7 & 8 & 9 & 10 \\ +% 11 & 12 & 13 & 14 & 15 +% \end{NiceArray}\right) +% \end{BVerbatim} +% $\left(\begin{NiceArray}{CCCC:C} +% 1 & 2 & 3 & 4 & 5 \\ +% 6 & 7 & 8 & 9 & 10 \\ +% 11 & 12 & 13 & 14 & 15 +% \end{NiceArray}\right)$ +% +% +% \bigskip +% These dotted lines do \emph{not} extend in the ``first row'' and the ``last column'' +% of the environments with such features. +% +% \medskip +% \begin{BVerbatim}[baseline=c,boxwidth=9.5cm] +% $\begin{pNiceArrayRC}{CCC:C}% +% [ code-for-first-row = \color{blue}\scriptstyle, +% code-for-last-col = \color{blue}\scriptstyle ] +% C_1 & C_2 & C_3 & C_4 \\ +% 1 & 2 & 3 & 4 & L_1 \\ +% 5 & 6 & 7 & 8 & L_2 \\ +% 9 & 10 & 11 & 12 & L_3 \\ +% \hdottedline +% 13 & 14 & 15 & 16 & L_4 +% \end{pNiceArrayRC}$ +% \end{BVerbatim} +% $\begin{pNiceArrayRC}{CCC:C}[ code-for-first-row = \color{blue}\scriptstyle, +% code-for-last-col = \color{blue}\scriptstyle ] +% C_1 & C_2 & C_3 & C_4 \\ +% 1 & 2 & 3 & 4 & L_1 \\ +% 5 & 6 & 7 & 8 & L_2 \\ +% 9 & 10 & 11 & 12 & L_3 \\ +% \hdottedline +% 13 & 14 & 15 & 16 & L_4 +% \end{pNiceArrayRC}$ +% +% \bigskip +% It's possible to change in \pkg{nicematrix} the letter used to specify a +% vertical dotted line with the option |letter-for-dotted-lines| available in +% |\NiceMatrixOptions|. For example, in this document, we have loaded the +% extension \pkg{arydshln} which uses the letter ``:'' to specify a vertical +% dashed line. Thus, by using |letter-for-dotted-lines|, we can use the +% vertical lines of both \pkg{arydshln} and \pkg{nicematrix}. +% +% \medskip +% \begin{BVerbatim}[baseline=c,boxwidth=9.5cm] +% \NiceMatrixOptions{letter-for-dotted-lines = V} +% \left(\begin{NiceArray}{~emphase#C|C:CVC@} +% 1 & 2 & 3 & 4 \\ +% 5 & 6 & 7 & 8 \\ +% 9 & 10 & 11 & 12 +% \end{NiceArray}\right) +% \end{BVerbatim} +% \begin{scope} +% \NiceMatrixOptions{letter-for-dotted-lines = V} +% $\left(\begin{NiceArray}{C|C:CVC} +% 1 & 2 & 3 & 4 \\ +% 5 & 6 & 7 & 8 \\ +% 9 & 10 & 11 & 12 +% \end{NiceArray}\right)$ +% \end{scope} +% % \section{The width of the columns} % \label{width} % @@ -1173,7 +1272,9 @@ version 2005/12/01 or later. % \end{pNiceMatrix}$ % \end{NiceMatrixBlock} % +% % +% % \section{Technical remarks} % % \subsection{Diagonal lines} @@ -1316,17 +1417,21 @@ version 2005/12/01 or later. % % \subsection{The class option draft} % -% The package \pkg{nicematrix} is rather slow when drawing the dotted lines (generated by |\Cdots|, |\Ldots|, |\Ddots|, -% etc.).\footnote{The main reason is that we want dotted lines with round dots (and not square dots) with the same -% space on both extremities of the lines. To achieve this goal, we have to construct our own systeme of dotted -% lines.} +% The package \pkg{nicematrix} is rather slow when drawing the dotted lines +% (generated by |\Cdots|, |\Ldots|, |\Ddots|, etc. but also by |\hdottedline| or +% the specifier |:|).\footnote{The main reason is that we want dotted lines with +% round dots (and not square dots) with the same space on both extremities of +% the lines. To achieve this goal, we have to construct our own system of dotted +% lines.} % -% That's why, when the class option |draft| is used, the dotted lines are not drawn, for a faster compilation. +% That's why, when the class option |draft| is used, the dotted lines are not +% drawn, for a faster compilation. % % \subsection{A technical problem with the argument of \textbackslash\textbackslash} % -% For technical, reasons, if you use the optional argument of the command |\\|, the vertical space added will also -% be added to the ``normal'' node corresponding at the previous node. +% For technical, reasons, if you use the optional argument of the command |\\|, +% the vertical space added will also be added to the ``normal'' node +% corresponding at the previous node. % % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=11cm] @@ -1345,8 +1450,8 @@ version 2005/12/01 or later. % \end{pNiceMatrix}$ % % \bigskip -% There are two solutions to solve this problem. The first solution is to use a TeX command to insert space between -% the rows. +% There are two solutions to solve this problem. The first solution is to use a +% TeX command to insert space between the rows. % % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=11cm] @@ -1390,8 +1495,8 @@ version 2005/12/01 or later. % \subsection{Compatibility with the extension dcolumn} % % \label{dcolumn} -% If we want to make \pkg{nicematrix} compatible with \pkg{dcolumn}, it's necessary to patch the commands -% |\DC@endcentre| and |\DC@endright| as follow. +% If we want to make \pkg{nicematrix} compatible with \pkg{dcolumn}, it's +% necessary to patch the commands |\DC@endcentre| and |\DC@endright| as follow. % % \bigskip % @@ -1532,7 +1637,7 @@ version 2005/12/01 or later. % \end{pNiceMatrix}$ % % \vspace{2cm} -% An example for the resultant of two polynoms (the dashed line has been drawn with \pkg{arydshln}):\par\nobreak +% An example for the resultant of two polynoms:\par\nobreak % \bigskip % \begin{BVerbatim} % \setlength{\extrarowheight}{1mm} @@ -1574,7 +1679,7 @@ version 2005/12/01 or later. % ~emphase#\begin{NiceMatrixBlock}[auto-columns-width]@ % \NiceMatrixOptions{code-for-last-col = \color{blue}\scriptstyle} % \setlength{\extrarowheight}{1mm} -% \quad $\begin{pNiceArrayC}{CCCC|C} +% \quad $\begin{pNiceArrayC}{CCCC:C} % 1&1&1&1&1&\\ % 2&4&8&16&9&\\ % 3&9&27&81&36&\\ @@ -1591,7 +1696,7 @@ version 2005/12/01 or later. % \NiceMatrixOptions{code-for-last-col = \color{blue}\scriptstyle} % \setlength{\extrarowheight}{1mm} % -% \quad $\begin{pNiceArrayC}{CCCC|C} +% \quad $\begin{pNiceArrayC}{CCCC:C} % 1&1&1&1&1&\\ % 2&4&8&16&9&\\ % 3&9&27&81&36&\\ @@ -1600,7 +1705,7 @@ version 2005/12/01 or later. % % \medskip % -% \quad $\begin{pNiceArrayC}{CCCC|C} +% \quad $\begin{pNiceArrayC}{CCCC:C} % 1&1&1&1&1&\\ % 0&2&6&14&7&L_2\gets-2L_1+L_2 \\ % 0&6&24&78&33&L_3\gets-3L_1+L_3 \\ @@ -1609,7 +1714,7 @@ version 2005/12/01 or later. % % \medskip % -% \quad $\begin{pNiceArrayC}{CCCC|C} +% \quad $\begin{pNiceArrayC}{CCCC:C} % 1&1&1&1&1&\\ % 0&1&3&7&\frac72&L_2\gets\frac12L_2\\ % 0&3&12&39&\frac{33}2&L_3\gets\frac12L_3 \\ @@ -1618,7 +1723,7 @@ version 2005/12/01 or later. % % \medskip % -% \quad $\begin{pNiceArrayC}{CCCC|C} +% \quad $\begin{pNiceArrayC}{CCCC:C} % 1&1&1&1&1&\\ % 0&1&3&7&\frac72&\\ % 0&0&3&18&6&L_3 \gets -3L_2+L_3 \\ @@ -1627,7 +1732,7 @@ version 2005/12/01 or later. % % \medskip % -% \quad $\begin{pNiceArrayC}{CCCC|C} +% \quad $\begin{pNiceArrayC}{CCCC:C} % 1&1&1&1&1&\\ % 0&1&3&7&\frac72&\\ % 0&0&1&6&2&L_3 \gets \frac13L_3\\ @@ -1636,7 +1741,7 @@ version 2005/12/01 or later. % % \medskip % -% \quad $\begin{pNiceArrayC}{CCCC|C} +% \quad $\begin{pNiceArrayC}{CCCC:C} % 1&1&1&1&1&\\ % 0&1&3&7&\frac72&\\ % 0&0&1&6&2& \\ @@ -1905,6 +2010,7 @@ version 2005/12/01 or later. % In the following example, we use the ``large nodes'' to construct a block matrix (the dashed lines have been % drawn with \pkg{arydshln}). % \begin{Verbatim} +% \NiceMatrixOptions{letter-for-dotted-lines = V} % \left(\begin{NiceArray}{CC:CC}% % [create-extra-nodes, % ~emphase#code-after = { \tikz \node [fit = (1-1-large) (2-2-large), inner sep = 0 pt]@ @@ -1917,7 +2023,9 @@ version 2005/12/01 or later. % \end{NiceArray}\right) % \end{Verbatim} % -% +% +% \begin{scope} +% \NiceMatrixOptions{letter-for-dotted-lines = V} % \[D = \left(\begin{NiceArray}{CC:CC}[ % create-extra-nodes, % code-after = { \tikz \node [fit = (1-1-large) (2-2-large), inner sep = 0 pt] @@ -1928,8 +2036,8 @@ version 2005/12/01 or later. % a_{31} & a_{32} & a_{33} & a_{34} \\ % a_{41} & a_{42} & a_{34} & a_{44} % \end{NiceArray}\right)\] +% \end{scope} % -% % % % \section{Implementation} @@ -2263,7 +2371,7 @@ version 2005/12/01 or later. { \seq_gput_left:Nn \g_@@_names_seq { #1 } } \str_set:Nn \l_@@_name_str { #1 } , name .value_required:n = true , - code-after .tl_set:N = \l_@@_code_after_tl , + code-after .tl_gset:N = \g_@@_code_after_tl , code-after .initial:n = \c_empty_tl , code-after .value_required:n = true , } @@ -2367,6 +2475,12 @@ version 2005/12/01 or later. % % \bigskip % \begin{macrocode} + letter-for-dotted-lines .tl_set:N = \l_@@_letter_for_dotted_lines_str , + letter-for-dotted-lines .value_required:n = true , + letter-for-dotted-lines .initial:n = \c_colon_str , +% \end{macrocode} +% \bigskip +% \begin{macrocode} unknown .code:n = \@@_error:n { Unknown~key~for~NiceMatrixOptions } } % \end{macrocode} % @@ -2385,6 +2499,7 @@ version 2005/12/01 or later. code-for-last-col,~ exterior-arraycolsep,~ left-margin,~ + letter-for-dotted-lines,~ nullify-dots,~ parallelize-diags,~ renew-dots,~ @@ -2657,7 +2772,7 @@ version 2005/12/01 or later. \@@_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. } % \end{macrocode} @@ -2712,7 +2827,78 @@ version 2005/12/01 or later. } % \end{macrocode} % -% +% \bigskip +% In the environment |{NiceArray}|, we will have to redefine the column types +% |w| and |W|. These definitions are rather long because we have to construct +% the |w|-nodes in these columns. The redefinition of these two column types are +% very close and that's why we use a macro |\@@_renewcolumntype:nn|. The first +% argument is the type of the column (|w| or |W|) and the second argument is a +% code inserted at a special place and which is the only difference between the +% two definitions. +% \begin{macrocode} +\cs_new_protected:Nn \@@_renewcolumntype:nn + { + \newcolumntype #1 [ 2 ] + { + > { + \hbox_set:Nw \l_tmpa_box + \@@_Cell: + } + c + < { + \@@_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 (@@~north~east) ; + } + \hbox:n + { + \tikz [ remember~picture , overlay ] + \coordinate (@@~south~west) ; + \box_move_up:nn \l_tmpa_dim { \box_use:N \l_tmpb_box } + } + } + } +% \end{macrocode} +% The |w|-node is created using the Tikz library |fit| after construction of the +% nodes |(@@~south~west)| and |(@@~north~east)|. It's not possible to contruct +% by a standard |node| instruction because such a construction give a erroneous +% result with some engines (|XeTeX|, |LuaTeX|) although the result is good with +% |pdflatex| (why?). +% \begin{macrocode} + \tikz [ remember~picture , overlay ] + \node + [ + node~contents = { } , + name = nm - \int_use:N \g_@@_env_int - + \int_use:N \g_@@_row_int - + \int_use:N \g_@@_column_int - w, + alias = + \str_if_empty:NF \l_@@_name_str + { + \l_@@_name_str - + \int_use:N \g_@@_row_int - + \int_use:N \g_@@_column_int - w + } , + inner~sep = \c_zero_dim , + fit = (@@~south~west) (@@~north~east) + ] + ; + } + } + } +% \end{macrocode} +% % \bigskip % First, we test if we are yet in an environment |{NiceArray}| (nested % environments are forbidden). @@ -2785,7 +2971,7 @@ version 2005/12/01 or later. } } % \end{macrocode} -% We don't want to patch any code and that's why some code is excuted in a +% We don't want to patch any code and that's why some code is executed in a % |\group_insert_after:N|. In particular, in this |\group_insert_after:N|, we % will have to know the value of some parameters like |\l_@@_extra_nodes_bool|. % That's why we transit via a global version for some variables. @@ -2794,7 +2980,6 @@ version 2005/12/01 or later. \dim_gset_eq:NN \g_@@_left_margin_dim \l_@@_left_margin_dim \dim_gset_eq:NN \g_@@_right_margin_dim \l_@@_right_margin_dim \dim_gset_eq:NN \g_@@_extra_right_margin_dim \l_@@_extra_right_margin_dim - \tl_gset_eq:NN \g_@@_code_after_tl \l_@@_code_after_tl \tl_gset_eq:NN \g_@@_name_str \l_@@_name_str % \end{macrocode} % The environment |{array}| uses internally the command |\ialign| and, in @@ -2842,9 +3027,10 @@ version 2005/12/01 or later. } % \end{macrocode} % -% We nullify the definitions of the column types |w| and |W| because we want to -% avoid a warning in the log file for a redefinition of a column type. We must -% put |\relax| and not |\prg_do_nothing:|. +% +% We nullify the definitions of the column types |w| and |W| before their +% redefinition because we want to avoid a warning in the log file for a +% redefinition of a column type. We must put |\relax| and not |\prg_do_nothing:|. % \begin{macrocode} \cs_set_eq:NN \NC@find@w \relax \cs_set_eq:NN \NC@find@W \relax @@ -2852,33 +3038,43 @@ version 2005/12/01 or later. % % We redefine the column types |w| and |W| of the package \pkg{array}. % \begin{macrocode} - \newcolumntype w [ 2 ] - { - > { - \hbox_set:Nw \l_tmpa_box - \@@_Cell:} - c - < { - \@@_end_Cell: - \hbox_set_end: - \makebox [ ##2 ] [ ##1 ] { \box_use:N \l_tmpa_box } - } - } - \newcolumntype W [ 2 ] - { - > { - \hbox_set:Nw \l_tmpa_box - \@@_Cell: + \@@_renewcolumntype:nn w { } + \@@_renewcolumntype:nn W { \cs_set_eq:NN \hss \hfil } +% \end{macrocode} +% +% \bigskip +% By default, the letter used to specify a dotted line in the preamble of an +% environment of \pkg{nicematrix} (for example in |{pNiceArray}|) is the letter +% |:|. However, this letter is used by some extensions, for example +% \pkg{arydshln}. That's why it's possible to change the letter used by +% \pkg{nicematrix} with the option |letter-for-dotted-lines| which changes the +% value of |\l_@@_letter_for_dotted_lines_str|. +% \begin{macrocode} + \exp_args:Nx \newcolumntype \l_@@_letter_for_dotted_lines_str + { + ! + { + \skip_horizontal:n { 0.53 pt } + \bool_gset_true:N \g_@@_extra_nodes_bool + \int_compare:nNnT \g_@@_row_int = 1 + { + \int_compare:nNnTF \g_@@_column_int = \c_zero_dim + { \@@_error:n { Use~of~:~in~first~position } } + { + \tl_gput_right:Nx \g_@@_code_after_tl + { + \exp_not:N \@@_vdottedline:n + \exp_not:N { + \int_use:N \g_@@_column_int + \exp_not:N } + } + } + } } - c - < { - \@@_end_Cell: - \hbox_set_end: - \cs_set_eq:NN \hss \hfil - \makebox [ ##2 ] [ ##1 ] { \box_use:N \l_tmpa_box } - } - } + } % \end{macrocode} +% +% % % The commands |\Ldots|, |\Cdots|, etc. will be defined only in the environment % |{NiceArray}|. If the class option |draft| is used, these commands will be @@ -2887,6 +3083,7 @@ version 2005/12/01 or later. \bool_if:NTF \c_@@_draft_bool \@@_define_dots_to_nil: \@@_define_dots: + \cs_set_eq:NN \hdottedline \@@_hdottedline: \cs_set_eq:NN \Hspace \@@_Hspace: \cs_set_eq:NN \Hdotsfor \@@_Hdotsfor \cs_set_eq:NN \multicolumn \@@_multicolumn:nnn @@ -3236,6 +3433,7 @@ version 2005/12/01 or later. } \cs_set_eq:NN \line \@@_line:nn \g_@@_code_after_tl + \tl_gclear:N \g_@@_code_after_tl \group_end: } % \end{macrocode} @@ -3731,7 +3929,7 @@ version 2005/12/01 or later. } } % \end{macrocode} -% We draw only if the length is not equel to zero (in fact, in the first +% We draw only if the length is not equal to zero (in fact, in the first % compilation, the length may be equal to zero). % \begin{macrocode} \dim_compare:nNnF \l_@@_l_dim = \c_zero_dim @@ -3757,7 +3955,8 @@ version 2005/12/01 or later. \int_set:Nn \l_tmpa_int { \dim_ratio:nn { \l_@@_l_dim - 0.3 em } { 0.45 em } } } - { \int_set:Nn \l_tmpa_int + { + \int_set:Nn \l_tmpa_int { \dim_ratio:nn { \l_@@_l_dim - 0.6 em } { 0.45 em }} } } @@ -4037,12 +4236,159 @@ version 2005/12/01 or later. } % \end{macrocode} % -% The commands |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots|, |\Iddots| don't use this -% command because they have to do other settings (for example, the diagonal +% The commands |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots|, and |\Iddots| don't use +% this command because they have to do other settings (for example, the diagonal % lines must be parallelized). % +% \bigskip +% \subsection{The commands to draw dotted lines to separate columns and rows} +% +% The command |\hdottedline| draws a horizontal dotted line to separate two +% rows. Similarly, the letter ``:'' in the preamble draws a vertical dotted line +% (the letter can be changed with the option |letter-for-dotted-lines|). Both +% mechanisms write instructions in the |code-after|. The actual instructions in +% the |code-after| use the commands |\@@_hdottedline:n| and |\@@_vdottedline:n|. +% +% \bigskip % +% The following command must \emph{not} be protected because it starts with |\noalign|. +% \begin{macrocode} +\cs_new:Nn \@@_hdottedline: + { + \noalign { \skip_vertical:n { 0.53 pt } } + \@@_hdottedline_i: + } +% \end{macrocode} % +% \begin{macrocode} +\cs_new_protected:Nn \@@_hdottedline_i: + { + \int_compare:nNnTF \g_@@_row_int < 2 + { \@@_error:n { Use~of~hdottedline~in~first~position } } + { + \bool_gset_true:N \g_@@_extra_nodes_bool + \bool_if:NF \c_@@_draft_bool + { + \tl_gput_right:Nx \g_@@_code_after_tl + { + \exp_not:N \@@_hdottedline:n + \exp_not:N { + \int_eval:n { \g_@@_row_int - 1 } + \exp_not:N } + } + } + } + } +% \end{macrocode} +% +% The argument of |\@@_hdottedline:n| is the number of the row \emph{after} which +% we have to draw a dotted line. +% \begin{macrocode} +\cs_new_protected:Nn \@@_hdottedline:n + { + \@@_create_extra_nodes: + \dim_zero_new:N \g_@@_x_initial_dim + \dim_zero_new:N \g_@@_y_initial_dim + \dim_zero_new:N \g_@@_x_final_dim + \dim_zero_new:N \g_@@_y_final_dim + \bool_set_true:N \l_@@_initial_open_bool + \bool_set_true:N \l_@@_final_open_bool + \begin { tikzpicture } [ remember~picture ] + \tikz@parse@node\pgfutil@firstofone + ( #1 - 1 -large .south~west ) + \dim_gset:Nn \g_@@_x_initial_dim \pgf@x + \dim_gset:Nn \g_@@_y_initial_dim \pgf@y + \tikz@parse@node\pgfutil@firstofone + ( #1 - \int_use:N \g_@@_column_int -large .south~east ) + \dim_gset:Nn \g_@@_x_final_dim \pgf@x + \dim_gset:Nn \g_@@_y_final_dim \pgf@y + \end { tikzpicture } + \@@_draw_tikz_line: + } +% \end{macrocode} +% +% \begin{macrocode} +\@@_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. + } +% \end{macrocode} +% +% +% \bigskip +% \begin{macrocode} +\cs_new_protected:Nn \@@_vdottedline:n + { +% \end{macrocode} +% The following test is a security: normally, the error should have been capted +% before. +% \begin{macrocode} + \int_compare:nNnTF #1 = \c_zero_int + { \@@_error:n { Use~of~:~in~first~position } } + { + \@@_create_extra_nodes: + \bool_if:NF \c_@@_draft_bool + { + \dim_zero_new:N \g_@@_x_initial_dim + \dim_zero_new:N \g_@@_y_initial_dim + \dim_zero_new:N \g_@@_x_final_dim + \dim_zero_new:N \g_@@_y_final_dim + \bool_set_true:N \l_@@_initial_open_bool + \bool_set_true:N \l_@@_final_open_bool +% \end{macrocode} +% If the |w|-nodes are created in the previous column (that is if the previous +% column was constructed explicitly of implicitly with a letter |w|), we use +% that column in order to have the dotted lines perfectly aligned when we use +% the environment |{NiceMatrixBlock}| with the option |auto-columns-width|. +% \begin{macrocode} + \cs_if_exist:cTF + { pgf@sh@ns@nm -\int_use:N \g_@@_env_int - 1 - #1 - w } + { + \begin { tikzpicture } [ remember~picture ] + \tikz@parse@node\pgfutil@firstofone + ( 1 - #1 - w .north~east ) + \dim_gset:Nn \g_@@_x_initial_dim \pgf@x + \dim_gset:Nn \g_@@_y_initial_dim \pgf@y + \tikz@parse@node\pgfutil@firstofone + ( \int_use:N \g_@@_row_int - #1 - w .south~east ) + \dim_gset:Nn \g_@@_x_final_dim \pgf@x + \dim_gset:Nn \g_@@_y_final_dim \pgf@y + \end { tikzpicture } + \dim_gadd:Nn \g_@@_x_initial_dim \arraycolsep + \dim_gadd:Nn \g_@@_x_final_dim \arraycolsep + } + { + \begin { tikzpicture } [ remember~picture ] + \tikz@parse@node\pgfutil@firstofone + ( 1 - #1 - large .north~east ) + \dim_gset:Nn \g_@@_x_initial_dim \pgf@x + \dim_gset:Nn \g_@@_y_initial_dim \pgf@y + \tikz@parse@node\pgfutil@firstofone + ( \int_use:N \g_@@_row_int - #1 - large .south~east ) + \dim_gset:Nn \g_@@_x_final_dim \pgf@x + \dim_gset:Nn \g_@@_y_final_dim \pgf@y + \end { tikzpicture } + } + \@@_draw_tikz_line: + } + } + } +% \end{macrocode} +% +% +% \begin{macrocode} +\@@_msg_new:nn { Use~of~:~in~first~position } + { + You~can't~use~the~column~specifier~"\l_@@_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. + } +% \end{macrocode} +% +% +% % \subsection{The environment \{NiceMatrixBlock\}} % % The following flag will be raised when all the columns of the environments of @@ -4845,6 +5191,16 @@ version 2005/12/01 or later. % % Option |allow-duplicate-names|. % +% \subsection{Changes between version 2.1.5 and 2.2} +% +% Possibility to draw horizontal dotted lines to separate rows with the command +% |\hdottedline| (similar to the classical command |\hline| and the command +% |\hdashline| of \pkg{arydshln}). +% +% Possibility to draw vertical dotted lines to separate columns with the +% specifier ``|:|'' in the preamble (similar to the classical specifier +% ``\verb+|+'' and the specifier ``|:|'' of \pkg{arydshln}). +% % \endinput % Local Variables: % TeX-fold-mode: nil 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 } { |