From c4d400d058136a9045857b99d816595e7a655125 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Fri, 2 Jul 2021 03:02:09 +0000 Subject: CTAN sync 202107020302 --- .../latex/contrib/nicematrix/nicematrix-french.pdf | Bin 461406 -> 463607 bytes .../latex/contrib/nicematrix/nicematrix-french.tex | 42 +- macros/latex/contrib/nicematrix/nicematrix.dtx | 648 ++++++++++++++++----- macros/latex/contrib/nicematrix/nicematrix.pdf | Bin 1300431 -> 1330962 bytes 4 files changed, 533 insertions(+), 157 deletions(-) (limited to 'macros/latex/contrib/nicematrix') diff --git a/macros/latex/contrib/nicematrix/nicematrix-french.pdf b/macros/latex/contrib/nicematrix/nicematrix-french.pdf index 55b39da0c4..30ae5840fa 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 5339ea7ac8..cfa537184b 100644 --- a/macros/latex/contrib/nicematrix/nicematrix-french.tex +++ b/macros/latex/contrib/nicematrix/nicematrix-french.tex @@ -213,7 +213,8 @@ lettres |L|, |C| et |R|, \pkg{nicematrix} doit être chargé avec l'option \begin{Verbatim} \usepackage[define-L-C-R]{nicematrix} \end{Verbatim} - +\textbf{Cette clé sera probablement supprimée dans une future version de + \pkg{nicematrix}.} \section{L'espace vertical entre les rangées} @@ -688,12 +689,13 @@ défaut de ce premier argument obligatoire est |1-1|.}. -\subsection{Petite remarque} +\subsection{Positionnement horizontal du contenu des blocs} -On remarquera que le centrage horizontal du contenu des blocs est -correct même si un espacement des colonnes a été demandé par une instruction -comme |!{\qquad}| dans le préambule (ce n'est pas le cas avec |\multicolumn|). -Dans l'exemple suivant, l'en-tête «Premier groupe» est correctement centré. +Par défaut, le positionnement horizontal des contenus des blocs est calculé sur +le \emph{contenu} des colonnes impliquées. De ce fait, dans l'exemple suivant, +l'en-tête «Premier groupe» est correctement centré même si un espacement +des colonnes a été demandé par une instruction comme |!{\qquad}| dans le +préambule (ce n'est pas le cas avec |\multicolumn|). \medskip \begin{center} @@ -701,8 +703,8 @@ Dans l'exemple suivant, l'en-tête «Premier groupe» est correctement centré. \begin{BVerbatim} \begin{NiceTabular}{@{}c!{\qquad}ccc~emphase#!{\qquad}+ccc~@{}} \toprule -& ~emphase#\Block{1-3}{Premier groupe}+ & & & \Block{1-3}{Deuxième groupe} \\ -Rang & 1A & 1B & 1C & 2A & 2B & 2C \\ +Rang & ~emphase#\Block{1-3}{Premier groupe}+ & & & \Block{1-3}{Deuxième groupe} \\ + & 1A & 1B & 1C & 2A & 2B & 2C \\ \midrule 1 & 0.657 & 0.913 & 0.733 & 0.830 & 0.387 & 0.893\\ 2 & 0.343 & 0.537 & 0.655 & 0.690 & 0.471 & 0.333\\ @@ -717,8 +719,8 @@ Rang & 1A & 1B & 1C & 2A & 2B & 2C \\ \begin{center} \begin{NiceTabular}{@{}c!{\qquad}ccc!{\qquad}ccc@{}} \toprule -& \Block{1-3}{Premier groupe} & & & \Block{1-3}{Deuxième groupe} \\ -Rang & 1A & 1B & 1C & 2A & 2B & 2C \\ +Rang & \Block{1-3}{Premier groupe} & & & \Block{1-3}{Deuxième groupe} \\ + & 1A & 1B & 1C & 2A & 2B & 2C \\ \midrule 1 & 0.657 & 0.913 & 0.733 & 0.830 & 0.387 & 0.893\\ 2 & 0.343 & 0.537 & 0.655 & 0.690 & 0.471 & 0.333\\ @@ -728,7 +730,11 @@ Rang & 1A & 1B & 1C & 2A & 2B & 2C \\ \end{NiceTabular} \end{center} - +\medskip +\colorbox{yellow!50}{\bfseries Nouveau 5.17}\enskip Pour avoir un positionnement +horizontal du contenu du bloc qui s'appuie sur les limites des colonnes du +tableau LaTeX (et non sur le contenu de ces colonnes), il faut utiliser les clés +|L|, |R| et |C| de la commande |\Block|. \section{Les filets horizontaux et verticaux} @@ -1004,6 +1010,12 @@ arum & iris & jacinthe & muguet \end{NiceTabular} \end{center} + +\bigskip +\colorbox{yellow!50}{\textbf{Nouveau 5.17}}\enskip La clé +|hvlines-except-borders| est similaire à la clé |hvlines| mais ne trace pas les +filets sur les bords horizontaux et verticaux du tableau. + \bigskip \subsubsection{Les coins (vides)} \label{corners} @@ -1016,7 +1028,7 @@ Pour chacun de ces coins, on appellera \emph{coin vide} (ou tout simplement \emph{coin}) la réunion de toutes les cases vides situées dans au moins un rectangle entièrement constitué de cases vides partant de ce coin.\footnote{Pour être complet, on doit préciser que toute case située dans un bloc (même si - elle vide) n'est pas prise en compte pour la détermination des coins. Ce + elle est vide) n'est pas prise en compte pour la détermination des coins. Ce comportement est naturel.} \smallskip @@ -4158,6 +4170,10 @@ est utilisée est considérée comme vide. Cette commande peut être utilisée p fixer la largeur des colonnes sans interférer avec le tracé des lignes en pointillés par \pkg{nicematrix}. +\medskip +\item Une case d'une colonne de type |p|, |m| ou |t| est toujours non vide. +\emph{Attention} : Ne pas se fier à ce point car il est susceptible de changer. + \end{itemize} @@ -4710,7 +4726,7 @@ a_{41} & a_{42} & a_{43} & \Block[draw]{}{a_{44}} \\ On remarquera que les traits que l'on vient de tracer sont dessinés \emph{après} la matrice sans modifier la position des composantes de celle-ci. En revanche, -les traits tracés par |\hline|, le spécificateur «\verb+|+» ou les options +les traits tracés par |\hline|, |\Hline|, le spécificateur «\verb+|+» ou les options |hlines|, |vlines| et |hvlines| «écartent» les composantes de la matrice.\footnote{Pour la commande |\cline|, voir la remarque p.~\pageref{remark-cline}.} diff --git a/macros/latex/contrib/nicematrix/nicematrix.dtx b/macros/latex/contrib/nicematrix/nicematrix.dtx index 43fb1accbd..5e195b9103 100644 --- a/macros/latex/contrib/nicematrix/nicematrix.dtx +++ b/macros/latex/contrib/nicematrix/nicematrix.dtx @@ -15,8 +15,8 @@ % % \fi % \iffalse -\def\myfileversion{5.16} -\def\myfiledate{2021/06/20} +\def\myfileversion{5.17} +\def\myfiledate{2021/07/01} % % %<*batchfile> @@ -263,7 +263,8 @@ version 2005/12/01 or later. % \begin{Verbatim} % \usepackage[define-L-C-R]{nicematrix} % \end{Verbatim} -% +% \textbf{This key will probably be deleted in a future version of +% \pkg{nicematrix}.} % % \section{The vertical space between the rows} % @@ -725,13 +726,14 @@ version 2005/12/01 or later. % % % -% \subsection{A small remark} +% \subsection{Horizontal position of the content of the block} % -% One should remark that the horizontal centering of the contents of the blocks -% is correct even when an instruction such as |!{\qquad}| has been used in the -% preamble of the array in order to increase the space between two columns (this -% is not the case with |\multicolumn|). In the following example, the header -% ``First group'' is correctly centered. +% By default, the horizontal position of the content of a block is computed +% by using the positions of the \emph{contents} of the columns implied in that +% block. That's why, in the following example, the header ``First group'' is +% correctly centered despite the instruction |!{\qquad}| in the preamble which +% has been used to increase the space between the columns (this +% is not the behaviour of |\multicolumn|). % % \medskip % \begin{center} @@ -739,8 +741,8 @@ version 2005/12/01 or later. % \begin{BVerbatim} % \begin{NiceTabular}{@{}c!{\qquad}ccc~emphase#!{\qquad}+ccc@{}} % \toprule -% & ~emphase#\Block{1-3}{First group}+ & & & \Block{1-3}{Second group} \\ -% Rank & 1A & 1B & 1C & 2A & 2B & 2C \\ +% Rank & ~emphase#\Block{1-3}{First group}+ & & & \Block{1-3}{Second group} \\ +% & 1A & 1B & 1C & 2A & 2B & 2C \\ % \midrule % 1 & 0.657 & 0.913 & 0.733 & 0.830 & 0.387 & 0.893\\ % 2 & 0.343 & 0.537 & 0.655 & 0.690 & 0.471 & 0.333\\ @@ -755,8 +757,8 @@ version 2005/12/01 or later. % \begin{center} % \begin{NiceTabular}{@{}c!{\qquad}ccc!{\qquad}ccc@{}} % \toprule -% & \Block{1-3}{First group} & & & \Block{1-3}{Second group} \\ -% Rank & 1A & 1B & 1C & 2A & 2B & 2C \\ +% Rank & \Block{1-3}{First group} & & & \Block{1-3}{Second group} \\ +% & 1A & 1B & 1C & 2A & 2B & 2C \\ % \midrule % 1 & 0.657 & 0.913 & 0.733 & 0.830 & 0.387 & 0.893\\ % 2 & 0.343 & 0.537 & 0.655 & 0.690 & 0.471 & 0.333\\ @@ -766,6 +768,11 @@ version 2005/12/01 or later. % \end{NiceTabular} % \end{center} % +% \medskip +% \colorbox{yellow!50}{\bfseries New 5.17}\enskip In order to have an horizontal +% positionning of the content of the block computed with the limits of the +% columns of the LaTeX array (and not with the contents of those columns), one +% may use the key |L|, |R| and |C| of the command |\Block|. % % % \section{The rules} @@ -1026,6 +1033,10 @@ version 2005/12/01 or later. % \end{NiceTabular} % \end{center} % +% \bigskip +% \colorbox{yellow!50}{\bfseries New 5.17}\enskip The key +% |hvlines-except-corners| is similar to the key |hvlines| but does not draw the +% rules on the horizontal and vertical borders of the array. % % \subsubsection{The (empty) corners} % @@ -4099,6 +4110,11 @@ version 2005/12/01 or later. % meaning as |\hspace| except that the cell where it is used is considered as % empty. This command can be used to fix the width of some columns of the matrix % without interfering with \pkg{nicematrix}. +% +% \medskip +% \item A cell of a column of type |p|, |m| or |t| is always considered as not +% emtpy. \emph{Caution} : One should not rely upon that point because it may +% change if a future version of \pkg{nicematrix}. % % \end{itemize} % % @@ -4644,7 +4660,7 @@ version 2005/12/01 or later. % % We should remark that the rules we have drawn are drawn \emph{after} the % construction of the array and thus, they don't spread the cells of the array. -% We recall that, on the other side, the command |\hline|, the specifier ``"|"'' +% We recall that, on the other side, the commands |\hline| and |\Hline|, the specifier ``"|"'' % and the options |hlines|, |vlines| and |hvlines| spread the % cells.\footnote{For the command |\cline|, see the remark % p.~\pageref{remark-cline}.} @@ -5867,17 +5883,27 @@ version 2005/12/01 or later. % \end{macrocode} % % \medskip -% The parameters of position of the label of a block. For the horizontal -% position, the possible values are |c|, |r| and |l|. For the vertical position, -% the possible values are |c|, |t| and |b|. Of course, it would be interesting to -% program a key |T| and a key |B|. +% The parameters of the horizontal position of the label of a block. If the user +% uses the key |c| or |C|, the value is |c|. If the user uses the key |l| or +% |L|, the value is |l|. If the user uses the key |r| or |R|, the value is |r|. +% If the user has used a capital letter, the boolean +% |\l_@@_hpos_of_block_cap_bool| will be raised (in the second pass of the +% analyze of the keys of the command |\Block|). % \begin{macrocode} \tl_new:N \l_@@_hpos_of_block_tl \tl_set:Nn \l_@@_hpos_of_block_tl { c } +\bool_new:N \l_@@_hpos_of_block_cap_bool +% \end{macrocode} +% +% \medskip +% For the vertical position, the possible values are |c|, |t| and |b|. Of +% course, it would be interesting to program a key |T| and a key |B|. +% \begin{macrocode} \tl_new:N \l_@@_vpos_of_block_tl \tl_set:Nn \l_@@_vpos_of_block_tl { c } % \end{macrocode} % +% % \medskip % Used when the key |draw-first| is used for |\Ddots| or |\Iddots|. % \begin{macrocode} @@ -6428,6 +6454,14 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip +% The boolean |\l_@@_except_borders_bool| will be raised when the key +% |hvlines-except-borders| will be used (but that key has also other effects). +% \begin{macrocode} +\bool_new:N \l_@@_except_borders_bool +% \end{macrocode} +% +% +% \bigskip % The dimension |\l_@@_left_margin_dim| correspond to the option |left-margin|. % Idem for the right margin. These parameters are involved in the creation of % the ``medium nodes'' but also in the placement of the delimiters and the @@ -6592,6 +6626,12 @@ version 2005/12/01 or later. \clist_set:Nn \l_@@_vlines_clist { all } \clist_set:Nn \l_@@_hlines_clist { all } } , + hvlines-except-borders .code:n = + { + \clist_set:Nn \l_@@_vlines_clist { all } + \clist_set:Nn \l_@@_hlines_clist { all } + \bool_set_true:N \l_@@_except_borders_bool + } , parallelize-diags .bool_set:N = \l_@@_parallelize_diags_bool , % \end{macrocode} % @@ -8549,6 +8589,10 @@ version 2005/12/01 or later. % \begin{macrocode} \int_gzero:N \c@jCol \tl_gclear:N \g_@@_preamble_tl +% \end{macrocode} +% |\g_tmpb_bool| will be raised if you have a \verb+|+ at the end of the preamble. +% \begin{macrocode} + \bool_gset_false:N \g_tmpb_bool \tl_if_eq:NnTF \l_@@_vlines_clist { all } { \tl_gset:Nn \g_@@_preamble_tl @@ -8609,7 +8653,13 @@ version 2005/12/01 or later. { ! \str_if_eq_p:Vn \g_@@_right_delim_tl { . } } { \bool_set_false:N \l_@@_NiceArray_bool } % \end{macrocode} -% +% +% \medskip +% We want to remind whether there is a specifier \verb+|+ at the end of the preamble. +% \begin{macrocode} + \bool_if:NT \g_tmpb_bool { \bool_set_true:N \l_@@_bar_at_end_of_pream_bool } +% \end{macrocode} +% % \bigskip % We complete the preamble with the potential ``exterior columns''. % \begin{macrocode} @@ -8774,11 +8824,16 @@ version 2005/12/01 or later. \tl_gput_right:Nx \g_@@_internal_code_after_tl { \@@_vline:nn { \@@_succ:n \c@jCol } { \int_use:N \l_tmpa_int } } \int_zero:N \l_tmpa_int + \str_if_eq:nnT { #1 } { \q_stop } + { \bool_gset_true:N \g_tmpb_bool } \@@_patch_preamble:n #1 } } % \end{macrocode} % +% \begin{macrocode} +\bool_new:N \l_@@_bar_at_end_of_pream_bool +% \end{macrocode} % % \medskip % For |p|, |m| and |b| @@ -8870,7 +8925,7 @@ version 2005/12/01 or later. \str_if_eq:VnTF \g_@@_left_delim_tl { . } { % \end{macrocode} -% In that case, in fact, the firt letter of the preamble must be considered as +% In that case, in fact, the first letter of the preamble must be considered as % the left delimiter of the array. % \begin{macrocode} \tl_gset:Nn \g_@@_left_delim_tl { #1 } @@ -8879,29 +8934,26 @@ version 2005/12/01 or later. } { \tl_gput_right:Nn \g_@@_preamble_tl { ! { \enskip } } - \tl_gput_right:Nx \g_@@_internal_code_after_tl - { \@@_delimiter:nnn #1 { \@@_succ:n \c@jCol } \c_true_bool } - \tl_if_in:nnTF { ( [ \{ ) ] \} } { #2 } - { - \@@_error:nn { delimiter~after~opening } { #2 } - \@@_patch_preamble:n - } - { \@@_patch_preamble:n #2 } + \@@_patch_preamble_vii_i:nn { #1 } { #2 } } } + { \@@_patch_preamble_vii_i:nn { #1 } { #2 } } + } +% \end{macrocode} +% +% \begin{macrocode} +\cs_new_protected:Npn \@@_patch_preamble_vii_i:nn #1 #2 + { + \tl_gput_right:Nx \g_@@_internal_code_after_tl + { \@@_delimiter:nnn #1 { \@@_succ:n \c@jCol } \c_true_bool } + \tl_if_in:nnTF { ( [ \{ ) ] \} } { #2 } { - \tl_gput_right:Nx \g_@@_internal_code_after_tl - { \@@_delimiter:nnn #1 { \@@_succ:n \c@jCol } \c_true_bool } - \tl_if_in:nnTF { ( [ \{ ) ] \} } { #2 } - { - \@@_error:nn { delimiter~after~opening } { #2 } - \@@_patch_preamble:n - } - { \@@_patch_preamble:n #2 } + \@@_error:nn { delimiter~after~opening } { #2 } + \@@_patch_preamble:n } + { \@@_patch_preamble:n #2 } } % \end{macrocode} -% % % \bigskip % For |)|, |]| and |\}|. We have two arguments for the following command because @@ -9018,7 +9070,259 @@ version 2005/12/01 or later. % \end{macrocode} % % +% \bigskip +% \subsection{The redefinition of \textbackslash multicolumn} +% +% \medskip +% The following command must \emph{not} be protected since it begins with +% |\multispan| (a TeX primitive). +% \begin{macrocode} +\cs_new:Npn \@@_multicolumn:nnn #1 #2 #3 + { + \multispan { #1 } + \begingroup +% \end{macrocode} +% +% \medskip +% You do the expansion of the (small) preamble with the tools of \pkg{array}. +% \begin{macrocode} + \@temptokena = { #2 } + \@tempswatrue + \@whilesw \if@tempswa \fi { \@tempswafalse \the \NC@list } +% \end{macrocode} +% +% \medskip +% Now, we patch the (small) preamble as we have done with the main preamble of +% the array. +% \begin{macrocode} + \tl_gclear:N \g_@@_preamble_tl + \exp_after:wN \@@_patch_m_preamble:n \the \@temptokena \q_stop +% \end{macrocode} +% +% \medskip +% The following line creates the preamble. This line is a adaptation of a line +% of the initial definition of |\multicolumn|. +% \begin{macrocode} + \exp_args:NV \@mkpream \g_@@_preamble_tl +% \end{macrocode} +% +% \medskip +% Now, you do a treatment specific to \pkg{nicematrix} which has no equivalent +% in the original definition of |\multicolumn|. +% \begin{macrocode} + \int_compare:nNnT { #1 } > 1 + { + \seq_gput_left:Nx \g_@@_multicolumn_cells_seq + { \int_use:N \c@iRow - \@@_succ:n \c@jCol } + \seq_gput_left:Nn \g_@@_multicolumn_sizes_seq { #1 } + \seq_gput_right:Nx \g_@@_pos_of_blocks_seq + { + { \int_use:N \c@iRow } + { \int_eval:n { \c@jCol + 1 } } + { \int_use:N \c@iRow } + { \int_eval:n { \c@jCol + #1 } } + } + } +% \end{macrocode} +% +% \medskip +% The following lines were in the original definition of |\multicolumn|. +% \begin{macrocode} + \cs_set:Npn \@sharp { #3 } + \set@typeset@protect + \cs_set_eq:NN \@startpbox \@@startpbox + \cs_set_eq:NN \@endpbox \@@endpbox + \@arstrut + \@preamble + \hbox { } + \endgroup + \int_gadd:Nn \c@jCol { #1 - 1 } + \int_compare:nNnT \c@jCol > \g_@@_col_total_int + { \int_gset_eq:NN \g_@@_col_total_int \c@jCol } + \ignorespaces + } +% \end{macrocode} +% +% \bigskip +% The following commands will patch the (small) preamble of the |\multicolumn|. +% All those commands have a |m| in their name to recall that they deal with the +% redefinition of |\multicolumn|. +% \begin{macrocode} +\cs_new_protected:Npn \@@_patch_m_preamble:n #1 + { + \str_case:nnF { #1 } + { + c { \@@_patch_m_preamble_i:n #1 } + l { \@@_patch_m_preamble_i:n #1 } + r { \@@_patch_m_preamble_i:n #1 } + > { \@@_patch_m_preamble_ii:nn #1 } + ! { \@@_patch_m_preamble_ii:nn #1 } + @ { \@@_patch_m_preamble_ii:nn #1 } + | { \@@_patch_m_preamble_iii:n #1 } + p { \@@_patch_m_preamble_iv:nnn t #1 } + m { \@@_patch_m_preamble_iv:nnn c #1 } + b { \@@_patch_m_preamble_iv:nnn b #1 } + \@@_w: { \@@_patch_m_preamble_v:nnnn { } #1 } + \@@_W: { \@@_patch_m_preamble_v:nnnn { \cs_set_eq:NN \hss \hfil } #1 } + \@@_true_c: { \@@_patch_m_preamble_vi:n #1 } + C { \@@_error:nn { old~column~type } #1 } + L { \@@_error:nn { old~column~type } #1 } + R { \@@_error:nn { old~column~type } #1 } + \q_stop { } + } + { \@@_fatal:nn { unknown~column~type } { #1 } } + } +% \end{macrocode} +% +% \medskip +% For |c|, |l| and |r| +% \begin{macrocode} +\cs_new_protected:Npn \@@_patch_m_preamble_i:n #1 + { + \tl_gput_right:Nn \g_@@_preamble_tl + { + > { \@@_Cell: \tl_set:Nn \l_@@_cell_type_tl { #1 } } + #1 + < \@@_end_Cell: + } +% \end{macrocode} +% +% We test for the presence of a |<|. +% \begin{macrocode} + \@@_patch_m_preamble_x:n + } +% \end{macrocode} +% +% \medskip +% For |>|, |!| and |@| +% \begin{macrocode} +\cs_new_protected:Npn \@@_patch_m_preamble_ii:nn #1 #2 + { + \tl_gput_right:Nn \g_@@_preamble_tl { #1 { #2 } } + \@@_patch_m_preamble:n + } +% \end{macrocode} +% +% +% \medskip +% For \verb+|+ +% \begin{macrocode} +\cs_new_protected:Npn \@@_patch_m_preamble_iii:n #1 + { + \tl_gput_right:Nn \g_@@_preamble_tl { #1 } + \@@_patch_m_preamble:n + } +% \end{macrocode} +% +% \medskip +% For |p|, |m| and |b| +% \begin{macrocode} +\cs_new_protected:Npn \@@_patch_m_preamble_iv:nnn #1 #2 #3 + { + \tl_gput_right:Nn \g_@@_preamble_tl + { + > { + \@@_Cell: + \begin { minipage } [ #1 ] { \dim_eval:n { #3 } } + \mode_leave_vertical: + \arraybackslash + \vrule height \box_ht:N \@arstrutbox depth 0 pt width 0 pt + } + c + < { + \vrule height 0 pt depth \box_dp:N \@arstrutbox width 0 pt + \end { minipage } + \@@_end_Cell: + } + } +% \end{macrocode} +% We test for the presence of a |<|. +% \begin{macrocode} + \@@_patch_m_preamble_x:n + } +% \end{macrocode} +% +% \medskip +% For |w| and |W| +% \begin{macrocode} +\cs_new_protected:Npn \@@_patch_m_preamble_v:nnnn #1 #2 #3 #4 + { + \tl_gput_right:Nn \g_@@_preamble_tl + { + > { + \hbox_set:Nw \l_@@_cell_box + \@@_Cell: + \tl_set:Nn \l_@@_cell_type_tl { #3 } + } + c + < { + \@@_end_Cell: + #1 + \hbox_set_end: + \bool_if:NT \g_@@_rotate_bool \@@_rotate_cell_box: + \@@_adjust_size_box: + \makebox [ #4 ] [ #3 ] { \box_use_drop:N \l_@@_cell_box } + } + } +% \end{macrocode} +% We test for the presence of a |<|. +% \begin{macrocode} + \@@_patch_m_preamble_x:n + } +% \end{macrocode} +% +% \medskip +% For |\@@_true_c:| which will appear in our redefinition of the columns of type +% |S| (of \pkg{siunitx}). +% \begin{macrocode} +\cs_new_protected:Npn \@@_patch_m_preamble_vi:n #1 + { + \tl_gput_right:Nn \g_@@_preamble_tl { c } +% \end{macrocode} +% We test for the presence of a |<|. +% \begin{macrocode} + \@@_patch_m_preamble_x:n + } +% \end{macrocode} +% % +% After a specifier of column, we have to test whether there is one or several +% |<{..}| because, after those potential |<{...}|, we have to insert +% |!{\skip_horizontal:N ...}| when the key |vlines| is used. +% \begin{macrocode} +\cs_new_protected:Npn \@@_patch_m_preamble_x:n #1 + { + \str_if_eq:nnTF { #1 } { < } + \@@_patch_m_preamble_ix:n + { + \tl_if_eq:NnTF \l_@@_vlines_clist { all } + { + \tl_gput_right:Nn \g_@@_preamble_tl + { ! { \skip_horizontal:N \arrayrulewidth } } + } + { + \exp_args:NNx + \clist_if_in:NnT \l_@@_vlines_clist { \@@_succ:n \c@jCol } + { + \tl_gput_right:Nn \g_@@_preamble_tl + { ! { \skip_horizontal:N \arrayrulewidth } } + } + } + \@@_patch_m_preamble:n { #1 } + } + } +% \end{macrocode} +% +% \begin{macrocode} +\cs_new_protected:Npn \@@_patch_m_preamble_ix:n #1 + { + \tl_gput_right:Nn \g_@@_preamble_tl { < { #1 } } + \@@_patch_m_preamble_x:n + } +% \end{macrocode} +% +% +% % \bigskip % The command |\@@_put_box_in_flow:| puts the box |\l_tmpa_box| (which contains % the array) in the flow. It is used for the environments with delimiters. @@ -9457,7 +9761,7 @@ version 2005/12/01 or later. % The command |\@@_create_col_nodes:| will construct a special last row. % That last row is a false row used to create the |col| nodes and to fix the % width of the columns (when the array is constructed with an option which -% specify the width of the columns). +% specifies the width of the columns). % \begin{macrocode} \cs_new:Npn \@@_create_col_nodes: { @@ -9609,11 +9913,28 @@ version 2005/12/01 or later. } \endpgfpicture } +% \end{macrocode} +% +% \bigskip +% We want to remove the exterior |\arraycolsep| of a environment |{NiceArray}|. +% \begin{macrocode} + \bool_lazy_all:nT + { + \l_@@_NiceArray_bool + { \bool_not_p:n \l_@@_NiceTabular_bool } + { \clist_if_empty_p:N \l_@@_vlines_clist } + { \bool_not_p:n \l_@@_exterior_arraycolsep_bool } + { ! \l_@@_bar_at_end_of_pream_bool } + } + { \skip_horizontal:n { - \col@sep } } +% \end{macrocode} +% +% \bigskip +% \begin{macrocode} \bool_if:NT \g_@@_last_col_found_bool { \hbox_overlap_right:n { - % \skip_horizontal:N \col@sep \skip_horizontal:N \g_@@_width_last_col_dim \bool_if:NT \l_@@_code_before_bool { @@ -11703,62 +12024,10 @@ version 2005/12/01 or later. } % \end{macrocode} % -% -% \bigskip -% In the environment |{NiceArray}|, the command |\multicolumn| will be linked to -% the following command |\@@_multicolumn:nnn|. % \begin{macrocode} \cs_set_eq:NN \@@_old_multicolumn \multicolumn -\cs_new:Npn \@@_multicolumn:nnn #1 #2 #3 - { -% \end{macrocode} -% We have to act in an expandable way since it will begin by a |\multicolumn|. -% \begin{macrocode} - \exp_args:NNe - \@@_old_multicolumn - { #1 } - { - \exp_args:Ne \str_case:nn { \str_foldcase:n { #2 } } - { - l { > \@@_Cell: l < \@@_end_Cell: } - r { > \@@_Cell: r < \@@_end_Cell: } - c { > \@@_Cell: c < \@@_end_Cell: } - { l | } { > \@@_Cell: l < \@@_end_Cell: | } - { r | } { > \@@_Cell: r < \@@_end_Cell: | } - { c | } { > \@@_Cell: c < \@@_end_Cell: | } - { | l } { | > \@@_Cell: l < \@@_end_Cell: } - { | r } { | > \@@_Cell: r < \@@_end_Cell: } - { | c } { | > \@@_Cell: c < \@@_end_Cell: } - { | l | } { | > \@@_Cell: l < \@@_end_Cell: | } - { | r | } { | > \@@_Cell: r < \@@_end_Cell: | } - { | c | } { | > \@@_Cell: c < \@@_end_Cell: | } - } - } - { #3 } -% \end{macrocode} -% The |\peek_remove_spaces:n| is mandatory. -% \begin{macrocode} - \peek_remove_spaces:n - { - \int_compare:nNnT #1 > 1 - { - \seq_gput_left:Nx \g_@@_multicolumn_cells_seq - { \int_use:N \c@iRow - \int_use:N \c@jCol } - \seq_gput_left:Nn \g_@@_multicolumn_sizes_seq { #1 } - \seq_gput_right:Nx \g_@@_pos_of_blocks_seq - { - { \int_use:N \c@iRow } - { \int_use:N \c@jCol } - { \int_use:N \c@iRow } - { \int_eval:n { \c@jCol + #1 - 1 } } - } - } - \int_gadd:Nn \c@jCol { #1 - 1 } - \int_compare:nNnT \c@jCol > \g_@@_col_total_int - { \int_gset_eq:NN \g_@@_col_total_int \c@jCol } - } - } % \end{macrocode} +% % % % \bigskip @@ -11813,7 +12082,8 @@ version 2005/12/01 or later. { #2 } { #1 , #3 , - down = \exp_not:n { #4 } , up = \exp_not:n { #5 } + down = \exp_not:n { #4 } , + up = \exp_not:n { #5 } } } \prg_replicate:nn { #2 - 1 } { & \multicolumn { 1 } { c } { } } @@ -12950,15 +13220,22 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% The command |\@@_draw_hlines:| draws all the vertical rules excepted in the +% The command |\@@_draw_vlines:| draws all the vertical rules excepted in the % blocks, in the virtual blocks (determined by a command such as |\Cdots|) and in % the corners (if the key |corners| is used). % \begin{macrocode} \cs_new_protected:Npn \@@_draw_vlines: { \int_step_inline:nnn - { \bool_if:NTF \l_@@_NiceArray_bool 1 2 } - { \bool_if:NTF \l_@@_NiceArray_bool { \@@_succ:n \c@jCol } \c@jCol } + { + \bool_if:nTF { \l_@@_NiceArray_bool && ! \l_@@_except_borders_bool } + 1 2 + } + { + \bool_if:nTF { \l_@@_NiceArray_bool && ! \l_@@_except_borders_bool } + { \@@_succ:n \c@jCol } + \c@jCol + } { \tl_if_eq:NnF \l_@@_vlines_clist { all } { \clist_if_in:NnT \l_@@_vlines_clist { ##1 } } @@ -13131,8 +13408,15 @@ version 2005/12/01 or later. \cs_new_protected:Npn \@@_draw_hlines: { \int_step_inline:nnn - { \bool_if:NTF \l_@@_NiceArray_bool 1 2 } - { \bool_if:NTF \l_@@_NiceArray_bool { \@@_succ:n \c@iRow } \c@iRow } + { + \bool_if:nTF { \l_@@_NiceArray_bool && ! \l_@@_except_borders_bool } + 1 2 + } + { + \bool_if:nTF { \l_@@_NiceArray_bool && ! \l_@@_except_borders_bool } + { \@@_succ:n \c@iRow } + \c@iRow + } { \tl_if_eq:NnF \l_@@_hlines_clist { all } { \clist_if_in:NnT \l_@@_hlines_clist { ##1 } } @@ -13180,7 +13464,6 @@ version 2005/12/01 or later. % % \subsection*{The key hvlines} % -% % The following command tests whether the current position in the array (given by % |\l_tmpa_tl| for the row and |\l_tmpb_tl| for the column) would provide an % horizontal rule towards the right in the block delimited by the four arguments @@ -13603,7 +13886,6 @@ version 2005/12/01 or later. % \bigskip % \textbf{Vertical dotted lines}\par\nobreak % -% % \medskip % \begin{macrocode} \cs_new_protected:Npn \@@_vdottedline:n #1 @@ -14106,6 +14388,12 @@ version 2005/12/01 or later. r .value_forbidden:n = true , c .code:n = \tl_set:Nn \l_@@_hpos_of_block_tl c , c .value_forbidden:n = true , + L .code:n = \tl_set:Nn \l_@@_hpos_of_block_tl l , + L .value_forbidden:n = true , + R .code:n = \tl_set:Nn \l_@@_hpos_of_block_tl r , + R .value_forbidden:n = true , + C .code:n = \tl_set:Nn \l_@@_hpos_of_block_tl c , + C .value_forbidden:n = true , t .code:n = \tl_set:Nn \l_@@_vpos_of_block_tl t , t .value_forbidden:n = true , b .code:n = \tl_set:Nn \l_@@_vpos_of_block_tl b , @@ -14461,6 +14749,15 @@ version 2005/12/01 or later. r .value_forbidden:n = true , c .code:n = \tl_set:Nn \l_@@_hpos_of_block_tl c , c .value_forbidden:n = true , + L .code:n = \tl_set:Nn \l_@@_hpos_of_block_tl l + \bool_set_true:N \l_@@_hpos_of_block_cap_bool , + L .value_forbidden:n = true , + R .code:n = \tl_set:Nn \l_@@_hpos_of_block_tl r + \bool_set_true:N \l_@@_hpos_of_block_cap_bool , + R .value_forbidden:n = true , + C .code:n = \tl_set:Nn \l_@@_hpos_of_block_tl c + \bool_set_true:N \l_@@_hpos_of_block_cap_bool , + C .value_forbidden:n = true , t .code:n = \tl_set:Nn \l_@@_vpos_of_block_tl t , t .value_forbidden:n = true , b .code:n = \tl_set:Nn \l_@@_vpos_of_block_tl b , @@ -14634,9 +14931,8 @@ version 2005/12/01 or later. % |!{\hspace{1cm}}| in the preamble which increases the space between the % columns (by adding, in fact, that space to the previous column, that is to say % the second column of the tabular), we will create \emph{two} nodes relative to -% the block: the node |1-1-block| and the node |1-1-block-short|. The latter -% will be used by \pkg{nicematrix} to put the label of the node. The first one -% won't be used explicitely. +% the block: the node |1-1-block| and the node |1-1-block-short|. +% % \begin{Verbatim} % \begin{NiceTabular}{cc!{\hspace{1cm}}c} % \Block{2-2}{our block} & & one \\ @@ -14705,58 +15001,71 @@ version 2005/12/01 or later. % \end{macrocode} % % \medskip -% We construct the |short| node. +% Now, we create the ``short node'' which, in general, will be used to put the +% label (that is to say the content of the node). However, if one the keys |L|, |C| or +% |R| is used (that information is provided by the boolean +% |\l_@@_hpos_of_block_cap_bool|), we don't need to create that node since the +% normal node is used to put the label. +% % \begin{macrocode} - \dim_set_eq:NN \l_tmpb_dim \c_max_dim - \int_step_inline:nnn \l_@@_first_row_int \g_@@_row_total_int + \bool_if:NF \l_@@_hpos_of_block_cap_bool { + \dim_set_eq:NN \l_tmpb_dim \c_max_dim +% \end{macrocode} +% The short node is constructed by taking into account the \emph{contents} of +% the columns involved in at least one cell of the block. That's why we have to +% do a loop over the rows of the array. +% \begin{macrocode} + \int_step_inline:nnn \l_@@_first_row_int \g_@@_row_total_int + { % \end{macrocode} % We recall that, when a cell is empty, no (normal) node is created in that % cell. That's why we test the existence of the node before using it. % \begin{macrocode} - \cs_if_exist:cT - { pgf @ sh @ ns @ \@@_env: - ##1 - #2 } - { - \seq_if_in:NnF \g_@@_multicolumn_cells_seq { ##1 - #2 } + \cs_if_exist:cT + { pgf @ sh @ ns @ \@@_env: - ##1 - #2 } { - \pgfpointanchor { \@@_env: - ##1 - #2 } { west } - \dim_set:Nn \l_tmpb_dim { \dim_min:nn \l_tmpb_dim \pgf@x } + \seq_if_in:NnF \g_@@_multicolumn_cells_seq { ##1 - #2 } + { + \pgfpointanchor { \@@_env: - ##1 - #2 } { west } + \dim_set:Nn \l_tmpb_dim { \dim_min:nn \l_tmpb_dim \pgf@x } + } } } - } % \end{macrocode} % If all the cells of the column were empty, |\l_tmpb_dim| has still the same % value |\c_max_dim|. In that case, you use for |\l_tmpb_dim| the value of the % position of the vertical rule. % \begin{macrocode} - \dim_compare:nNnT \l_tmpb_dim = \c_max_dim - { - \@@_qpoint:n { col - #2 } - \dim_set_eq:NN \l_tmpb_dim \pgf@x - } - \dim_set:Nn \l_tmpd_dim { - \c_max_dim } - \int_step_inline:nnn \l_@@_first_row_int \g_@@_row_total_int - { - \cs_if_exist:cT - { pgf @ sh @ ns @ \@@_env: - ##1 - \int_use:N \l_@@_last_col_int } + \dim_compare:nNnT \l_tmpb_dim = \c_max_dim + { + \@@_qpoint:n { col - #2 } + \dim_set_eq:NN \l_tmpb_dim \pgf@x + } + \dim_set:Nn \l_tmpd_dim { - \c_max_dim } + \int_step_inline:nnn \l_@@_first_row_int \g_@@_row_total_int { - \seq_if_in:NnF \g_@@_multicolumn_cells_seq { ##1 - #2 } + \cs_if_exist:cT + { pgf @ sh @ ns @ \@@_env: - ##1 - \int_use:N \l_@@_last_col_int } { - \pgfpointanchor - { \@@_env: - ##1 - \int_use:N \l_@@_last_col_int } - { east } - \dim_set:Nn \l_tmpd_dim { \dim_max:nn \l_tmpd_dim \pgf@x } + \seq_if_in:NnF \g_@@_multicolumn_cells_seq { ##1 - #2 } + { + \pgfpointanchor + { \@@_env: - ##1 - \int_use:N \l_@@_last_col_int } + { east } + \dim_set:Nn \l_tmpd_dim { \dim_max:nn \l_tmpd_dim \pgf@x } + } } } + \dim_compare:nNnT \l_tmpd_dim = { - \c_max_dim } + { + \@@_qpoint:n { col - \@@_succ:n { \l_@@_last_col_int } } + \dim_set_eq:NN \l_tmpd_dim \pgf@x + } + \@@_pgf_rect_node:nnnnn + { \@@_env: - #1 - #2 - block - short } + \l_tmpb_dim \l_tmpa_dim \l_tmpd_dim \l_tmpc_dim } - \dim_compare:nNnT \l_tmpd_dim = { - \c_max_dim } - { - \@@_qpoint:n { col - \@@_succ:n { \l_@@_last_col_int } } - \dim_set_eq:NN \l_tmpd_dim \pgf@x - } - \@@_pgf_rect_node:nnnnn - { \@@_env: - #1 - #2 - block - short } - \l_tmpb_dim \l_tmpa_dim \l_tmpd_dim \l_tmpc_dim % \end{macrocode} % % \medskip @@ -14806,7 +15115,10 @@ version 2005/12/01 or later. % We retrieve (in |\pgf@x|) the $x$-value of the center of the block. % \begin{macrocode} \pgfpointanchor - { \@@_env: - #1 - #2 - block - short } + { + \@@_env: - #1 - #2 - block + \bool_if:NF \l_@@_hpos_of_block_cap_bool { - short } + } { \str_case:Vn \l_@@_hpos_of_block_tl { @@ -14853,7 +15165,10 @@ version 2005/12/01 or later. \pgftransformshift { \pgfpointanchor - { \@@_env: - #1 - #2 - block - short } + { + \@@_env: - #1 - #2 - block + \bool_if:NF \l_@@_hpos_of_block_cap_bool { - short } + } { \str_case:Vn \l_@@_hpos_of_block_tl { @@ -15148,14 +15463,36 @@ version 2005/12/01 or later. % \end{macrocode} % % +% \bigskip +% We will extract the potential keys |l|, |r| and |c| and pass the other keys to +% the environment |{NiceArrayWithDelims}|. +% \begin{macrocode} +\keys_define:nn { NiceMatrix / Auto } + { + l .code:n = \tl_set:Nn \l_@@_type_of_col_tl l , + r .code:n = \tl_set:Nn \l_@@_type_of_col_tl r , + c .code:n = \tl_set:Nn \l_@@_type_of_col_tl c + } +% \end{macrocode} +% % \begin{macrocode} \NewDocumentCommand \AutoNiceMatrixWithDelims { m m O { } m O { } m ! O { } } { \int_zero_new:N \l_@@_nb_rows_int \int_zero_new:N \l_@@_nb_cols_int \@@_set_size:n #4 \q_stop - \begin { NiceArrayWithDelims } { #1 } { #2 } - { * { \l_@@_nb_cols_int } { c } } [ #3 , #5 , #7 ] +% \end{macrocode} +% The group is for the protection of |\l_@@_type_of_col_tl|. +% \begin{macrocode} + \group_begin: + \tl_set:Nn \l_@@_type_of_col_tl c + \keys_set_known:nnN { NiceMatrix / Auto } { #3, #5, #7 } \l_tmpa_tl + \use:x + { + \exp_not:N \begin { NiceArrayWithDelims } { #1 } { #2 } + { * { \int_use:N \l_@@_nb_cols_int } { \l_@@_type_of_col_tl } } + [ \l_tmpa_tl ] + } \int_compare:nNnT \l_@@_first_row_int = 0 { \int_compare:nNnT \l_@@_first_col_int = 0 { & } @@ -15166,7 +15503,7 @@ version 2005/12/01 or later. { \int_compare:nNnT \l_@@_first_col_int = 0 { & } % \end{macrocode} -% You put |{ }| before |#6| to avoid a hasty expansion of a potential +% We put |{ }| before |#6| to avoid a hasty expansion of a potential % |\arabic{iRow}| at the beginning of the row which would result in an incorrect % value of that |iRow| (since |iRow| is incremented in the first cell of the row % of the |\halign|). @@ -15181,6 +15518,7 @@ version 2005/12/01 or later. \int_compare:nNnT \l_@@_last_col_int > { -1 } { & } \\ } \end { NiceArrayWithDelims } + \group_end: } % \end{macrocode} % @@ -16108,10 +16446,20 @@ version 2005/12/01 or later. % \end{macrocode} % % \begin{macrocode} +\@@_msg_new:nn { define-L-C-R } + { + You~have~used~the~key~'define-L-C-R'.~Please~note~that~this~key~ + will~probably~be~deleted~in~a~future~version~of~'nicematrix'.\\ + However,~you~can~go~on. + } +% \end{macrocode} +% +% \begin{macrocode} \keys_define:nn { NiceMatrix / Package } { - define-L-C-R .bool_set:N = \c_@@_define_L_C_R_bool , - define-L-C-R .default:n = true , + define-L-C-R .code:n = + \@@_error:n { define-L-C-R } + \bool_set_true:N \c_@@_define_L_C_R_bool , renew-dots .bool_set:N = \l_@@_renew_dots_bool , renew-dots .value_forbidden:n = true , renew-matrix .code:n = \@@_renew_matrix: , @@ -17465,13 +17813,25 @@ version 2005/12/01 or later. % The version 5.15b is compatible with the version 3.0+ of \pkg{siunitx} % (previous versions were not). % -% % \subsection*{Changes between versions 5.15 and 5.16} +% \subsection*{Changes between versions 5.15 and 5.16} % % It's now possible to use the cells corresponding to the contents of the nodes % (of the form |i-j|) in the |\CodeBefore| when the key |create-cell-nodes| of % that |\CodeBefore| is used. The medium and the large nodes are also available % if the corresponding keys are used. % +% \subsection*{Changes between versions 5.16 and 5.17} +% +% The key |define-L-C-R| (only available at load-time) now raises a (non fatal) +% error (that key will probably be deleted in a future version of \pkg{nicematrix}). +% +% Keys |L|, |C| and |R| for the command |\Block|. +% +% Key |hvlines-except-borders|. +% +% It's now possible to use a key |l|, |r| or |c| with the command +% |\pAutoNiceMatrix| (and the similar ones). +% % \PrintIndex % % \tableofcontents diff --git a/macros/latex/contrib/nicematrix/nicematrix.pdf b/macros/latex/contrib/nicematrix/nicematrix.pdf index 40b867d72e..2f690d6409 100644 Binary files a/macros/latex/contrib/nicematrix/nicematrix.pdf and b/macros/latex/contrib/nicematrix/nicematrix.pdf differ -- cgit v1.2.3