From 8c1f78ad1a590e86ae1e357a03ecfe9c8a00ad64 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sun, 18 Sep 2022 19:45:00 +0000 Subject: nicematrix (18sep22) git-svn-id: svn://tug.org/texlive/trunk@64433 c570f23f-e606-0410-a88d-b1316a301751 --- .../doc/latex/nicematrix/nicematrix-french.pdf | Bin 511972 -> 511473 bytes .../doc/latex/nicematrix/nicematrix-french.tex | 57 ++++++++- .../texmf-dist/doc/latex/nicematrix/nicematrix.pdf | Bin 1320819 -> 1325255 bytes .../source/latex/nicematrix/nicematrix.dtx | 141 +++++++++++++++++++-- .../texmf-dist/tex/latex/nicematrix/nicematrix.sty | 52 +++++++- 5 files changed, 227 insertions(+), 23 deletions(-) diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf index aef19a755cf..0ae8f26c90d 100644 Binary files a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf and b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf differ diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex index 6244fda93e2..f7fa1fe561f 100644 --- a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex +++ b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex @@ -24,7 +24,6 @@ \usepackage{shortvrb} \MakeShortVerb{\|} - \usepackage{fancyvrb} \fvset{commandchars=\~\#\@,formatcom=\color{gray}} @@ -967,13 +966,13 @@ par |\Cdots|, |\Vdots|, etc. : cf.~p.~\pageref{Cdots}. \end{itemize} \item Les coins sont créés par la clé |corners| détaillée un peu plus loin : cf. p.~\pageref{corners}. -\item Pour les rangées et colonnes extérieures, cf.~\pageref{exterior}. +\item Pour les rangées et colonnes extérieures, cf. p.~\pageref{exterior}. \end{itemize} En particulier, cette remarque explique la différence entre la commande standard |\hline| et la commande |\Hline| proposée par \pkg{nicematrix}. -\colorbox{yellow!50}{\textbf{Nouveau 6.13}}\enskip La command |\Hline| admet +\colorbox{yellow!50}{\textbf{Nouveau 6.13}}\enskip La commande |\Hline| admet entre crochets un argument optionnel qui est une liste de couples \textsl{clé=valeur} qui décrivent un filet. Pour la description de ces clés, voir |custom-line| p.~\pageref{custom-line}. @@ -1183,7 +1182,7 @@ Cette commande |\diagbox| peut aussi être utilisée dans un |\Block|. Il est possible de définir des commandes et des lettres pour des filets personnalisés avec la clé |custom-line|, utilisable dans |\NiceMatrixOptions| ou bien dans un environnement. Cette clé prend en argument une liste de paires de -la forme \textsl{clé=valeur}. Il y a d'abord deux clés pour spécifier les outils +la forme \textsl{clé=valeur}. Il y a d'abord trois clés pour spécifier les outils qui permettront d'utiliser ce nouveau type de filet. \begin{itemize} @@ -1792,9 +1791,51 @@ Antoine \\ Stéphanie \\ \end{NiceTabular} +\bigskip +On peut aussi utiliser dans la commande |\rowlistcolors| une série de couleurs +définie par la commande |\definecolorseries| de \pkg{xcolor} (et initialisée +avec la commande |\resetcolorseries|\footnote{Pour l'initialisation, on a + utilisé dans l'exemple qui suit le compteur |iRow| qui, quand il est utilisé + dans le |\CodeBefore| (ou le |\CodeAfter|) désigne le nombre de rangées du + tableau : cf~p.~\pageref{iRow}. Cela permet un ajustement de la gradation des + couleurs à la taille du tableau.}). + +\smallskip +\begin{BVerbatim}[boxwidth=12cm,baseline=c] +\begin{NiceTabular}{c} +\CodeBefore + ~emphase#\definecolorseries{BlueWhite}{rgb}{last}{blue}{white}@ + ~emphase#\resetcolorseries{\value{iRow}}{BlueWhite}@ + ~emphase#\rowlistcolors{1}{BlueWhite!!+}@ +\Body +Mathilde \\ +Pierre \\ +Paul \\ +Amélie \\ +Jacques \\ +Antoine \\ +Stéphanie \\ +\end{NiceTabular} +\end{BVerbatim} +\begin{NiceTabular}{c} +\CodeBefore + \definecolorseries{BlueWhite}{rgb}{last}{blue}{white} + \resetcolorseries[\value{iRow}]{BlueWhite} + \rowlistcolors{1}{BlueWhite!!+} +\Body +Mathilde \\ +Pierre \\ +Paul \\ +Amélie \\ +Jacques \\ +Antoine \\ +Stéphanie \\ +\end{NiceTabular} + \end{itemize} -\medskip + +\vspace{1cm} On rappelle que toutes les commandes de coloriage que l'on vient de décrire ne colorient pas les cases qui sont dans les «coins». Dans l'exemple suivant, on utilise la clé |corners| pour demander de considérer le coin \emph{north east} (NE). @@ -3332,7 +3373,7 @@ $\begin{pNiceMatrix} \subsection{La légendes des tableaux} \colorbox{yellow!50}{\bfseries Nouveau 6.12}\enskip L'environnement -|{NiceTabular}| proposent des clés |caption|, |short-caption| et |label| à +|{NiceTabular}| propose des clés |caption|, |short-caption| et |label| à utiliser lorsque le tableau est inséré dans un environnment flottant (typiquement un environnement |{table}|). @@ -3462,7 +3503,7 @@ des notes avant les notes numérotées. \colorbox{yellow!50}{\textbf{Nouveau 6.13} }\enskip Une syntaxe alternative est proposée : il est possible d'utiliser l'environnement |{TabularNote}| à la fin de -l'environnement |{NiceTabular}| (mais \emph{avant} l'eventuel |\CodeAfter|). +l'environnement |{NiceTabular}| (mais \emph{avant} l'éventuel |\CodeAfter|). \item Si l'extension \pkg{booktabs} a été chargée (avant ou après \pkg{nicematrix}), la clé |notes/bottomrule| permet de faire tracer un @@ -3917,6 +3958,8 @@ En fait, l'option |small| correspond aux réglages suivants : \subsection{Les compteurs iRow et jCol} +\label{iRow} + Dans les cases du tableau, il est possible d'utiliser les compteurs LaTeX |iRow| et |jCol| qui représentent le numéro de la rangée courante et le numéro de la colonne courante\footnote{On rappelle que le numéro de la «première rangée» (si diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf b/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf index cd44a1841fe..d2b0a1ca61c 100644 Binary files a/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf and b/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf differ diff --git a/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx b/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx index 1884212f428..659e7fa56a2 100644 --- a/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx +++ b/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx @@ -17,8 +17,8 @@ % % \fi % \iffalse -\def\myfileversion{6.13} -\def\myfiledate{2022/08/24} +\def\myfileversion{6.13a} +\def\myfiledate{2022/09/17} % % %<*batchfile> @@ -1200,7 +1200,7 @@ version 2005/12/01 or later. % It's also possible to define commands and letters for customized rules with % the key |custom-line| available in |\NiceMatrixOptions| and in the options of % individual environments. That key takes in as argument a list of -% \textsl{key=value} pairs. First, there is two keys to define the tools which +% \textsl{key=value} pairs. First, there is three keys to define the tools which % will be used to use that new type of rule. % % \begin{itemize} @@ -1754,7 +1754,6 @@ version 2005/12/01 or later. % arguments for the colors, this command takes in an argument which is a % (comma-separated) list of colors. In that list, the symbol |=| represent a % color identical to the previous one. -% \end{itemize} % % \smallskip % \begin{BVerbatim}[boxwidth=10cm,baseline=c] @@ -1784,8 +1783,49 @@ version 2005/12/01 or later. % Alexandra \\ % \end{NiceTabular} % +% \bigskip +% It's also possible to use in the command |\rowlistcolors| a color series +% defined by the command |\definecolorseries| of \pkg{xcolor} (and initialized +% with the command |\resetcolorseries|\footnote{For the initialization, in the +% following example, you have used the counter |iRow| which, when used in the +% |\CodeBefore| (and in the |\CodeAfter|) corresponds to the number of rows of +% the array: cf.~p~\pageref{iRow}. That leads to an adjustement of the gradation +% of the colors to the size of the tabular.}). % -% \medskip +% \smallskip +% \begin{BVerbatim}[boxwidth=12cm,baseline=c] +% \begin{NiceTabular}{c} +% \CodeBefore +% ~emphase#\definecolorseries{BlueWhite}{rgb}{last}{blue}{white}@ +% ~emphase#\resetcolorseries{\value{iRow}}{BlueWhite}@ +% ~emphase#\rowlistcolors{1}{BlueWhite!!+}@ +% \Body +% Peter \\ +% James \\ +% Abigail \\ +% Elisabeth \\ +% Claudius \\ +% Jane \\ +% Alexandra \\ +% \end{NiceTabular} +% \end{BVerbatim} +% \begin{NiceTabular}{c} +% \CodeBefore +% \definecolorseries{BlueWhite}{rgb}{last}{blue}{white} +% \resetcolorseries[\value{iRow}]{BlueWhite} +% \rowlistcolors{1}{BlueWhite!!+} +% \Body +% Peter \\ +% James \\ +% Abigail \\ +% Elisabeth \\ +% Claudius \\ +% Jane \\ +% Alexandra \\ +% \end{NiceTabular} +% \end{itemize} +% +% \vspace{1cm} % We recall that all the color commands we have described don't color the cells % which are in the ``corners''. In the following example, we use the key % |corners| to require the determination of the corner \emph{north east} (NE). @@ -3876,6 +3916,8 @@ version 2005/12/01 or later. % % \subsection{The counters iRow and jCol} % +% \label{iRow} +% % In the cells of the array, it's possible to use the LaTeX counters |iRow| and % |jCol| which represent the number of the current row and the number of the % current column\footnote{We recall that the exterior ``first row'' (if it @@ -5888,6 +5930,77 @@ version 2005/12/01 or later. } % \end{macrocode} % +% \bigskip +% \subsection*{Security test} +% +% Within the package \pkg{nicematrix}, we will have to test whether a cell of a +% |{NiceTabular}| is empty. For the cells of the columns of type |p|, |b|, |m|, +% |X| and |V|, we will test whether the cell is syntactically empty (that is to +% say that there is only spaces between the ampersands |&|). That test will be +% done with the command |\@@_test_if_empty:| by testing if the two first tokens +% in the cells are (during the TeX process) are |\ignorespaces| and |\unskip|. +% +% However, if, one day, there is a changement in the implementation of +% \pkg{array}, maybe that this test will be broken (and \pkg{nicematrix} also). +% +% That's why, by security, we will take a test in a small |{tabular}| composed +% in the box |\l_tmpa_box| used as sandbox. +% +% \begin{macrocode} +\@@_msg_new:nn { Internal~error } + { + A~fatal~internal~error~have~occurred.\\ + If~you~see~this~message,~contact~the~author~of~the~package~'nicematrix'~ + because~this~error~should~not~have~occurred. + } +% \end{macrocode} +% +% \bigskip +% \begin{macrocode} +\@@_msg_new:nn { mdwtab~loaded } + { + The~packages~'mdwtab'~and~'nicematrix'~are~incompatible.~ + This~error~is~fatal. + } +% \end{macrocode} +% +% \bigskip +% \begin{macrocode} +\cs_new_protected:Npn \@@_security_test:n #1 + { + \peek_meaning:NTF \ignorespaces + { \@@_security_test_i:w } + { \@@_fatal:n { Internal~error } } + #1 + } +% \end{macrocode} +% +% \bigskip +% \begin{macrocode} +\cs_new_protected:Npn \@@_security_test_i:w \ignorespaces #1 + { + \peek_meaning:NF \unskip { \@@_fatal:n { Internal~error } } + #1 + } +% \end{macrocode} +% +% \bigskip +% Here, the box |\l_tmpa_box| will be used as sandbox to take our security test. +% \begin{macrocode} +\hook_gput_code:nnn { begindocument } { . } + { + \@ifpackageloaded { mdwtab } + { \@@_fatal:n { mdwtab~loaded } } + { + \hbox_set:Nn \l_tmpa_box + { + \begin { tabular } { c > { \@@_security_test:n } c c } + text & & text + \end { tabular } + } + } + } +% \end{macrocode} % % \bigskip % \subsection*{Technical definitions} @@ -8497,7 +8610,7 @@ version 2005/12/01 or later. % we use the following technic: % \begin{itemize} % \item for the columns of type |p|, |m|, |b|, |V| (of \pkg{varwidth}) or |X|, -% we test whether the cell is syntacticly empty with |\@@_test_if_empty:| and +% we test whether the cell is syntactically empty with |\@@_test_if_empty:| and % |\@@_test_if_empty_for_S:| % \item if the width of the box |\l_@@_cell_box| (created with the content of % the cell) is equal to zero, we consider the cell as empty (however, @@ -10580,7 +10693,14 @@ version 2005/12/01 or later. \peek_meaning:NT \unskip { \tl_gput_right:Nn \g_@@_cell_after_hook_tl - { \box_set_wd:Nn \l_@@_cell_box \c_zero_dim } + { + \box_set_wd:Nn \l_@@_cell_box \c_zero_dim +% \end{macrocode} +% We put the following code in order to have a column with the correct width +% even when all the cells of the column are empty. +% \begin{macrocode} + \skip_horizontal:N \l_@@_col_width_dim + } } #1 } @@ -11031,8 +11151,9 @@ version 2005/12/01 or later. \@whilesw \if@tempswa \fi { \@tempswafalse \the \NC@list } \tl_gclear:N \g_@@_preamble_tl \exp_after:wN \@@_patch_m_preamble:n \the \@temptokena \q_stop - \tl_gset_eq:NN #1 \g_@@_preamble_tl \group_end: + \tl_set_eq:NN #1 \g_@@_preamble_tl + % \group_end: } % \end{macrocode} % @@ -12434,7 +12555,7 @@ version 2005/12/01 or later. \bool_if:NTF \l_@@_in_code_after_bool { \@@_error_or_warning:n { TabularNote~in~CodeAfter } } { - \tl_if_empty:NF \g_@@_taublarnote_tl + \tl_if_empty:NF \g_@@_tabularnote_tl { \tl_gput_right:Nn \g_@@_tabularnote_tl { \par } } \tl_gput_right:Nn \g_@@_tabularnote_tl { ##1 } } @@ -17359,7 +17480,7 @@ version 2005/12/01 or later. { { \int_compare_p:nNn { #2 } = 1 } { \dim_compare_p:n { \l_@@_col_width_dim >= \c_zero_dim } } - { ! \l_@@_respect_arraystretch_bool } + { ! \g_@@_rotate_bool } % added 2022/09/16 } % \end{macrocode} % When the block is mono-column in a column with a fixed width (eg |p{3cm}|). diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty index 97bf94e1892..1a614513716 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{6.13} -\def\myfiledate{2022/08/24} +\def\myfileversion{6.13a} +\def\myfiledate{2022/09/17} \RequirePackage{pgfcore} \usepgfmodule{shapes} \RequirePackage{l3keys2e} @@ -70,6 +70,42 @@ \__nicematrix_warning:n { #1 } \__nicematrix_gredirect_none:n { #1 } } +\__nicematrix_msg_new:nn { Internal~error } + { + A~fatal~internal~error~have~occurred.\\ + If~you~see~this~message,~contact~the~author~of~the~package~'nicematrix'~ + because~this~error~should~not~have~occurred. + } +\__nicematrix_msg_new:nn { mdwtab~loaded } + { + The~packages~'mdwtab'~and~'nicematrix'~are~incompatible.~ + This~error~is~fatal. + } +\cs_new_protected:Npn \__nicematrix_security_test:n #1 + { + \peek_meaning:NTF \ignorespaces + { \__nicematrix_security_test_i:w } + { \__nicematrix_fatal:n { Internal~error } } + #1 + } +\cs_new_protected:Npn \__nicematrix_security_test_i:w \ignorespaces #1 + { + \peek_meaning:NF \unskip { \__nicematrix_fatal:n { Internal~error } } + #1 + } +\hook_gput_code:nnn { begindocument } { . } + { + \@ifpackageloaded { mdwtab } + { \__nicematrix_fatal:n { mdwtab~loaded } } + { + \hbox_set:Nn \l_tmpa_box + { + \begin { tabular } { c > { \__nicematrix_security_test:n } c c } + text & & text + \end { tabular } + } + } + } \tl_new:N \l__nicematrix_argspec_tl \cs_generate_variant:Nn \seq_set_split:Nnn { N V n } \cs_generate_variant:Nn \keys_define:nn { n x } @@ -2226,7 +2262,10 @@ \peek_meaning:NT \unskip { \tl_gput_right:Nn \g__nicematrix_cell_after_hook_tl - { \box_set_wd:Nn \l__nicematrix_cell_box \c_zero_dim } + { + \box_set_wd:Nn \l__nicematrix_cell_box \c_zero_dim + \skip_horizontal:N \l__nicematrix_col_width_dim + } } #1 } @@ -2513,8 +2552,9 @@ \@whilesw \if@tempswa \fi { \@tempswafalse \the \NC@list } \tl_gclear:N \g__nicematrix_preamble_tl \exp_after:wN \__nicematrix_patch_m_preamble:n \the \@temptokena \q_stop - \tl_gset_eq:NN #1 \g__nicematrix_preamble_tl \group_end: + \tl_set_eq:NN #1 \g__nicematrix_preamble_tl + % \group_end: } \cs_new:Npn \__nicematrix_multicolumn:nnn #1 #2 #3 { @@ -3367,7 +3407,7 @@ \bool_if:NTF \l__nicematrix_in_code_after_bool { \__nicematrix_error_or_warning:n { TabularNote~in~CodeAfter } } { - \tl_if_empty:NF \g__nicematrix_taublarnote_tl + \tl_if_empty:NF \g__nicematrix_tabularnote_tl { \tl_gput_right:Nn \g__nicematrix_tabularnote_tl { \par } } \tl_gput_right:Nn \g__nicematrix_tabularnote_tl { ##1 } } @@ -6335,7 +6375,7 @@ { { \int_compare_p:nNn { #2 } = 1 } { \dim_compare_p:n { \l__nicematrix_col_width_dim >= \c_zero_dim } } - { ! \l__nicematrix_respect_arraystretch_bool } + { ! \g__nicematrix_rotate_bool } % added 2022/09/16 } { \begin { minipage } [ \l__nicematrix_vpos_of_block_tl ] -- cgit v1.2.3