diff options
author | Karl Berry <karl@freefriends.org> | 2021-01-08 23:35:47 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-01-08 23:35:47 +0000 |
commit | eb963ac14509494146101b4eaf83ef0f3af89ea6 (patch) | |
tree | 317e8af197c629ed3c8c41c63505d8c705b9d6e7 /Master/texmf-dist/source/latex | |
parent | 2df956a8c8e5ea708f70d1e8185cfe0c3f412e1b (diff) |
nicematrix (9jan21)
git-svn-id: svn://tug.org/texlive/trunk@57352 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex')
-rw-r--r-- | Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx | 577 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/nicematrix/nicematrix.ins | 4 |
2 files changed, 312 insertions, 269 deletions
diff --git a/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx b/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx index 83f99f5cbd1..c6f1a06f31a 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{5.8} -\def\myfiledate{2021/01/01} +\def\myfileversion{5.9} +\def\myfiledate{2021/01/08} % % %<*batchfile> @@ -279,17 +279,22 @@ version 2005/12/01 or later. % Inspired by the package \pkg{cellspace} which deals with that problem, the % package \pkg{nicematrix} provides two keys |cell-space-top-limit| and % |cell-space-bottom-limit| similar to the parameters |\cellspacetoplimit| and -% |\cellspacebottomlimit| of \pkg{cellspace}. The initial value of these -% parameters is $0$~pt in order to have for the environments of \pkg{nicematrix} -% the same behaviour as those of \pkg{array} and \pkg{amsmath}. However, a value -% of $1$~pt would probably be a good choice and we suggest to set them with -% |\NiceMatrixOptions|.\footnote{One should remark that these parameters apply -% also to the columns of type |S| of \pkg{siunitx} whereas the package -% \pkg{cellspace} is not able to act on such columns of type~|S|.} +% |\cellspacebottomlimit| of \pkg{cellspace}. +% +% \colorbox{yellow!50}{\bfseries{New 5.9}}\enskip +% There is also a key |cell-space-limits| to set both parameters at once. +% +% The initial value of these parameters is $0$~pt in order to have for the +% environments of \pkg{nicematrix} the same behaviour as those of \pkg{array} +% and \pkg{amsmath}. However, a value of $1$~pt would probably be a good choice +% and we suggest to set them with |\NiceMatrixOptions|.\footnote{One should +% remark that these parameters apply also to the columns of type |S| of +% \pkg{siunitx} whereas the package \pkg{cellspace} is not able to act on such +% columns of type~|S|.} % % \medskip % \begin{Verbatim} -% \NiceMatrixOptions{~emphase#cell-space-top-limit = 1pt,cell-space-bottom-limit = 1pt@} +% \NiceMatrixOptions{~emphase#cell-space-limits = 1pt@} % \end{Verbatim} % % \begin{BVerbatim}[baseline=c,boxwidth=9cm] @@ -299,10 +304,7 @@ version 2005/12/01 or later. % \end{pNiceMatrix}$ % \end{BVerbatim} % \begin{scope} -% \NiceMatrixOptions{ -% cell-space-top-limit = 1pt , -% cell-space-bottom-limit = 1pt , -% } +% \NiceMatrixOptions{cell-space-limits = 1pt} % $\begin{pNiceMatrix} % \frac12 & -\frac12 \\ % \frac13 & \frac14 \\ @@ -419,7 +421,7 @@ version 2005/12/01 or later. % % \smallskip % \begin{Verbatim} -% \NiceMatrixOptions{cell-space-top-limit=1pt,cell-space-bottom-limit=1pt} +% \NiceMatrixOptions{cell-space-limits=1pt} % \end{Verbatim} % % \smallskip @@ -433,7 +435,7 @@ version 2005/12/01 or later. % \end{pNiceArray}$ % \end{BVerbatim} % \begin{scope} -% \NiceMatrixOptions{cell-space-top-limit=1pt,cell-space-bottom-limit=1pt} +% \NiceMatrixOptions{cell-space-limits=1pt} % \raisebox{-5mm}{$A=\begin{pNiceArray}{cc|cc}[baseline=line-3] % \dfrac1A & \dfrac1B & 0 & 0 \\ % \dfrac1C & \dfrac1D & 0 & 0 \\ @@ -461,9 +463,9 @@ version 2005/12/01 or later. % $i$\verb|-|$j$ where $i$ is the number of rows of the block and $j$ its number % of columns. % -% \colorbox{yellow!30}{New 5.6}\enskip If this argument is empty, its -% default value is |1-1|. If the number of rows is not specified, the block -% extends until the last row (idem for the columns). +% If this argument is empty, its default +% value is |1-1|. If the number of rows is not specified, or equal to |*|, the +% block extends until the last row (idem for the columns). % % \item The second argument is the content of the block. It's possible to use % |\\| in that content to have a content on several lines. In |{NiceTabular}| @@ -579,11 +581,11 @@ version 2005/12/01 or later. % \end{NiceTabular} % \end{center} % -% \colorbox{yellow!50}{\bfseries New 5.7}\enskip As we can see on this example, -% it's possible to fill the block by using the key |fill| and to draw the frame -% with the key |draw|\footnote{If the key |draw| is used without value, the -% default color the rules of the tabulars is used}. It's also possible to change -% the width (thickness) of that rules with the key |line-width|. +% \colorbox{yellow!30}{New 5.7}\enskip As we can see on this example, it's +% possible to fill the block by using the key |fill| and to draw the frame with +% the key |draw|\footnote{If the key |draw| is used without value, the default +% color the rules of the tabulars is used}. It's also possible to change the +% width (thickness) of that rules with the key |line-width|. % % \subsection{The mono-column blocks} % @@ -636,9 +638,9 @@ version 2005/12/01 or later. % % \subsection{The mono-row blocks} % -% \colorbox{yellow!30}{New 5.6}\enskip For the mono-row blocks, the -% natural height and depth are taken into account for the height and depth of -% the current row (as does a standard |\multicolumn| of LaTeX). +% For the mono-row blocks, the natural height and depth are taken into account +% for the height and depth of the current row (as does a standard |\multicolumn| +% of LaTeX). % % \subsection{The mono-cell blocks} % @@ -1205,10 +1207,6 @@ version 2005/12/01 or later. % \end{NiceTabular} % \end{scope} % -% \medskip -% A command |\cellcolor| generates only one instruction |fill| (coded |f|) in the -% resulting \textsc{pdf}. -% % \bigskip % \item The command |\rectanglecolor| takes three mandatory arguments. The first % is the color. The second is the upper-left cell of the rectangle and the third @@ -1274,10 +1272,6 @@ version 2005/12/01 or later. % \end{NiceArray}$ % \end{scope} % -% \medskip -% A command |\rowcolor| generates only one instruction |fill| (coded |f|) in the -% resulting \textsc{pdf}. -% % % \bigskip % \item The command |\columncolor| takes its name from the command @@ -1323,7 +1317,7 @@ version 2005/12/01 or later. % \begin{BVerbatim}[baseline=c,boxwidth=10cm] % \begin{NiceTabular}{clr} % [hvlines,code-before = ~emphase#{\rowcolors{2}{blue!10}{}[cols=2-3,restart]}@] -% \Block{1-3}{Results} \\ +% \Block{1-}{Results} \\ % John & 12 \\ % Stephen & 8 \\ % Sarah & 18 \\ @@ -1334,7 +1328,7 @@ version 2005/12/01 or later. % \end{BVerbatim} % \begin{NiceTabular}{clr}[hvlines,code-before = % {\rowcolors{2}{blue!10}{}[cols=2-3,restart]},baseline=2] -% \Block{1-3}{Results} \\ +% \Block{1-}{Results} \\ % \Block{2-1}{A}& John & 12 \\ % & Stephen & 8 \\ % \Block{4-1}{B}& Sarah & 18 \\ @@ -1503,47 +1497,6 @@ version 2005/12/01 or later. % \end{NiceTabular} % \end{center} % -% \medskip -% Each instruction |\cellcolor|, |\rowcolor| or |\columncolor| will generate an -% instruction |fill| (coded~|f|) in the resulting \textsc{pdf}. In cases of -% juxtaposed colored rectangles, one may have a thin white color line in some -% \textsc{pdf} viewers\footnote{For example SumatraPDF, which uses MuPDF -% of Artifex Software, or PDF.js used by Firefox.} (between the -% two first columns in the above example). In you want to avoid this problem, -% you should use the tools in the |code-before|. That's what we do with the -% following code. -% -% -% \medskip -% \begin{Verbatim} -% \begin{NiceTabular}[colortbl-like]{ccc}% -% [code-before = ~emphase#\columncolor{blue!15}{1,2}@] -% \toprule -% \rowcolor{red!15} -% Last name & First name & Birth day \\ -% \midrule -% Achard & Jacques & 5 juin 1962 \\ -% Lefebvre & Mathilde & 23 mai 1988 \\ -% Vanesse & Stephany & 30 octobre 1994 \\ -% Dupont & Chantal & 15 janvier 1998 \\ -% \bottomrule -% \end{NiceTabular} -% \end{Verbatim} -% -% -% \begin{center} -% \begin{NiceTabular}[colortbl-like]{ccc}[code-before = \columncolor{blue!15}{1,2}] -% \toprule -% \rowcolor{red!15} -% Last name & First name & Birth day \\ -% \midrule -% Achard & Jacques & 5 juin 1962 \\ -% Lefebvre & Mathilde & 23 mai 1988 \\ -% Vanesse & Stephany & 30 octobre 1994 \\ -% Dupont & Chantal & 15 janvier 1998 \\ -% \bottomrule -% \end{NiceTabular} -% \end{center} % % \section{The width of the columns} % \label{width} @@ -2353,9 +2306,7 @@ version 2005/12/01 or later. % For the legibility of the code, an alternative syntax is provided: it's % possible to give the instructions of the |\code-after| at the end of the % environment, after the keyword |\CodeAfter| (for an example, cf. -% p.~\pageref{example-CodeAfter}). \colorbox{yellow!30}{New 5.5}\enskip -% Before the version 5.5, it was necessary, in some circonstancies, to put the -% keyword |\omit| before |\CodeAfter|. Since version~5.5, one must never put~|\omit|. +% p.~\pageref{example-CodeAfter}). % % % @@ -3016,7 +2967,6 @@ version 2005/12/01 or later. % \textbf{Caution} : By default, no node is created in a empty cell. % % \smallskip -% \colorbox{yellow!30}{New 5.6}\enskip % However, it's possible to impose the creation of a node with the command |\NotEmpty|. % \footnote{One should note that, with that command, the cell is considered as % non-empty, which has consequencies for the continuous dotted lines (cf. @@ -5797,7 +5747,7 @@ version 2005/12/01 or later. % contain an integer (which represents the number of the row to which align the % array). % \begin{macrocode} -\str_new:N \l_@@_baseline_tl +\tl_new:N \l_@@_baseline_tl \tl_set:Nn \l_@@_baseline_tl c % \end{macrocode} % @@ -6005,6 +5955,12 @@ version 2005/12/01 or later. cell-space-top-limit .value_required:n = true , cell-space-bottom-limit .dim_set:N = \l_@@_cell_space_bottom_limit_dim , cell-space-bottom-limit .value_required:n = true , + cell-space-limits .code:n = + { + \dim_set:Nn \l_@@_cell_space_bottom_limit_dim { #1 } + \dim_set:Nn \l_@@_cell_space_top_limit_dim { #1 } + } , + cell-spaces-limits .value_required:n = true , xdots .code:n = \keys_set:nn { NiceMatrix / xdots } { #1 } , max-delimiter-width .bool_set:N = \l_@@_max_delimiter_width_bool , light-syntax .bool_set:N = \l_@@_light_syntax_bool , @@ -7282,7 +7238,9 @@ version 2005/12/01 or later. % by the user between instructions in the |code-before|. % \begin{macrocode} \bool_if:NT \l_@@_NiceTabular_bool \c_math_toggle_token + \seq_clear_new:N \l_@@_colors_seq \l_@@_code_before_tl + \@@_actually_color: \bool_if:NT \l_@@_NiceTabular_bool \c_math_toggle_token \group_end: } @@ -8329,9 +8287,9 @@ version 2005/12/01 or later. \tl_if_empty:nT { #1 } { \@@_fatal:n { empty~environment } } \tl_map_inline:nn { #1 } { - \tl_if_eq:nnT { ##1 } { & } + \str_if_eq:nnT { ##1 } { & } { \@@_fatal:n { ampersand~in~light-syntax } } - \tl_if_eq:nnT { ##1 } { \\ } + \str_if_eq:nnT { ##1 } { \\ } { \@@_fatal:n { double-backslash~in~light-syntax } } } % \end{macrocode} @@ -10012,59 +9970,6 @@ version 2005/12/01 or later. % \begin{macrocode} \cs_new_protected:Npn \@@_draw_line: { - \pgfrememberpicturepositiononpagetrue - \pgf@relevantforpicturesizefalse - \tl_if_eq:NNTF \l_@@_xdots_line_style_tl \c_@@_standard_tl - \@@_draw_standard_dotted_line: - \@@_draw_non_standard_dotted_line: - } -% \end{macrocode} -% -% \medskip -% We have to do a special construction with |\exp_args:NV| to be able to put in -% the list of options in the correct place in the Tikz instruction. -% \begin{macrocode} -\cs_new_protected:Npn \@@_draw_non_standard_dotted_line: - { - \begin { scope } - \exp_args:No \@@_draw_non_standard_dotted_line:n - { \l_@@_xdots_line_style_tl , \l_@@_xdots_color_tl } - } -% \end{macrocode} -% We have used the fact that, in \textsc{pgf}, un color name can be put directly -% in a list of options (that's why we have put diredtly |\l_@@_xdots_color_tl|). -% -% \smallskip -% The argument of |\@@_draw_non_standard_dotted_line:n| is, in fact, the list of options. -% \begin{macrocode} -\cs_new_protected:Npn \@@_draw_non_standard_dotted_line:n #1 - { - \draw - [ - #1 , - shorten~> = \l_@@_xdots_shorten_dim , - shorten~< = \l_@@_xdots_shorten_dim , - ] - ( \l_@@_x_initial_dim , \l_@@_y_initial_dim ) - -- node [ sloped , above ] - { \c_math_toggle_token \scriptstyle \l_@@_xdots_up_tl \c_math_toggle_token } - node [ sloped , below ] - { - \c_math_toggle_token - \scriptstyle \l_@@_xdots_down_tl - \c_math_toggle_token - } - ( \l_@@_x_final_dim , \l_@@_y_final_dim ) ; - \end { scope } - } -% \end{macrocode} -% -% \bigskip -% The command |\@@_draw_standard_dotted_line:| draws the line with our system of points -% (which give a dotted line with real round points). -% \begin{macrocode} -\cs_new_protected:Npn \@@_draw_standard_dotted_line: - { % \end{macrocode} % First, we put the labels. % \begin{macrocode} @@ -10114,6 +10019,50 @@ version 2005/12/01 or later. } \pgfrememberpicturepositiononpagetrue \pgf@relevantforpicturesizefalse + \tl_if_eq:NNTF \l_@@_xdots_line_style_tl \c_@@_standard_tl + \@@_draw_standard_dotted_line: + \@@_draw_non_standard_dotted_line: + } +% \end{macrocode} +% +% \medskip +% We have to do a special construction with |\exp_args:NV| to be able to put in +% the list of options in the correct place in the Tikz instruction. +% \begin{macrocode} +\cs_new_protected:Npn \@@_draw_non_standard_dotted_line: + { + \begin { scope } + \exp_args:No \@@_draw_non_standard_dotted_line:n + { \l_@@_xdots_line_style_tl , \l_@@_xdots_color_tl } + } +% \end{macrocode} +% We have used the fact that, in \textsc{pgf}, un color name can be put directly +% in a list of options (that's why we have put diredtly |\l_@@_xdots_color_tl|). +% +% \smallskip +% The argument of |\@@_draw_non_standard_dotted_line:n| is, in fact, the list of options. +% \begin{macrocode} +\cs_new_protected:Npn \@@_draw_non_standard_dotted_line:n #1 + { + \draw + [ + #1 , + shorten~> = \l_@@_xdots_shorten_dim , + shorten~< = \l_@@_xdots_shorten_dim , + ] + ( \l_@@_x_initial_dim , \l_@@_y_initial_dim ) + -- + ( \l_@@_x_final_dim , \l_@@_y_final_dim ) ; + \end { scope } + } +% \end{macrocode} +% +% \bigskip +% The command |\@@_draw_standard_dotted_line:| draws the line with our system of points +% (which give a dotted line with real round points). +% \begin{macrocode} +\cs_new_protected:Npn \@@_draw_standard_dotted_line: + { \group_begin: % \end{macrocode} % The dimension |\l_@@_l_dim| is the length $\ell$ of the line to draw. We use @@ -10832,73 +10781,88 @@ version 2005/12/01 or later. % \bigskip % \subsection*{Colors of cells, rows and columns} % -% In the beginning of the |code-before|, the command |\@@_rowcolor:nn| will be -% linked to |\rowcolor| and the command |\@@_columncolor:nn| to |\columncolor|. +% We want to avoid the thin white lines that are shown in some \textsc{pdf} +% viewers (eg: with the engine MuPDF used by SumatraPDF). That's why we try to +% draw rectangles of the same color in the same instruction |\pgfusepathqfill| +% (and they will be in the same instruction |fill|---coded |f|--- in the +% resulting \textsc{pdf}). +% +% The commands |\@@_rowcolor|, |\@@_columncolor| and |\@@_rectanglecolor| +% (which are linked to |\rowcolor|, |\columncolor| and |\rectanglecolor| before +% the execution of the |code-before|) don't directly draw the corresponding +% rectangles. Instead, they store their instructions color by color: +% \begin{itemize} +% \item A sequence |\l_@@_colors_seq| will be built containing all the colors +% used by at least one of these instructions. Each \emph{color} may be prefixed +% by it color model (eg: |[gray]{0.5}|). +% \item For the color whose index in |\l_@@_colors_seq| is equal to~$i$, a list of +% instructions which use that color will be constructed in the token list +% |\l_@@_color_|$i$|_tl|. In that token list, the instructions will +% |\@@_rowcolor:n|, |\@@_columncolor:n| and |\@@_rectanglecolor:nn| +% (corresponding of |\@@_rowcolor|, |\@@_columncolor| and |\@@_rectanglecolor|). +% \end{itemize} +% % +% bigskip +% |#1| is the color and |#2| is an instruction using that color. Despite its +% name, the command |\@@_add_to_color_seq| doesn't only add a color to +% |\l_@@_colors_seq|: it also updates the corresponding token list +% |\l_@@_color_|$i$|_tl|. % \begin{macrocode} -\cs_set_protected:Npn \@@_cut_on_hyphen:w #1-#2\q_stop +\cs_new_protected:Npn \@@_add_to_colors_seq:nn #1 #2 { - \tl_set:Nn \l_tmpa_tl { #1 } - \tl_set:Nn \l_tmpb_tl { #2 } - } % \end{macrocode} -% -% \bigskip -% The following command uses two implicit arguments : |\l_@@_rows_tl| and -% |\l_@@_cols_tl| which are specifications for a set of row and a set of -% columns. The cartesian product is filled with the current color. +% Firt, we look for the number of the color and, if it's found, we store it in +% |\l_tmpa_int|. If the color is not present in |\l_@@_colors_seq|, +% |\l_tmpa_int| will remain equal to $0$. % \begin{macrocode} -\cs_new_protected:Npn \@@_cartesian_fill: - { + \int_zero:N \l_tmpa_int + \seq_map_indexed_inline:Nn \l_@@_colors_seq + { \tl_if_eq:nnT { #1 } { ##2 } { \int_set:Nn \l_tmpa_int { ##1 } } } + \int_compare:nNnTF \l_tmpa_int = \c_zero_int % \end{macrocode} -% We begin the loop over the columns. +% First, the case where the color is a \emph{new} color (not in the sequence). % \begin{macrocode} - \clist_map_inline:Nn \l_@@_cols_tl { - \tl_set:Nn \l_tmpa_tl { ##1 } - \tl_if_in:NnTF \l_tmpa_tl { - } - { \@@_cut_on_hyphen:w ##1 \q_stop } - { \@@_cut_on_hyphen:w ##1 - ##1 \q_stop } - \tl_if_empty:NT \l_tmpa_tl { \tl_set:Nn \l_tmpa_tl { 1 } } - \tl_if_empty:NT \l_tmpb_tl - { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } } - \int_compare:nNnT \l_tmpb_tl > \c@jCol - { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } } - \@@_qpoint:n { col - \l_tmpa_tl } - \bool_lazy_and:nnTF - { \str_if_eq_p:Vn \l_tmpa_tl 0 } - { \int_compare_p:nNn \l_@@_first_col_int > 0 } - { \dim_set:Nn \l_tmpc_dim { \pgf@x - 0.5 \arrayrulewidth } } - { \dim_set:Nn \l_tmpc_dim { \pgf@x + 0.5 \arrayrulewidth } } - \@@_qpoint:n { col - \@@_succ:n \l_tmpb_tl } - \dim_set:Nn \l_tmpa_dim { \pgf@x + 0.5 \arrayrulewidth } + \seq_put_right:Nn \l_@@_colors_seq { #1 } + \tl_set:cn { l_@@_color _ \seq_count:N \l_@@_colors_seq _ tl } { #2 } + } % \end{macrocode} -% We begin the loop over the rows +% Now, the case where the color is \emph{not} a new color (the color is in the +% sequence at the position |\l_tmpa_int|). % \begin{macrocode} - \clist_map_inline:Nn \l_@@_rows_tl - { - \tl_set:Nn \l_tmpa_tl { ####1 } - \tl_if_in:NnTF \l_tmpa_tl { - } - { \@@_cut_on_hyphen:w ####1 \q_stop } - { \@@_cut_on_hyphen:w ####1 - ####1 \q_stop } - \tl_if_empty:NT \l_tmpa_tl { \tl_set:Nn \l_tmpa_tl { 1 } } - \tl_if_empty:NT \l_tmpb_tl - { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@iRow } } - \int_compare:nNnT \l_tmpb_tl > \c@iRow - { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@iRow } } + { \tl_put_right:cn { l_@@_color _ \int_use:N \l_tmpa_int _tl } { #2 } } + } % \end{macrocode} -% Now, the numbers of both rows are in |\l_tmpa_tl| and |\l_tmpb_tl|. +% % \begin{macrocode} - \@@_qpoint:n { row - \@@_succ:n \l_tmpb_tl } - \dim_set:Nn \l_tmpb_dim { \pgf@y + 0.5 \arrayrulewidth } - \@@_qpoint:n { row - \l_tmpa_tl } - \dim_set:Nn \l_tmpd_dim { \pgf@y + 0.5 \arrayrulewidth } - \pgfpathrectanglecorners - { \pgfpoint \l_tmpc_dim \l_tmpd_dim } - { \pgfpoint \l_tmpa_dim \l_tmpb_dim } - } +\cs_generate_variant:Nn \@@_add_to_colors_seq:nn { x n } +% \end{macrocode} +% +% \bigskip +% The macro |\@@_actually_color:| will actually fill all the rectangles, color by +% color (using the sequence |\l_@@_colors_seq| and all the token lists of the +% form |\l_@@_color_|$i$|_tl|). +% \begin{macrocode} +\cs_new_protected:Npn \@@_actually_color: + { + \pgfpicture + \pgf@relevantforpicturesizefalse + \seq_map_indexed_inline:Nn \l_@@_colors_seq + { + \color ##2 + \use:c { l_@@_color _ ##1 _tl } + \pgfusepathqfill } - \pgfusepathqfill + \endpgfpicture + } +% \end{macrocode} +% +% \begin{macrocode} +\cs_set_protected:Npn \@@_cut_on_hyphen:w #1-#2\q_stop + { + \tl_set:Nn \l_tmpa_tl { #1 } + \tl_set:Nn \l_tmpb_tl { #2 } } % \end{macrocode} % @@ -10910,18 +10874,23 @@ version 2005/12/01 or later. { \tl_if_blank:nF { #2 } { - \pgfpicture - \pgf@relevantforpicturesizefalse - \tl_if_empty:nTF { #1 } \color { \color [ #1 ] } { #2 } - \tl_set:Nn \l_@@_rows_tl { #3 } - \tl_set:Nn \l_@@_cols_tl { - } + \@@_add_to_colors_seq:xn + { \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } } + { \@@_rowcolor:n { #3 } } + } + } +% \end{macrocode} +% +% \begin{macrocode} +\cs_new_protected:Npn \@@_rowcolor:n #1 + { + \tl_set:Nn \l_@@_rows_tl { #1 } + \tl_set:Nn \l_@@_cols_tl { - } % \end{macrocode} -% The command |\@@_cartesian_fill:| takes in two implicit arguments: +% The command |\@@_cartesian_path:| takes in two implicit arguments: % |\l_@@_cols_tl| and |\l_@@_row_tl|. % \begin{macrocode} - \@@_cartesian_fill: - \endpgfpicture - } + \@@_cartesian_path: } % \end{macrocode} % @@ -10933,18 +10902,22 @@ version 2005/12/01 or later. { \tl_if_blank:nF { #2 } { - \pgfpicture - \pgf@relevantforpicturesizefalse - \tl_if_empty:nTF { #1 } \color { \color [ #1 ] } { #2 } - \tl_set:Nn \l_@@_rows_tl { - } - \tl_set:Nn \l_@@_cols_tl { #3 } + \@@_add_to_colors_seq:xn + { \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } } + { \@@_columncolor:n { #3 } } + } + } +% \end{macrocode} +% \begin{macrocode} +\cs_new_protected:Npn \@@_columncolor:n #1 + { + \tl_set:Nn \l_@@_rows_tl { - } + \tl_set:Nn \l_@@_cols_tl { #1 } % \end{macrocode} -% The command |\@@_cartesian_fill:| takes in two implicit arguments: +% The command |\@@_cartesian_path:| takes in two implicit arguments: % |\l_@@_cols_tl| and |\l_@@_row_tl|. % \begin{macrocode} - \@@_cartesian_fill: - \endpgfpicture - } + \@@_cartesian_path: } % \end{macrocode} % @@ -10955,19 +10928,17 @@ version 2005/12/01 or later. \NewDocumentCommand \@@_rectanglecolor { O { } m m m } { \tl_if_blank:nF { #2 } - { - \pgfpicture - \pgf@relevantforpicturesizefalse - \tl_if_empty:nTF { #1 } \color { \color [ #1 ] } { #2 } - \@@_rectanglecolor_i:nn { #3 } { #4 } - \endpgfpicture + { + \@@_add_to_colors_seq:xn + { \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } } + { \@@_rectanglecolor:nn { #3 } { #4 } } } } % \end{macrocode} % % \bigskip % \begin{macrocode} -\cs_new_protected:Npn \@@_rectanglecolor_i:nn #1 #2 +\cs_new_protected:Npn \@@_rectanglecolor:nn #1 #2 { \@@_cut_on_hyphen:w #1 \q_stop \tl_clear_new:N \l_tmpc_tl @@ -10978,10 +10949,10 @@ version 2005/12/01 or later. \tl_set:Nx \l_@@_rows_tl { \l_tmpc_tl - \l_tmpa_tl } \tl_set:Nx \l_@@_cols_tl { \l_tmpd_tl - \l_tmpb_tl } % \end{macrocode} -% The command |\@@_cartesian_fill:| takes in two implicit arguments: +% The command |\@@_cartesian_path:| takes in two implicit arguments: % |\l_@@_cols_tl| and |\l_@@_row_tl|. % \begin{macrocode} - \@@_cartesian_fill: + \@@_cartesian_path: } % \end{macrocode} % @@ -10991,18 +10962,28 @@ version 2005/12/01 or later. % \begin{macrocode} \NewDocumentCommand \@@_cellcolor { O { } m m } { - \tl_if_blank:nF { #2 } + \clist_map_inline:nn { #3 } + { \@@_rectanglecolor [ #1 ] { #2 } { ##1 } { ##1 } } + } +% \end{macrocode} +% +% \bigskip +% \begin{macrocode} +\NewDocumentCommand \@@_chessboardcolors { O { } m m } + { + \int_step_inline:nn { \int_use:N \c@iRow } { - \pgfpicture - \pgf@relevantforpicturesizefalse - \tl_if_empty:nTF { #1 } \color { \color [ #1 ] } { #2 } - \clist_map_inline:nn { #3 } - { \@@_rectanglecolor_i:nn { ##1 } { ##1 } } - \pgfusepathqfill - \endpgfpicture - } + \int_step_inline:nn { \int_use:N \c@jCol } + { + \int_if_even:nTF { ####1 + ##1 } + { \@@_cellcolor [ #1 ] { #2 } } + { \@@_cellcolor [ #1 ] { #3 } } + { ##1 - ####1 } + } + } } % \end{macrocode} +% % % \bigskip % \begin{macrocode} @@ -11112,10 +11093,11 @@ version 2005/12/01 or later. { \color [ #1 ] } { #3 } % \end{macrocode} -% The command |\@@_cartesian_fill:| takes in two implicit arguments: +% The command |\@@_cartesian_path:| takes in two implicit arguments: % |\l_@@_cols_tl| and |\l_@@_row_tl|. % \begin{macrocode} - \@@_cartesian_fill: + \@@_cartesian_path: + \pgfusepathqfill } \bool_set_false:N \l_tmpa_bool } @@ -11127,10 +11109,11 @@ version 2005/12/01 or later. { \color [ #1 ] } { #4 } % \end{macrocode} -% The command |\@@_cartesian_fill:| takes in two implicit arguments: +% The command |\@@_cartesian_path:| takes in two implicit arguments: % |\l_@@_cols_tl| and |\l_@@_row_tl|. % \begin{macrocode} - \@@_cartesian_fill: + \@@_cartesian_path: + \pgfusepathqfill } \bool_set_true:N \l_tmpa_bool } @@ -11182,23 +11165,65 @@ version 2005/12/01 or later. % \end{macrocode} % % +% % \bigskip +% The following command uses two implicit arguments : |\l_@@_rows_tl| and +% |\l_@@_cols_tl| which are specifications for a set of rows and a set of +% columns. It creates a path but does \emph{not} fill it. It must be filled by +% another command after. % \begin{macrocode} -\NewDocumentCommand \@@_chessboardcolors { O { } m m } - { - \int_step_inline:nn { \int_use:N \c@iRow } +\cs_new_protected:Npn \@@_cartesian_path: + { +% \end{macrocode} +% We begin the loop over the columns. +% \begin{macrocode} + \clist_map_inline:Nn \l_@@_cols_tl { - \int_step_inline:nn { \int_use:N \c@jCol } - { - \int_if_even:nTF { ####1 + ##1 } - { \@@_cellcolor [ #1 ] { #2 } } - { \@@_cellcolor [ #1 ] { #3 } } - { ##1 - ####1 } + \tl_set:Nn \l_tmpa_tl { ##1 } + \tl_if_in:NnTF \l_tmpa_tl { - } + { \@@_cut_on_hyphen:w ##1 \q_stop } + { \@@_cut_on_hyphen:w ##1 - ##1 \q_stop } + \tl_if_empty:NT \l_tmpa_tl { \tl_set:Nn \l_tmpa_tl { 1 } } + \tl_if_empty:NT \l_tmpb_tl + { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } } + \int_compare:nNnT \l_tmpb_tl > \c@jCol + { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } } + \@@_qpoint:n { col - \l_tmpa_tl } + \int_compare:nNnTF \l_@@_first_col_int = \l_tmpa_tl + { \dim_set:Nn \l_tmpc_dim { \pgf@x - 0.5 \arrayrulewidth } } + { \dim_set:Nn \l_tmpc_dim { \pgf@x + 0.5 \arrayrulewidth } } + \@@_qpoint:n { col - \@@_succ:n \l_tmpb_tl } + \dim_set:Nn \l_tmpa_dim { \pgf@x + 0.5 \arrayrulewidth } +% \end{macrocode} +% We begin the loop over the rows +% \begin{macrocode} + \clist_map_inline:Nn \l_@@_rows_tl + { + \tl_set:Nn \l_tmpa_tl { ####1 } + \tl_if_in:NnTF \l_tmpa_tl { - } + { \@@_cut_on_hyphen:w ####1 \q_stop } + { \@@_cut_on_hyphen:w ####1 - ####1 \q_stop } + \tl_if_empty:NT \l_tmpa_tl { \tl_set:Nn \l_tmpa_tl { 1 } } + \tl_if_empty:NT \l_tmpb_tl + { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@iRow } } + \int_compare:nNnT \l_tmpb_tl > \c@iRow + { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@iRow } } +% \end{macrocode} +% Now, the numbers of both rows are in |\l_tmpa_tl| and |\l_tmpb_tl|. +% \begin{macrocode} + \@@_qpoint:n { row - \@@_succ:n \l_tmpb_tl } + \dim_set:Nn \l_tmpb_dim { \pgf@y + 0.5 \arrayrulewidth } + \@@_qpoint:n { row - \l_tmpa_tl } + \dim_set:Nn \l_tmpd_dim { \pgf@y + 0.5 \arrayrulewidth } + \pgfpathrectanglecorners + { \pgfpoint \l_tmpc_dim \l_tmpd_dim } + { \pgfpoint \l_tmpa_dim \l_tmpb_dim } } - } + } } % \end{macrocode} % +% % \bigskip % When the user uses the key |colortbl-like|, the following command will % be linked to |\cellcolor| in the tabular. @@ -11211,7 +11236,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% When the user uses the key |rowcolor-in-tabular|, the following command will +% When the user uses the key |colortbll-like|, the following command will % be linked to |\rowcolor| in the tabular. % \begin{macrocode} \NewDocumentCommand \@@_rowcolor_tabular { O { } m } @@ -12646,8 +12671,27 @@ version 2005/12/01 or later. { % \end{macrocode} % +% \medskip +% We recall that |#1| and |#2| have been extracted from the first mandatory +% argument of |\Block| (which is of the syntax $i$|-|$j$). However, the user is +% allowed to omit $i$ or $j$ (or both). We detect that situation by replacing a +% missing value by 100 (it's a convention: when the block will actually be drawn +% these values will be detected and interpreted as \emph{maximal possible value}). +% \begin{macrocode} + \bool_lazy_or:nnTF + { \tl_if_blank_p:n { #1 } } + { \str_if_eq_p:nn { #1 } { * } } + { \int_set:Nn \l_tmpa_int { 100 } } + { \int_set:Nn \l_tmpa_int { #1 } } + \bool_lazy_or:nnTF + { \tl_if_blank_p:n { #2 } } + { \str_if_eq_p:nn { #2 } { * } } + { \int_set:Nn \l_tmpb_int { 100 } } + { \int_set:Nn \l_tmpb_int { #2 } } +% \end{macrocode} +% % \begin{macrocode} - \int_compare:nNnTF { #2 } = 1 + \int_compare:nNnTF \l_tmpb_int = 1 { \tl_if_empty:NTF \l_@@_cell_type_tl { \tl_set:Nn \l_@@_pos_of_block_tl c } @@ -12661,20 +12705,6 @@ version 2005/12/01 or later. \keys_set_known:nn { NiceMatrix / Block / FirstPass } { #3 } % \end{macrocode} % -% \medskip -% We recall that |#1| and |#2| have been extracted from the first mandatory -% argument of |\Block| (which is of the syntax $i$|-|$j$). However, the user is -% allowed to omit $i$ or $j$ (or both). We detect that situation by replacing a -% missing value by 100 (it's a convention: when the block will actually be drawn -% these values will be detected and interpreted as \emph{maximal possible value}). -% \begin{macrocode} - \tl_if_empty:nTF { #1 } - { \int_set:Nn \l_tmpa_int { 100 } } - { \int_set:Nn \l_tmpa_int { #1 } } - \tl_if_empty:nTF { #2 } - { \int_set:Nn \l_tmpb_int { 100 } } - { \int_set:Nn \l_tmpb_int { #2 } } -% \end{macrocode} % % \begin{macrocode} \tl_set:Nx \l_tmpa_tl @@ -12693,14 +12723,14 @@ version 2005/12/01 or later. % % \medskip % If the block is mono-column or mono-row, we have a special treatment. That's -% why we have two macros: |\@@_Block_iii:nnnnn| and |\@@_Block_iv:nnnnn| (the five +% why we have two macros: |\@@_Block_iv:nnnnn| and |\@@_Block_v:nnnnn| (the five % arguments of those macros are provided by curryfication). % \begin{macrocode} \bool_lazy_or:nnTF { \int_compare_p:nNn { \l_tmpa_int } = 1 } { \int_compare_p:nNn { \l_tmpb_int } = 1 } - { \exp_args:Nxx \@@_Block_iii:nnnnn } { \exp_args:Nxx \@@_Block_iv:nnnnn } + { \exp_args:Nxx \@@_Block_v:nnnnn } { \l_tmpa_int } { \l_tmpb_int } { #3 } { #4 } { #5 } } % \end{macrocode} @@ -12714,7 +12744,7 @@ version 2005/12/01 or later. % current row). However, that box will be put in the array \emph{after the % construction of the array} (by using \textsc{pgf}). % \begin{macrocode} -\cs_new_protected:Npn \@@_Block_iii:nnnnn #1 #2 #3 #4 #5 +\cs_new_protected:Npn \@@_Block_iv:nnnnn #1 #2 #3 #4 #5 { \int_gincr:N \g_@@_block_box_int \cs_set_protected_nopar:Npn \diagbox ##1 ##2 @@ -12847,7 +12877,7 @@ version 2005/12/01 or later. % composed right now in a box. The composition in a box will be done further, % just after the construction of the array. % \begin{macrocode} -\cs_new_protected:Npn \@@_Block_iv:nnnnn #1 #2 #3 #4 #5 +\cs_new_protected:Npn \@@_Block_v:nnnnn #1 #2 #3 #4 #5 { \seq_gput_right:Nx \g_@@_blocks_seq { @@ -12941,13 +12971,14 @@ version 2005/12/01 or later. \cs_new_protected:Npn \@@_draw_blocks: { \cs_set_eq:NN \ialign \@@_old_ialign: - \seq_map_inline:Nn \g_@@_blocks_seq { \@@_Block_iii:nnnnnn ##1 } + \seq_map_inline:Nn \g_@@_blocks_seq { \@@_Block_iv:nnnnnn ##1 } } % \end{macrocode} % % \begin{macrocode} -\cs_new_protected:Npn \@@_Block_iii:nnnnnn #1 #2 #3 #4 #5 #6 +\cs_new_protected:Npn \@@_Block_iv:nnnnnn #1 #2 #3 #4 #5 #6 { +% \end{macrocode} % The integer |\l_@@_last_row_int| will be the last row of the block and % |\l_@@_last_col_int| its last column. % \begin{macrocode} @@ -12985,12 +13016,12 @@ version 2005/12/01 or later. } { \msg_error:nnnn { nicematrix } { Block~too~large~1 } { #1 } { #2 } } } - { \@@_Block_iv:nnnnnn { #1 } { #2 } { #3 } { #4 } { #5 } { #6 } } + { \@@_Block_v:nnnnnn { #1 } { #2 } { #3 } { #4 } { #5 } { #6 } } } % \end{macrocode} % % \begin{macrocode} -\cs_new_protected:Npn \@@_Block_iv:nnnnnn #1 #2 #3 #4 #5 #6 +\cs_new_protected:Npn \@@_Block_v:nnnnnn #1 #2 #3 #4 #5 #6 { % \end{macrocode} % The sequence of the positions of the blocks will be used when drawing the rules @@ -13950,7 +13981,7 @@ version 2005/12/01 or later. % \begin{macrocode} \@@_msg_new:nn { ampersand~in~light-syntax } { - You~can't~use~an~ampersand~(\token_to_str &)~to~separate~columns~because + You~can't~use~an~ampersand~(\token_to_str:N &)~to~separate~columns~because~ ~you~have~used~the~key~'light-syntax'.~This~error~is~fatal. } % \end{macrocode} @@ -14187,6 +14218,7 @@ version 2005/12/01 or later. The~available~keys~are~(in~alphabetic~order):~ allow-duplicate-names,~ cell-space-bottom-limit,~ + cell-space-limits,~ cell-space-top-limit,~ code-for-first-col,~ code-for-first-row,~ @@ -14235,6 +14267,7 @@ version 2005/12/01 or later. baseline,~ c,~ cell-space-bottom-limit,~ + cell-space-limits,~ cell-space-top-limit,~ code-after,~ code-for-first-col,~ @@ -14293,6 +14326,7 @@ version 2005/12/01 or later. baseline,~ c,~ cell-space-bottom-limit,~ + cell-space-limits,~ cell-space-top-limit,~ code-after,~ code-for-first-col,~ @@ -14347,6 +14381,7 @@ version 2005/12/01 or later. baseline,~ c,~ cell-space-bottom-limit,~ + cell-space-limits,~ cell-space-top-limit,~ code-after,~ code-for-first-col,~ @@ -14818,6 +14853,14 @@ version 2005/12/01 or later. % % Better error messages for the command |\Block|. % +% \subsection*{Changes between versions 5.8 and 5.9} +% +% Correction of a bug: in the previous versions, it was not possible to use the +% key |line-style| for the continuous dotted lines when the Tikz library |babel| +% was loaded. +% +% New key |cell-space-limits|. +% % \PrintIndex % % \tableofcontents diff --git a/Master/texmf-dist/source/latex/nicematrix/nicematrix.ins b/Master/texmf-dist/source/latex/nicematrix/nicematrix.ins index 7c31f665795..b6fbed12ca8 100644 --- a/Master/texmf-dist/source/latex/nicematrix/nicematrix.ins +++ b/Master/texmf-dist/source/latex/nicematrix/nicematrix.ins @@ -1,5 +1,5 @@ %% -%% Copyright (C) 2018-2020 by F. Pantigny +%% Copyright (C) 2018-2021 by F. Pantigny %% %% %% This file may be distributed and/or modified under the @@ -17,7 +17,7 @@ \usedir{tex/latex/nicematrix} \preamble -Copyright (C) 2018-2020 by F. Pantigny +Copyright (C) 2018-2021 by F. Pantigny This file may be distributed and/or modified under the conditions of the LaTeX Project Public License, either |