From d91bb5cad66508ec34d77ea60c0a02c79308edef Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Fri, 17 Nov 2023 03:02:29 +0000 Subject: CTAN sync 202311170302 --- .../latex/contrib/nicematrix/nicematrix-code.dtx | 170 +++++++++++++++------ .../latex/contrib/nicematrix/nicematrix-code.pdf | Bin 959106 -> 964932 bytes .../latex/contrib/nicematrix/nicematrix-french.pdf | Bin 594905 -> 596890 bytes .../latex/contrib/nicematrix/nicematrix-french.tex | 55 ++++++- macros/latex/contrib/nicematrix/nicematrix.pdf | Bin 610574 -> 615920 bytes macros/latex/contrib/nicematrix/nicematrix.tex | 49 ++++++ 6 files changed, 226 insertions(+), 48 deletions(-) (limited to 'macros/latex/contrib/nicematrix') diff --git a/macros/latex/contrib/nicematrix/nicematrix-code.dtx b/macros/latex/contrib/nicematrix/nicematrix-code.dtx index 6e883a8b82..d70404e997 100644 --- a/macros/latex/contrib/nicematrix/nicematrix-code.dtx +++ b/macros/latex/contrib/nicematrix/nicematrix-code.dtx @@ -17,8 +17,8 @@ % % \fi % \iffalse -\def\myfileversion{6.25a} -\def\myfiledate{2023/11/03} +\def\myfileversion{6.25b} +\def\myfiledate{2023/11/16} % % %<*batchfile> @@ -2294,7 +2294,7 @@ version 2005/12/01 or later. % array). % \begin{macrocode} \tl_new:N \l_@@_baseline_tl -\tl_set:Nn \l_@@_baseline_tl c +\tl_set:Nn \l_@@_baseline_tl { c } % \end{macrocode} % % \bigskip @@ -3795,6 +3795,7 @@ version 2005/12/01 or later. \cs_set_eq:NN \multicolumn \@@_multicolumn:nnn \hook_gput_code:nnn { env / tabular / begin } { . } { \cs_set_eq:NN \multicolumn \@@_old_multicolumn } + \@@_revert_colortbl: % \end{macrocode} % If there is one or several commands |\tabularnote| in the caption specified % by the key |caption| and if that caption has to be composed above the tabular, @@ -4027,7 +4028,10 @@ version 2005/12/01 or later. % \begin{macrocode} \cs_new_protected_nopar:Npn \@@_CodeBefore_Body:w #1 \Body { - \tl_gput_left:Nn \g_@@_pre_code_before_tl { #1 } + \tl_set:Nn \l_tmpa_tl { #1 } + \int_compare:nNnT { \char_value_catcode:n { 60 } } = { 13 } + { \@@_rescan_for_spanish:N \l_tmpa_tl } + \tl_gput_left:NV \g_@@_pre_code_before_tl \l_tmpa_tl \bool_set_true:N \l_@@_code_before_bool % \end{macrocode} % We go on with |\@@_pre_array:| which will (among other) execute the @@ -4040,6 +4044,7 @@ version 2005/12/01 or later. % \end{macrocode} % % +% % \bigskip % \section{The \textbackslash CodeBefore} % @@ -4156,11 +4161,8 @@ version 2005/12/01 or later. % \textsc{ascci} 60) and |>| are activated and Tikz is not able to solve the % problem (even with the Tikz library \pkg{babel}). % \begin{macrocode} - \int_compare:nNnT { \char_value_catcode:n { 60 } } = { 13 } - { - \@@_rescan_for_spanish:N \g_@@_pre_code_before_tl - \@@_rescan_for_spanish:N \l_@@_code_before_tl - } + \int_compare:nNnT { \char_value_catcode:n { 60 } } = { 13 } + { \@@_rescan_for_spanish:N \l_@@_code_before_tl } % \end{macrocode} % % Here is the |\CodeBefore|. The construction is a bit complicated because @@ -5951,7 +5953,8 @@ version 2005/12/01 or later. \multispan { #1 } \cs_set_eq:NN \@@_update_max_cell_width: \prg_do_nothing: % added 2023-10-04 \begingroup - \cs_set:Npn \@addamp { \if@firstamp \@firstampfalse \else \@preamerr 5 \fi } + \cs_set:Npn \@addamp + { \legacy_if:nTF { @firstamp } { \@firstampfalse } { \@preamerr 5 } } % \end{macrocode} % % \medskip @@ -7049,6 +7052,7 @@ version 2005/12/01 or later. \hbox_overlap_right:n { \skip_horizontal:N \g_@@_width_last_col_dim + \skip_horizontal:N \col@sep % added 2023-11-05 \bool_if:NT \l_@@_code_before_bool { \pgfsys@markposition @@ -9880,6 +9884,47 @@ version 2005/12/01 or later. % \bigskip % \section{The command \textbackslash RowStyle} % +% +% |\g_@@_row_style_tl| may contain several instructions of the form: +% +% \qquad |\@@_if_row_less_than:nn { number } { instructions }| +% +% \smallskip +% Then, |\g_@@_row_style_tl| will be inserted in all the cells of the array (and +% also in both components of a |\diagbox| in a cell of in a mono-row block). +% +% The test |\@@_if_row_less_then:nn| ensures that the instructions are inserted +% only if you are in a row which is (still) in the scope of that instructions +% (which depends on the value of the key |nb-rows| of |\RowStyle|). +% +% That test will be active even in an expandable context because +% |\@@_if_row_less_then:nn| is \emph{not} protected. +% +% |#1| is the first row \emph{after} the scope of the instructions in |#2| +% \begin{macrocode} +\cs_new:Npn \@@_if_row_less_than:nn #1 #2 + { \int_compare:nNnT { \int_use:N \c@iRow } < { #1 } { #2 } } +% \end{macrocode} +% +% \bigskip +% |\@@_put_in_row_style| will be used several times by |\RowStyle|. +% \begin{macrocode} +\cs_set_protected:Npn \@@_put_in_row_style:n #1 + { + \tl_gput_right:Nx \g_@@_row_style_tl + { +% \end{macrocode} +% Be careful, |\exp_not:N \@@_if_row_less_than:nn| can't be replaced by a +% protected version of |\@@_if_row_less_than:nn|. +% \begin{macrocode} + \exp_not:N + \@@_if_row_less_than:nn + { \int_eval:n { \c@iRow + \l_@@_key_nb_rows_int } } + { \exp_not:n { #1 } } + } + } +\cs_generate_variant:Nn \@@_put_in_row_style:n { e } +% \end{macrocode} % \medskip % \begin{macrocode} \keys_define:nn { NiceMatrix / RowStyle } @@ -9954,21 +9999,21 @@ version 2005/12/01 or later. } } } - \tl_gput_right:Nn \g_@@_row_style_tl { \ifnum \c@iRow < } - \tl_gput_right:Nx \g_@@_row_style_tl - { \int_eval:n { \c@iRow + \l_@@_key_nb_rows_int } } - \tl_gput_right:Nn \g_@@_row_style_tl { #2 } + \@@_put_in_row_style:n { \exp_not:n { #2 } } % \end{macrocode} % |\l_tmpa_dim| is the value of the key |cell-space-top-limit| of |\RowStyle|. % \begin{macrocode} \dim_compare:nNnT \l_tmpa_dim > \c_zero_dim { - \tl_gput_right:Nx \g_@@_row_style_tl + \@@_put_in_row_style:n { - \tl_gput_right:Nn \exp_not:N \g_@@_cell_after_hook_tl - { - \dim_set:Nn \l_@@_cell_space_top_limit_dim - { \dim_use:N \l_tmpa_dim } + \exp_not:n + { + \tl_gput_right:Nn \g_@@_cell_after_hook_tl + { + \dim_set:Nn \l_@@_cell_space_top_limit_dim + { \dim_use:N \l_tmpa_dim } + } } } } @@ -9977,12 +10022,15 @@ version 2005/12/01 or later. % \begin{macrocode} \dim_compare:nNnT \l_tmpb_dim > \c_zero_dim { - \tl_gput_right:Nx \g_@@_row_style_tl + \@@_put_in_row_style:n { - \tl_gput_right:Nn \exp_not:N \g_@@_cell_after_hook_tl - { - \dim_set:Nn \l_@@_cell_space_bottom_limit_dim - { \dim_use:N \l_tmpb_dim } + \exp_not:n + { + \tl_gput_right:Nn \g_@@_cell_after_hook_tl + { + \dim_set:Nn \l_@@_cell_space_bottom_limit_dim + { \dim_use:N \l_tmpb_dim } + } } } } @@ -9991,7 +10039,7 @@ version 2005/12/01 or later. % \begin{macrocode} \tl_if_empty:NF \l_@@_color_tl { - \tl_gput_right:Nx \g_@@_row_style_tl + \@@_put_in_row_style:e { \mode_leave_vertical: \@@_color:n { \l_@@_color_tl } @@ -10002,24 +10050,27 @@ version 2005/12/01 or later. % \begin{macrocode} \bool_if:NT \l_tmpa_bool { - \tl_gput_right:Nn \g_@@_row_style_tl + \@@_put_in_row_style:n { - \if_mode_math: - \c_math_toggle_token - \bfseries \boldmath - \c_math_toggle_token - \else: - \bfseries \boldmath - \fi: + \exp_not:n + { + \if_mode_math: + \c_math_toggle_token + \bfseries \boldmath + \c_math_toggle_token + \else: + \bfseries \boldmath + \fi: + } } } - \tl_gput_right:Nn \g_@@_row_style_tl { \fi } \group_end: \g_@@_row_style_tl \ignorespaces } % \end{macrocode} % +% % \bigskip % \section{Colors of cells, rows and columns} % @@ -10578,8 +10629,8 @@ version 2005/12/01 or later. { \tl_if_blank_p:V \l_tmpb_tl } { \str_if_eq_p:Vn \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 } } + \int_compare:nNnT \l_tmpb_tl > \g_@@_col_total_int + { \tl_set:Nx \l_tmpb_tl { \int_use:N \g_@@_col_total_int } } % \end{macrocode} % |\l_@@_tmpc_tl| will contain the number of column. % \begin{macrocode} @@ -10608,8 +10659,8 @@ version 2005/12/01 or later. \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 } } + \int_compare:nNnT \l_tmpb_tl > \g_@@_row_total_int + { \tl_set:Nx \l_tmpb_tl { \int_use:N \g_@@_row_total_int } } % \end{macrocode} % Now, the numbers of both rows are in |\l_tmpa_tl| and |\l_tmpb_tl|. % \begin{macrocode} @@ -10858,6 +10909,26 @@ version 2005/12/01 or later. % \end{macrocode} % % +% \bigskip +% \begin{macrocode} +\hook_gput_code:nnn { begindocument } { . } + { + \IfPackageLoadedTF { colortbl } + { + \cs_set_eq:NN \@@_old_cellcolor \cellcolor + \cs_set_eq:NN \@@_old_rowcolor \rowcolor + \cs_new_protected:Npn \@@_revert_colortbl: + { + \hook_gput_code:nnn { env / tabular / begin } { . } + { + \cs_set_eq:NN \cellcolor \@@_old_cellcolor + \cs_set_eq:NN \rowcolor \@@_old_rowcolor + } + } + } + { \cs_new_protected:Npn \@@_revert_colortbl: { } } + } +% \end{macrocode} % % \bigskip % \section{The vertical and horizontal rules} @@ -12840,15 +12911,15 @@ version 2005/12/01 or later. { \int_use:N \c@jCol } { \int_eval:n { \c@iRow + #1 - 1 } } { \int_eval:n { \c@jCol + #2 - 1 } } - { \exp_not:n { ##1 } } - { \exp_not:n { ##2 } } + { \g_@@_row_style_tl \exp_not:n { ##1 } } + { \g_@@_row_style_tl \exp_not:n { ##2 } } } } \box_gclear_new:c { g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box } % \end{macrocode} % Now, we will actually compose the content of the |\Block| in a TeX box. -% \emph{Be careful}: if after, the construction of the box, the boolean +% \emph{Be careful}: if after the construction of the box, the boolean % |\g_@@_rotate_bool| is raised (which means that the command |\rotate| was % present in the content of the |\Block|) we will rotate the box but also, % maybe, change the position of the baseline! @@ -14296,8 +14367,17 @@ version 2005/12/01 or later. { \int_use:N \c@jCol } { \int_use:N \c@iRow } { \int_use:N \c@jCol } - { \exp_not:n { #1 } } - { \exp_not:n { #2 } } +% \end{macrocode} +% |\g_@@_row_style_tl| contains several instructions of the form: +% +% \qquad |\@@_if_row_less_than:nn { number } { instructions }| +% +% The command |\@@_if_row_less:nn| is fully expandable and, thus, the +% instructions will be inserted in the |\g_@@_pre_code_after_tl| only if +% |\diagbox| is used in a row which is the scope of that chunck of instructions. +% \begin{macrocode} + { \g_@@_row_style_tl \exp_not:n { #1 } } + { \g_@@_row_style_tl \exp_not:n { #2 } } } % \end{macrocode} % We put the cell with |\diagbox| in the sequence |\g_@@_pos_of_blocks_seq| @@ -16448,6 +16528,7 @@ version 2005/12/01 or later. Block~too~large.\\ You~try~to~draw~a~block~in~the~cell~#1-#2~of~your~matrix~but~the~matrix~is~ too~small~for~that~block. \\ + This~block~and~maybe~others~will~be~ignored. } % \end{macrocode} % @@ -16459,8 +16540,7 @@ version 2005/12/01 or later. \g_@@_static_num_of_col_int\ columns~but~you~use~only~\int_use:N \c@jCol\ and~that's~why~a~block~ specified~in~the~cell~#1-#2~can't~be~drawn.~You~should~add~some~ampersands~ - (&)~at~the~end~of~the~first~row~of~your~ - \@@_full_name_env:.\\ + (&)~at~the~end~of~the~first~row~of~your~\@@_full_name_env:.\\ This~block~and~maybe~others~will~be~ignored. } % \end{macrocode} diff --git a/macros/latex/contrib/nicematrix/nicematrix-code.pdf b/macros/latex/contrib/nicematrix/nicematrix-code.pdf index 61c9ca2acb..acdf19c303 100644 Binary files a/macros/latex/contrib/nicematrix/nicematrix-code.pdf and b/macros/latex/contrib/nicematrix/nicematrix-code.pdf differ diff --git a/macros/latex/contrib/nicematrix/nicematrix-french.pdf b/macros/latex/contrib/nicematrix/nicematrix-french.pdf index 5182d3d966..1217b82fdf 100644 Binary files a/macros/latex/contrib/nicematrix/nicematrix-french.pdf and b/macros/latex/contrib/nicematrix/nicematrix-french.pdf differ diff --git a/macros/latex/contrib/nicematrix/nicematrix-french.tex b/macros/latex/contrib/nicematrix/nicematrix-french.tex index ea91158d20..b81d87457f 100644 --- a/macros/latex/contrib/nicematrix/nicematrix-french.tex +++ b/macros/latex/contrib/nicematrix/nicematrix-french.tex @@ -1875,8 +1875,7 @@ De nouvelles commandes sont disponibles dans ce |\CodeBefore|: |\cellcolor|, \index{arraycolor@\texttt{\textbackslash arraycolor} (commande du \texttt{\textbackslash CodeBefore)}} -Les noms de ces commandes sont inspirés des noms des commandes de \pkg{colortbl}. - +Les noms de certaines de ces commandes sont inspirés des noms des commandes de \pkg{colortbl}. \medskip Ces commandes ne colorient pas les cases qui se trouvent dans les «coins» si la @@ -2290,6 +2289,56 @@ utilise la clé |corners| pour demander de considérer le coin \emph{north east} \end{NiceTabular} \end{scope} +\medskip +L'exemple précédent utilise les clés |first-row| et |first-col| qui sont +décrites dans la partie sur les rangées et colonnes «extérieures» (cf.~p.~\pageref{exterior}). + +Comme on le voit, \emph{par défaut}, les commandes de coloriage décrites précédemment ne +s'appliquent pas dans ces rangées et colonnes «extérieures». + +Mais on peut \emph{quand même} colorier dans ces rangées et colonnes en +donnant aux commandes précédentes les numéros explicites de ces rangées et +colonnes extérieures. + +Dans l'exemple suivant, on demande explicitement le coloriage de la colonne~$0$ +(qui est la «première colonne» et qui existe du fait de la clé |first-col|). + +\medskip +\begin{scope} +\hfuzz=11cm +\begin{BVerbatim}[boxwidth=9cm,baseline=c] +\begin{NiceTabular}{cccccc}[~emphase#corners=NE@,margin,hvlines,first-row,first-col] +\CodeBefore + \rowlistcolors{1}{blue!15, } + ~emphase#\columncolor{red!15}{0}@ +\Body + & 0 & 1 & 2 & 3 & 4 & 5 & 6 \\ +0 & 1 \\ +1 & 1 & 1 \\ +2 & 1 & 2 & 1 \\ +3 & 1 & 3 & 3 & 1 \\ +4 & 1 & 4 & 6 & 4 & 1 \\ +5 & 1 & 5 & 10 & 10 & 5 & 1 \\ +6 & 1 & 6 & 15 & 20 & 15 & 6 & 1 \\ +\end{NiceTabular} +\end{BVerbatim} +\begin{NiceTabular}{ccccccc}[corners=NE,margin,hvlines,first-row,first-col] +\CodeBefore + \rowlistcolors{1}{blue!15, } + \columncolor{red!15}{0} +\Body + & 0 & 1 & 2 & 3 & 4 & 5 & 6 \\ +0 & 1 \\ +1 & 1 & 1 \\ +2 & 1 & 2 & 1 \\ +3 & 1 & 3 & 3 & 1 \\ +4 & 1 & 4 & 6 & 4 & 1 \\ +5 & 1 & 5 & 10 & 10 & 5 & 1 \\ +6 & 1 & 6 & 15 & 20 & 15 & 6 & 1 \\ +\end{NiceTabular} +\end{scope} + + \bigskip On remarquera que ces commandes sont compatibles avec les commandes de \pkg{booktabs} (|\toprule|, |\midrule|, |\bottomrule|, etc). Néanmoins, @@ -2344,7 +2393,7 @@ spécial & 12 & 12 & 0.5 & 70 \\ \index{S (les colonnes S de \pkg{siunitx})|textit} \medskip -On a utilisé le type de colonne |S| de \pkg{siunitx}. +On a utilisé le type de colonne |S| de \pkg{siunitx} (qu'il faut avoir chargé). \subsection{Outils de coloriage en tableau} diff --git a/macros/latex/contrib/nicematrix/nicematrix.pdf b/macros/latex/contrib/nicematrix/nicematrix.pdf index c7eeb39bf4..051d396651 100644 Binary files a/macros/latex/contrib/nicematrix/nicematrix.pdf and b/macros/latex/contrib/nicematrix/nicematrix.pdf differ diff --git a/macros/latex/contrib/nicematrix/nicematrix.tex b/macros/latex/contrib/nicematrix/nicematrix.tex index 7eb8e1783e..64aaf68522 100644 --- a/macros/latex/contrib/nicematrix/nicematrix.tex +++ b/macros/latex/contrib/nicematrix/nicematrix.tex @@ -2227,6 +2227,55 @@ which are in the ``corners''. In the following example, we use the key \end{NiceTabular} \end{scope} +\medskip +The previous example uses the keys |first-row| and |first-col| which are +described in the chapter concerning the «exterior» rows and columns +(cf.~p.~\pageref{exterior}). + +As one can see, \emph{by default}, the coloring commands that we have described +don't apply in those exterior rows and columns. + +However, it may still be possible to color in those rows and columns by +providing explicity the numbers of those rows and columns. + +In the following example, we require a color in the column~$0$ (which is the +«first column» and which exists because the key |first-col| has been used). + +\medskip +\begin{scope} +\hfuzz=11cm +\begin{BVerbatim}[boxwidth=9cm,baseline=c] +\begin{NiceTabular}{cccccc}[~emphase#corners=NE@,margin,hvlines,first-row,first-col] +\CodeBefore + \rowlistcolors{1}{blue!15, } + ~emphase#\columncolor{red!15}{0}@ +\Body + & 0 & 1 & 2 & 3 & 4 & 5 & 6 \\ +0 & 1 \\ +1 & 1 & 1 \\ +2 & 1 & 2 & 1 \\ +3 & 1 & 3 & 3 & 1 \\ +4 & 1 & 4 & 6 & 4 & 1 \\ +5 & 1 & 5 & 10 & 10 & 5 & 1 \\ +6 & 1 & 6 & 15 & 20 & 15 & 6 & 1 \\ +\end{NiceTabular} +\end{BVerbatim} +\begin{NiceTabular}{ccccccc}[corners=NE,margin,hvlines,first-row,first-col] +\CodeBefore + \rowlistcolors{1}{blue!15, } + \columncolor{red!15}{0} +\Body + & 0 & 1 & 2 & 3 & 4 & 5 & 6 \\ +0 & 1 \\ +1 & 1 & 1 \\ +2 & 1 & 2 & 1 \\ +3 & 1 & 3 & 3 & 1 \\ +4 & 1 & 4 & 6 & 4 & 1 \\ +5 & 1 & 5 & 10 & 10 & 5 & 1 \\ +6 & 1 & 6 & 15 & 20 & 15 & 6 & 1 \\ +\end{NiceTabular} +\end{scope} + \bigskip One should remark that all the previous commands are compatible with the -- cgit v1.2.3