summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/nicematrix
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2020-06-14 03:02:26 +0000
committerNorbert Preining <norbert@preining.info>2020-06-14 03:02:26 +0000
commit893b65e5d4c0b7cb8ebbfca9ee6b090b9a4a182c (patch)
treef6b0cff2cf2f8e30ef3edbfa6c7205e588e81515 /macros/latex/contrib/nicematrix
parent2d0067edb74f15b431d7a1e3a42b4f525986cef0 (diff)
CTAN sync 202006140302
Diffstat (limited to 'macros/latex/contrib/nicematrix')
-rw-r--r--macros/latex/contrib/nicematrix/nicematrix-french.pdfbin355481 -> 356758 bytes
-rw-r--r--macros/latex/contrib/nicematrix/nicematrix-french.tex37
-rw-r--r--macros/latex/contrib/nicematrix/nicematrix.dtx219
-rw-r--r--macros/latex/contrib/nicematrix/nicematrix.pdfbin873835 -> 882583 bytes
4 files changed, 226 insertions, 30 deletions
diff --git a/macros/latex/contrib/nicematrix/nicematrix-french.pdf b/macros/latex/contrib/nicematrix/nicematrix-french.pdf
index c5d481ad72..24432563ff 100644
--- a/macros/latex/contrib/nicematrix/nicematrix-french.pdf
+++ b/macros/latex/contrib/nicematrix/nicematrix-french.pdf
Binary files differ
diff --git a/macros/latex/contrib/nicematrix/nicematrix-french.tex b/macros/latex/contrib/nicematrix/nicematrix-french.tex
index d79a0f3727..a8c0fdd435 100644
--- a/macros/latex/contrib/nicematrix/nicematrix-french.tex
+++ b/macros/latex/contrib/nicematrix/nicematrix-french.tex
@@ -378,8 +378,45 @@ arum & iris & jacinthe & muguet
\end{center}
+\interitem
+On remarquera que les 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é.
+
+\medskip
+\begin{center}
+\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 \\
+\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\\
+ 3 & 0.783 & 0.885 & 0.015 & 0.306 & 0.643 & 0.263\\
+ 4 & 0.161 & 0.708 & 0.386 & 0.257 & 0.074 & 0.336\\
+\bottomrule
+\end{NiceTabular}
+\end{BVerbatim}
+\end{center}
\bigskip
+\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 \\
+\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\\
+ 3 & 0.783 & 0.885 & 0.015 & 0.306 & 0.643 & 0.263\\
+ 4 & 0.161 & 0.708 & 0.386 & 0.257 & 0.074 & 0.336\\
+\bottomrule
+\end{NiceTabular}
+\end{center}
+
+
+\interitem
On peut aussi utiliser la commande |\Block| dans des matrices mathématiques.
\medskip
diff --git a/macros/latex/contrib/nicematrix/nicematrix.dtx b/macros/latex/contrib/nicematrix/nicematrix.dtx
index e957be5dc9..a3e658e757 100644
--- a/macros/latex/contrib/nicematrix/nicematrix.dtx
+++ b/macros/latex/contrib/nicematrix/nicematrix.dtx
@@ -1,6 +1,6 @@
% \iffalse meta-comment
%
-% Copyright (C) 2018-2019 by F. Pantigny
+% Copyright (C) 2018-2020 by F. Pantigny
% -----------------------------------
%
% This file may be distributed and/or modified under the
@@ -15,8 +15,8 @@
%
% \fi
% \iffalse
-\def\myfileversion{4.2}
-\def\myfiledate{2020/06/07}
+\def\myfileversion{4.3}
+\def\myfiledate{2020/06/12}
%
%
%<*batchfile>
@@ -434,9 +434,49 @@ version 2005/12/01 or later.
% \end{NiceTabular}
% \end{center}
%
-%
+% \interitem
+% On 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.
%
% \medskip
+% \begin{center}
+% \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 \\
+% \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\\
+% 3 & 0.783 & 0.885 & 0.015 & 0.306 & 0.643 & 0.263\\
+% 4 & 0.161 & 0.708 & 0.386 & 0.257 & 0.074 & 0.336\\
+% \bottomrule
+% \end{NiceTabular}
+% \end{BVerbatim}
+% \end{center}
+%
+% \bigskip
+% \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 \\
+% \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\\
+% 3 & 0.783 & 0.885 & 0.015 & 0.306 & 0.643 & 0.263\\
+% 4 & 0.161 & 0.708 & 0.386 & 0.257 & 0.074 & 0.336\\
+% \bottomrule
+% \end{NiceTabular}
+% \end{center}
+%
+%
+%
+%
+% \interitem
% It's also possible to use the command |\Block| in mathematical matrices.
%
% \medskip
@@ -3659,7 +3699,7 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
-% The following commands are only for efficiency. It must \emph{not} be protected
+% The following commands are only for efficiency. They must \emph{not} be protected
% because it will be used (for instance) in names of \textsc{pgf} nodes.
% \begin{macrocode}
\cs_new:Npn \@@_succ:n #1 { \the \numexpr #1 + 1 \relax }
@@ -4049,9 +4089,8 @@ version 2005/12/01 or later.
% \begin{macrocode}
\seq_new:N \g_@@_pos_of_blocks_seq
% \end{macrocode}
-% The sequence |\g_@@_pos_of_blocks_seq| will be used by the test of
-% non-overlapping of two blocks and when we will draw the rules required by the
-% key |hvlines| (these rules won't be drawn within the blocks).
+% The sequence |\g_@@_pos_of_blocks_seq| when we will draw the rules required by
+% the key |hvlines| (these rules won't be drawn within the blocks).
%
% \bigskip
% We will also manage a sequence for the positions of the dotted lines. These
@@ -7884,9 +7923,9 @@ version 2005/12/01 or later.
% \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 }
+ \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
@@ -9211,7 +9250,7 @@ version 2005/12/01 or later.
{
\int_compare:nNnT \l_tmpb_tl > { #2 - 1 }
{
- \int_compare:nNnT \l_tmpb_tl < { #4 + 1 }
+ \int_compare:nNnT \l_tmpb_tl < { #4 + 1 }
{ \bool_gset_false:N \g_tmpa_bool }
}
}
@@ -9871,10 +9910,10 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
-% \subsection*{Block matrices}
+% \subsection*{The blocks}
%
-% The code in this section if for the construction of \emph{block matrices}. It
-% has no direct link with the environment |{NiceMatrixBlock}|.
+% The code deals with the command |\Block|. This command has no direct link with
+% the environment |{NiceMatrixBlock}|.
%
%
% The following command will be linked to |\Block| in the environments of
@@ -9882,8 +9921,10 @@ version 2005/12/01 or later.
% because it has an optional argument between |<| and |>| (for TeX instructions
% put before the math mode of the label)
%
+% It's mandatory to use a expandable command (probably because of the first
+% optional argument ?).
% \begin{macrocode}
-\NewDocumentCommand \@@_Block: { O { } m D < > { } m }
+\NewExpandableDocumentCommand \@@_Block: { O { } m D < > { } m }
{ \@@_Block_i #2 \q_stop { #1 } { #3 } { #4 } }
% \end{macrocode}
%
@@ -9909,10 +9950,10 @@ version 2005/12/01 or later.
% \begin{macrocode}
\tl_set:Nx \l_tmpa_tl
{
- { \int_use:N \c@iRow }
- { \int_use:N \c@jCol }
- { \int_eval:n { \c@iRow + #1 - 1 } }
- { \int_eval:n { \c@jCol + #2 - 1 } }
+ { \int_use:N \c@iRow }
+ { \int_use:N \c@jCol }
+ { \int_eval:n { \c@iRow + #1 - 1 } }
+ { \int_eval:n { \c@jCol + #2 - 1 } }
}
% \end{macrocode}
% Now, |\l_tmpa_tl| constains a ``object'' corresponding to the position of the
@@ -9944,7 +9985,9 @@ version 2005/12/01 or later.
%
% \bigskip
% The key |tikz| is for Tikz options used when the \textsc{pgf} node of the
-% block is created.
+% block is created (the ``normal'' block node and not the ``short'' one nor the
+% ``medium'' one). \textbf{In fact, as for now, it is \emph{not} documented}. Is
+% it really a good idea to provide such a key?
% \begin{macrocode}
\keys_define:nn { NiceMatrix / Block }
{
@@ -9965,7 +10008,8 @@ version 2005/12/01 or later.
\cs_new_protected:Npn \@@_Block_iii:nnnnnn #1 #2 #3 #4 #5 #6
{
% \end{macrocode}
-% The group is for the keys.
+% The group is for the keys (even if, as for new, there is only one key, called
+% |tikz| and not documented).
% \begin{macrocode}
\group_begin:
\keys_set:nn { NiceMatrix / Block } { #5 }
@@ -9973,7 +10017,7 @@ version 2005/12/01 or later.
%
% \begin{macrocode}
\bool_lazy_or:nnTF
- { \int_compare_p:nNn { #3 } > \c@iRow }
+ { \int_compare_p:nNn { #3 } > \g_@@_row_total_int }
{ \int_compare_p:nNn { #4 } > \c@jCol }
{ \msg_error:nnnn { nicematrix } { Block~too~large } { #1 } { #2 } }
{
@@ -9984,7 +10028,54 @@ version 2005/12/01 or later.
\hbox_set:Nn \l_@@_cell_box { #6 }
% \end{macrocode}
%
-% \medskip
+% \bigskip
+% Let's consider the following |{NiceTabular}|. Because of the instruction
+% |!{\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.
+% \begin{Verbatim}
+% \begin{NiceTabular}{CC!{\hspace{1cm}}C}
+% \Block{2-2}{our block} & & one \\
+% & & two \\
+% three & four & five \\
+% six & seven & eight \\
+% \end{NiceTabular}
+% \end{Verbatim}
+%
+% \tikzset{highlight/.style={rectangle,
+% fill=red!15,
+% blend mode = multiply,
+% rounded corners = 0pt,
+% inner sep=0pt,
+% fit = #1}}
+%
+% \begin{tabular}{c!{\hspace{1cm}}c}
+% We highlight the node |1-1-block|
+% & We highlight the node |1-1-block-short| \\[2mm]
+% \begin{NiceTabular}{CC!{\hspace{1cm}}C}
+% \Block{2-2}{our block} & & one \\
+% & & two \\
+% three & four & five \\
+% six & seven & eight \\
+% \CodeAfter
+% \tikz \node [highlight = (1-1-block)] { } ;
+% \end{NiceTabular}
+% &
+% \begin{NiceTabular}{CC!{\hspace{1cm}}C}
+% \Block{2-2}{our block} & & one \\
+% & & two \\
+% three & four & five \\
+% six & seven & eight \\
+% \CodeAfter
+% \tikz \node [highlight = (1-1-block-short)] { } ;
+% \end{NiceTabular}
+% \end{tabular}
+%
+%
+% \bigskip
% The construction of the node corresponding to the merged cells.
% \begin{macrocode}
\pgfpicture
@@ -10012,7 +10103,55 @@ version 2005/12/01 or later.
\l_tmpb_dim \l_tmpa_dim \l_tmpd_dim \l_tmpc_dim
\end { pgfscope }
% \end{macrocode}
+%
+%
%
+% \medskip
+% We construct the |short| node.
+% \begin{macrocode}
+ \dim_set_eq:NN \l_tmpb_dim \c_max_dim
+ \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 }
+ {
+ \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 - #4 }
+ {
+ \pgfpointanchor { \@@_env: - ##1 - #4 } { 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 { #4 } }
+ \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
% If the creation of the ``medium nodes'' is required, we create a ``medium
@@ -10033,6 +10172,16 @@ version 2005/12/01 or later.
\int_compare:nNnTF { #1 } = { #3 }
{
% \end{macrocode}
+% We take into account the case of a block of one row in the ``first row'' or
+% the ``end row''.
+% \begin{macrocode}
+ \int_compare:nNnTF { #1 } = 0
+ { \l_@@_code_for_first_row_tl }
+ {
+ \int_compare:nNnT { #1 } = \l_@@_last_row_int
+ \l_@@_code_for_last_row_tl
+ }
+% \end{macrocode}
% If the block has only one row, we want the label of the block perfectly
% aligned on the baseline of the row. That's why we have constructed a
% |\pgfcoordinate| on the baseline of the row, in the first column of the array.
@@ -10042,7 +10191,7 @@ version 2005/12/01 or later.
% \end{macrocode}
% We retrieve (in |\pgf@x|) the $x$-value of the center of the block.
% \begin{macrocode}
- \@@_qpoint:n { #1 - #2 - block }
+ \@@_qpoint:n { #1 - #2 - block - short }
% \end{macrocode}
% We put the label of the block which has been composed in |\l_@@_cell_box|.
% \begin{macrocode}
@@ -10054,11 +10203,11 @@ version 2005/12/01 or later.
%
% \medskip
% If the number of rows is different of $1$, we put the label of the block in
-% the center of the node (the label of the block has been composed in
+% the center of the (short) node (the label of the block has been composed in
% |\l_@@_cell_box|).
% \begin{macrocode}
{
- \pgftransformshift { \@@_qpoint:n { #1 - #2 - block } }
+ \pgftransformshift { \@@_qpoint:n { #1 - #2 - block - short } }
\pgfnode { rectangle } { center }
{ \box_use_drop:N \l_@@_cell_box } { } { }
}
@@ -10172,6 +10321,7 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
+% \bigskip
% \subsection*{The redefinition of the command \textbackslash dotfill }
%
% \begin{macrocode}
@@ -10199,6 +10349,7 @@ version 2005/12/01 or later.
{ \dim_compare:nNnT { \box_wd:N \l_@@_cell_box } = \c_zero_dim \@@_dotfill }
% \end{macrocode}
%
+% \bigskip
% \subsection*{The command \textbackslash diagbox}
%
%
@@ -10256,7 +10407,8 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
-% \subsection*{The command \textbackslash CodeAfter}
+% \bigskip
+% \subsection*{The keyword \textbackslash CodeAfter}
%
% In fact, in this subsection, we define the user command |\CodeAfter| for the
% case of the ``normal syntax''. For the case of ``light-syntax'', see the
@@ -10286,7 +10438,7 @@ version 2005/12/01 or later.
\str_if_eq:eeTF \@currenvir { #1 }
{ \end { #1 } }
% \end{macrocode}
-% It this is not the |\end| we are looking for, we put those tokens in
+% If this is not the |\end| we are looking for, we put those tokens in
% |\g_@@_code_after_tl| and we go on searching for the next command |\end| with
% a recursive call to the command |\@@_CodeAfter:n|.
% \begin{macrocode}
@@ -10302,7 +10454,6 @@ version 2005/12/01 or later.
% \bigskip
% \subsection*{We process the options at package loading}
%
-%
%
% We process the options when the package is loaded (with |\usepackage|) but we
% recommend to use |\NiceMatrixOptions| instead.
@@ -11151,6 +11302,14 @@ version 2005/12/01 or later.
% It's now possible to write |\begin{pNiceMatrix}a&b\\c&d\end{pNiceMatrix}^2|
% with the expected result.
%
+% \subsection*{Changes between versions 4.2 and 4.3}
+%
+% The horizontal centering of the content of a |\Block| is correct even when an
+% instruction such as |!{\qquad}| is used in the preamble of the array.
+%
+% It's now possible to use the command |\Block| in the ``last row''.
+%
+%
% \PrintIndex
%
% \tableofcontents
diff --git a/macros/latex/contrib/nicematrix/nicematrix.pdf b/macros/latex/contrib/nicematrix/nicematrix.pdf
index 184e8e4a59..31fb149271 100644
--- a/macros/latex/contrib/nicematrix/nicematrix.pdf
+++ b/macros/latex/contrib/nicematrix/nicematrix.pdf
Binary files differ