summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/nicematrix
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-06-30 21:29:09 +0000
committerKarl Berry <karl@freefriends.org>2020-06-30 21:29:09 +0000
commit39e1b29fb6805f0ed171d8547196bb3a20b94838 (patch)
tree38385550e12c63da124776bb2c4d556555447829 /Master/texmf-dist/source/latex/nicematrix
parent5e414716e2db683d25868668a82195c6229aedd1 (diff)
nicematrix (30jun20)
git-svn-id: svn://tug.org/texlive/trunk@55710 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/nicematrix')
-rw-r--r--Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx352
1 files changed, 309 insertions, 43 deletions
diff --git a/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx b/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx
index a3e658e7572..f4228206e9c 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{4.3}
-\def\myfiledate{2020/06/12}
+\def\myfileversion{4.4}
+\def\myfiledate{2020/06/30}
%
%
%<*batchfile>
@@ -703,7 +703,8 @@ version 2005/12/01 or later.
% \label{hvlines}
%
% The key |hvlines| draws all the vertical and horizontal rules \emph{excepted
-% in the blocks}.\footnote{In fact, when the key |hvlines| is in force, the
+% in the blocks}.\footnote{In fact, when the key |hvlines| (or the key
+% |hvlines-except-corners| described just after) is in force, the
% rules are also not drawn in the virtual blocks delimited by cells relied par
% dotted lines (cf. p. \pageref{dotted-and-hvlines}).}
%
@@ -729,8 +730,66 @@ version 2005/12/01 or later.
% \end{center}
%
%
+% \subsection{The key hvlines-except-corners}
+%
+% The key |hvlines-except-corners| draws all the horizontal and vertical rules,
+% \emph{excepted in the blocks} and excepted in the empty corners.
+%
+% \medskip
+% \begin{Verbatim}
+% \begin{NiceTabular}{*{6}{C}}[~emphase#hvlines-except-corners@,cell-space-top-limit=3pt]
+% & & & & A \\
+% & & A & A & A \\
+% & & & A \\
+% & & A & A & A & A \\
+% A & A & A & A & A & A \\
+% A & A & A & A & A & A \\
+% & \Block{2-2}{B} & & A \\
+% & & & A \\
+% & A & A & A \\
+% \end{NiceTabular}
+% \end{Verbatim}
+% %
+% \begin{center}
+% \begin{NiceTabular}{*{6}{C}}[hvlines-except-corners,cell-space-top-limit=3pt]
+% & & & & A \\
+% & & A & A & A \\
+% & & & A \\
+% & & A & A & A & A \\
+% A & A & A & A & A & A \\
+% A & A & A & A & A & A \\
+% & \Block{2-2}{B} & & A \\
+% & & & A \\
+% & A & A & A \\
+% \end{NiceTabular}
+% \end{center}
+%
+% As we can see, an ``empty corner'' is composed by the reunion of all the empty
+% rectangles starting from the cell actually in the corner of the array.
+%
+% \bigskip
+% \begin{BVerbatim}[boxwidth=11cm,baseline=c]
+% \begin{NiceTabular}{*{6}{C}}%
+% [~emphase#hvlines-except-corners@,cell-space-top-limit=3pt]
+% 1\\
+% 1&1\\
+% 1&2&1\\
+% 1&3&3&1\\
+% 1&4&6&4&1\\
+% 1&5&10&10&5&1
+% \end{NiceTabular}
+% \end{BVerbatim}
+% \begin{NiceTabular}{*{6}{C}}[c,hvlines-except-corners,cell-space-top-limit=3pt]
+% 1\\
+% 1&1\\
+% 1&2&1\\
+% 1&3&3&1\\
+% 1&4&6&4&1\\
+% 1&5&10&10&5&1
+% \end{NiceTabular}
+%
%
-% \subsection{La commande \textbackslash diagbox}
+% \subsection{The command \textbackslash diagbox}
%
% The command |\diagbox| (inspired by the package \pkg{diagbox}), allows, when
% it is used in a cell, to slash that cell diagonally downwards.\footnote{The
@@ -1005,7 +1064,7 @@ version 2005/12/01 or later.
%
%
% \bigskip
-% One should remark that these commands are compatible with the commands de
+% One should remark that these commands are compatible with the commands of
% \pkg{booktabs} (|\toprule|, |\midrule|, |\bottomrule|, etc).
%
% \medskip
@@ -3412,7 +3471,7 @@ version 2005/12/01 or later.
%
%
%
-% \section{Implementation}
+%\section{Implementation}
%
% By default, the package \pkg{nicematrix} doesn't patch any existing code.
%
@@ -3668,7 +3727,7 @@ version 2005/12/01 or later.
\cs_set:Npn \@@_cline
% \end{macrocode}
% We have to act in a fully expandable way since there may be |\noalign| (in the
-% |\multispan|) to detect. That's why we use |\@@_cline_i:en|.
+% |\multispan|) to detect. That's why we use |\@@_cline_i:en|.
% \begin{macrocode}
{ \@@_cline_i:en \l_@@_first_col_int }
% \end{macrocode}
@@ -4089,8 +4148,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| 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| will be used when we will draw the
+% rules required by the keys |hvlines| or |hvlines-except-corners|.
%
% \bigskip
% We will also manage a sequence for the positions of the dotted lines. These
@@ -4370,6 +4429,12 @@ version 2005/12/01 or later.
\bool_new:N \l_@@_vlines_bool
\bool_new:N \l_@@_hvlines_bool
% \end{macrocode}
+%
+% \bigskip
+% The flag |\l_@@_hlines_except_corners_bool| corresponds to the key |hlines-except-corners|.
+% \begin{macrocode}
+\bool_new:N \l_@@_hvlines_except_corners_bool
+% \end{macrocode}
%
% \bigskip
% The flag |\l_@@_nullify_dots_bool| corresponds to the option |nullify-dots|.
@@ -4573,6 +4638,8 @@ version 2005/12/01 or later.
% \begin{macrocode}
\keys_define:nn { NiceMatrix / Env }
{
+ hvlines-except-corners .bool_set:N = \l_@@_hvlines_except_corners_bool ,
+ hvlines-except-corners .default:n = true ,
code-before .code:n =
{
\tl_if_empty:nF { #1 }
@@ -7049,6 +7116,8 @@ version 2005/12/01 or later.
{
\bool_if:NT \l_@@_hlines_bool \@@_draw_hlines:
\bool_if:NT \l_@@_vlines_bool \@@_draw_vlines:
+ \bool_if:NT \l_@@_hvlines_except_corners_bool
+ \@@_draw_hvlines_except_corners:
}
% \end{macrocode}
%
@@ -9064,6 +9133,7 @@ version 2005/12/01 or later.
%
% \subsection*{The key hvlines}
%
+% \subsubsection*{The key hvlines}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_draw_hlines:
@@ -9125,35 +9195,13 @@ version 2005/12/01 or later.
\group_begin:
\CT@arc@
% \end{macrocode}
-%
-% First, the exterior rectangle of the array (only in |{NiceArray}| and
-% |{NiceTabular}|).
-% \begin{macrocode}
- \bool_if:NT \l_@@_NiceArray_bool
- {
- \pgfpicture
- \pgfrememberpicturepositiononpagetrue
- \pgf@relevantforpicturesizefalse
- \pgfsetlinewidth \arrayrulewidth
- \pgfsetrectcap
- \@@_qpoint:n { col - 1 }
- \dim_set_eq:NN \l_tmpa_dim \pgf@x
- \@@_qpoint:n { row -1 }
- \dim_set_eq:NN \l_tmpb_dim \pgf@y
- \@@_qpoint:n { col - \@@_succ:n \c@jCol }
- \dim_set_eq:NN \l_tmpc_dim \pgf@x
- \@@_qpoint:n { row - \@@_succ:n \c@iRow }
- \pgfpathrectanglecorners
- { \pgfpoint \l_tmpa_dim \l_tmpb_dim }
- { \pgfpoint \l_tmpc_dim \pgf@y }
- \pgfusepathqstroke
- \endpgfpicture
- }
-% \end{macrocode}
%
-% Now, the horizontal rules in the interior of the array.
+% The horizontal rules.
% \begin{macrocode}
- \int_step_variable:nnNn 2 \c@iRow \l_tmpa_tl
+ \int_step_variable:nnNn
+ { \bool_if:NTF \l_@@_NiceArray_bool 1 2 }
+ { \bool_if:NTF \l_@@_NiceArray_bool { \@@_succ:n \c@iRow } \c@iRow }
+ \l_tmpa_tl
{
\int_step_variable:nNn \c@jCol \l_tmpb_tl
{
@@ -9169,6 +9217,35 @@ version 2005/12/01 or later.
{ \@@_test_if_hline_in_block:nnnn ##1 }
\seq_map_inline:Nn \g_@@_pos_of_xdots_seq
{ \@@_test_if_hline_in_block:nnnn ##1 }
+% \end{macrocode}
+% \begin{macrocode}
+ \bool_if:NT \l_@@_hvlines_except_corners_bool
+ {
+ \int_compare:nNnTF \l_tmpa_tl = { \c@iRow + 1 }
+ {
+ \seq_if_in:NxT
+ \l_@@_empty_corner_cells_seq
+ { \@@_pred:n \l_tmpa_tl - \l_tmpb_tl }
+ { \bool_set_false:N \g_tmpa_bool }
+ }
+ {
+ \seq_if_in:NxT
+ \l_@@_empty_corner_cells_seq
+ { \l_tmpa_tl - \l_tmpb_tl }
+ {
+ \int_compare:nNnTF \l_tmpa_tl = 1
+ { \bool_set_false:N \g_tmpa_bool }
+ {
+ \seq_if_in:NxT
+ \l_@@_empty_corner_cells_seq
+ { \@@_pred:n \l_tmpa_tl - \l_tmpb_tl }
+ { \bool_set_false:N \g_tmpa_bool }
+ }
+ }
+ }
+ }
+% \end{macrocode}
+% \begin{macrocode}
\bool_if:NT \g_tmpa_bool
{
\pgfpicture
@@ -9190,17 +9267,20 @@ version 2005/12/01 or later.
}
}
% \end{macrocode}
-% Now, the vertical rules in the interior of the array.
+% Now, the vertical rules.
% \begin{macrocode}
\int_step_variable:nNn \c@iRow \l_tmpa_tl
{
- \int_step_variable:nnNn 2 \c@jCol \l_tmpb_tl
+ \int_step_variable:nnNn
+ { \bool_if:NTF \l_@@_NiceArray_bool 1 2 }
+ { \bool_if:NTF \l_@@_NiceArray_bool { \@@_succ:n \c@jCol } \c@jCol }
+ \l_tmpb_tl
{
% \end{macrocode}
-% The boolean |\g_tmpa_bool| indicates whether the small vertial rule will be
+% The boolean |\g_tmpa_bool| indicates whether the small vertical rule will be
% drawn. If we find that it is in a block (a real block, created by |\Block| or
% a virtual block corresponding to a dotted line, created by |\Cdots|, |\Vdots|,
-% etc.), we will set |\g_tmpa_bool| to |false| and the small vertial rule won't
+% etc.), we will set |\g_tmpa_bool| to |false| and the small vertical rule won't
% be drawn.
% \begin{macrocode}
\bool_gset_true:N \g_tmpa_bool
@@ -9208,6 +9288,37 @@ version 2005/12/01 or later.
{ \@@_test_if_vline_in_block:nnnn ##1 }
\seq_map_inline:Nn \g_@@_pos_of_xdots_seq
{ \@@_test_if_vline_in_block:nnnn ##1 }
+% \end{macrocode}
+%
+% \begin{macrocode}
+ \bool_if:NT \l_@@_hvlines_except_corners_bool
+ {
+ \int_compare:nNnTF \l_tmpb_tl = { \@@_succ:n \c@jCol }
+ {
+ \seq_if_in:NxT
+ \l_@@_empty_corner_cells_seq
+ { \l_tmpa_tl - \@@_pred:n \l_tmpb_tl }
+ { \bool_set_false:N \g_tmpa_bool }
+ }
+ {
+ \seq_if_in:NxT
+ \l_@@_empty_corner_cells_seq
+ { \l_tmpa_tl - \l_tmpb_tl }
+ {
+ \int_compare:nNnTF \l_tmpb_tl = 1
+ { \bool_set_false:N \g_tmpa_bool }
+ {
+ \seq_if_in:NxT
+ \l_@@_empty_corner_cells_seq
+ { \l_tmpa_tl - \@@_pred:n \l_tmpb_tl }
+ { \bool_set_false:N \g_tmpa_bool }
+ }
+ }
+ }
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
\bool_if:NT \g_tmpa_bool
{
\pgfpicture
@@ -9242,7 +9353,7 @@ version 2005/12/01 or later.
% |#1|, |#2|, |#3| and |#4|. If this rule would be in the block (it must not be
% drawn), the boolean |\l_tmpa_bool| is set to |false|.
% \begin{macrocode}
-\cs_set_protected:Npn \@@_test_if_hline_in_block:nnnn #1 #2 #3 #4
+\cs_new_protected:Npn \@@_test_if_hline_in_block:nnnn #1 #2 #3 #4
{
\int_compare:nNnT \l_tmpa_tl > { #1 }
{
@@ -9260,7 +9371,7 @@ version 2005/12/01 or later.
%
% The same for vertical rules.
% \begin{macrocode}
-\cs_set_protected:Npn \@@_test_if_vline_in_block:nnnn #1 #2 #3 #4
+\cs_new_protected:Npn \@@_test_if_vline_in_block:nnnn #1 #2 #3 #4
{
\int_compare:nNnT \l_tmpa_tl > { #1 - 1 }
{
@@ -9277,8 +9388,158 @@ version 2005/12/01 or later.
% \end{macrocode}
%
%
+% \bigskip
+% \subsubsection*{The key hvlines-except-corners}
%
+%
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_draw_hvlines_except_corners:
+ {
+% \end{macrocode}
+% The sequence |\l_@@_empty_corner_cells_seq| will be the sequence of all the
+% cells empty (and not in a block) considered in the corners of the array.
+% \begin{macrocode}
+ \seq_clear_new:N \l_@@_empty_corner_cells_seq
+ \@@_compute_a_corner:nnnnnn 1 1 1 1 \c@iRow \c@jCol
+ \@@_compute_a_corner:nnnnnn 1 \c@jCol 1 { -1 } \c@iRow 1
+ \@@_compute_a_corner:nnnnnn \c@iRow 1 { -1 } 1 1 \c@jCol
+ \@@_compute_a_corner:nnnnnn \c@iRow \c@jCol { -1 } { -1 } 1 1
+ \@@_draw_hvlines_ii:
+ }
+% \end{macrocode}
+%
+% \bigskip
+% ``Computing a corner'' is determining all the empty cells (which are not in a
+% block) that belong to that corner. These cells will be added to the sequence
+% |\l_@@_empty_corner_cells_seq|.
+%
+% \medskip
+% The six arguments of |\@@_compute_a_corner:nnnnnn| are as follow:
+% \begin{itemize}
+% \item |#1| and |#2| are the number of row and column of the cell which is
+% actually in the corner ;
+% \item |#3| and |#4| are the step in rows and the step in columns when moving
+% from the corner ;
+% \item |#5| is the number of the final row when scanning the rows from the
+% corner ;
+% \item |#6| is the number of the final column when scanning the columns from
+% the corner.
+% \end{itemize}
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_compute_a_corner:nnnnnn #1 #2 #3 #4 #5 #6
+ {
+% \end{macrocode}
+% For the explanations and the name of the variables, we consider that we are
+% computing the left-upper corner.
+%
+% First, we try to determine which is the last empty cell (and not in a block:
+% we won't add that precision any longer) in the column of number~$1$. The flag
+% |\l_tmpa_bool| will be raised when a non-empty cell is found.
+% \begin{macrocode}
+ \bool_set_false:N \l_tmpa_bool
+ \int_zero_new:N \l_@@_last_empty_row_int
+ \int_step_inline:nnnn { #1 } { #3 } { #5 }
+ {
+ \@@_test_if_cell_in_a_block:nx { ##1 } { \int_eval:n { #2 } }
+ \bool_if:nTF
+ {
+ \cs_if_exist_p:c
+ { pgf @ sh @ ns @ \@@_env: - ##1 - \int_eval:n { #2 } }
+ ||
+ \l_tmpb_bool
+ }
+ { \bool_set_true:N \l_tmpa_bool }
+ {
+ \bool_if:NF \l_tmpa_bool
+ { \int_set:Nn \l_@@_last_empty_row_int { ##1 } }
+ }
+ }
+% \end{macrocode}
+% Now, you determine the last empty cell in the row of number~$1$.
+% \begin{macrocode}
+ \bool_set_false:N \l_tmpa_bool
+ \int_zero_new:N \l_@@_last_empty_column_int
+ \int_step_inline:nnnn { #2 } { #4 } { #6 }
+ {
+ \@@_test_if_cell_in_a_block:xn { \int_eval:n { #1 } } { ##1 }
+ \bool_if:nTF
+ {
+ \cs_if_exist_p:c
+ { pgf @ sh @ ns @ \@@_env: - \int_eval:n { #1 } - ##1 }
+ || \l_tmpb_bool
+ }
+ { \bool_set_true:N \l_tmpa_bool }
+ {
+ \bool_if:NF \l_tmpa_bool
+ { \int_set:Nn \l_@@_last_empty_column_int { ##1 } }
+ }
+ }
+% \end{macrocode}
+% Now, we loop over the rows.
+% \begin{macrocode}
+ \int_step_inline:nnnn { #1 } { #3 } \l_@@_last_empty_row_int
+ {
+% \end{macrocode}
+% We treat the row number |##1| with another loop.
+% \begin{macrocode}
+ \bool_set_false:N \l_tmpa_bool
+ \int_step_inline:nnnn { #2 } { #4 } \l_@@_last_empty_column_int
+ {
+ \@@_test_if_cell_in_a_block:nn { ##1 } { ####1 }
+ \bool_if:nTF
+ {
+ \cs_if_exist_p:c
+ { pgf @ sh @ ns @ \@@_env: - ##1 - ####1 }
+ || \l_tmpb_bool
+ }
+ { \bool_set_true:N \l_tmpa_bool }
+ {
+ \bool_if:NF \l_tmpa_bool
+ {
+ \int_set:Nn \l_@@_last_empty_column_int { ####1 }
+ \seq_put_right:Nn
+ \l_@@_empty_corner_cells_seq
+ { ##1 - ####1 }
+ }
+ }
+ }
+ }
+ }
+% \end{macrocode}
+%
+% \bigskip
+% The following macro tests whether if a cell is in (at least) one of the blocks
+% of the array.
+%
+% The flag |\l_tmpb_bool| will be raised if the cell |#1|-|#2| is in a block.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_test_if_cell_in_a_block:nn #1 #2
+ {
+ \bool_set_false:N \l_tmpb_bool
+ \seq_map_inline:Nn \g_@@_pos_of_blocks_seq
+ { \@@_test_if_cell_in_block:nnnnnnn { #1 } { #2 } ##1 }
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_generate_variant:Nn \@@_test_if_cell_in_a_block:nn { nx , xn }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_test_if_cell_in_block:nnnnnnn #1 #2 #3 #4 #5 #6
+ {
+ \bool_if:nT
+ {
+ \int_compare_p:n { #3 <= #1 }
+ && \int_compare_p:n { #1 <= #5 }
+ && \int_compare_p:n { #4 <= #2 }
+ && \int_compare_p:n { #2 <= #6 }
+ }
+ { \bool_set_true:N \l_tmpb_bool }
+ }
+% \end{macrocode}
%
+%
% \bigskip
% \subsection*{The commands to draw dotted lines to separate columns and rows}
%
@@ -10008,7 +10269,7 @@ 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 (even if, as for new, there is only one key, called
+% The group is for the keys (even if, as for now, there is only one key, called
% |tikz| and not documented).
% \begin{macrocode}
\group_begin:
@@ -10785,6 +11046,7 @@ version 2005/12/01 or later.
first-row,~
hlines,~
hvlines,~
+ hvlines-except-corners,~
last-col,~
last-row,~
left-margin,~
@@ -11309,6 +11571,10 @@ version 2005/12/01 or later.
%
% It's now possible to use the command |\Block| in the ``last row''.
%
+% \subsection*{Changes between versions 4.3 and 4.4}
+%
+% New key |hvlines-except-corners|.
+%
%
% \PrintIndex
%