diff options
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf | bin | 356758 -> 359504 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex | 65 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf | bin | 882583 -> 896061 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx | 352 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty | 183 |
5 files changed, 529 insertions, 71 deletions
diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf Binary files differindex 24432563ff4..fa9a6f9a400 100644 --- a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf +++ b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex index a8c0fdd4351..fe29f84779a 100644 --- a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex +++ b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex @@ -639,8 +639,9 @@ a & b & c & d \\ \label{hvlines} La clé |hvlines| demande le tracé de tous les filets horizontaux et verticaux \emph{sauf dans les - blocs}.\footnote{En fait, quand la clé |hvlines| est utilisée, les filets ne sont pas non plus tracés dans les blocs virtuels - délimités par des cases reliées par des lignes pointillées (cf. p. \pageref{dotted-and-hvlines}).} + blocs}.\footnote{En fait, quand la clé |hvlines| (ou la clé |hvlines-except-corners| décrite juste après) est + utilisée, les filets ne sont pas non plus tracés dans les blocs virtuels délimités par des cases reliées par des + lignes pointillées (cf. p. \pageref{dotted-and-hvlines}).} \medskip \begin{Verbatim} @@ -662,6 +663,66 @@ arum & iris & jacinthe & muguet \end{center} +\subsection{La clé hvlines-except-corners} + +La clé |hvlines-except-corners| demande le tracé de tous les filets horizontaux et verticaux \emph{sauf dans les + blocs} et sauf dans les coins vides. + +\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} + +Comme on le voit, un «coin vide» est constitué de la réunion de tous les rectangles vides partant de la case située +exactement dans le coin. + +\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} diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf b/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf Binary files differindex 31fb149271d..2c72de6ae13 100644 --- a/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf +++ b/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf 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 % diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty index d286a1bb15c..70dedcb495c 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{4.3} -\def\myfiledate{2020/06/12} +\def\myfileversion{4.4} +\def\myfiledate{2020/06/30} \RequirePackage{pgfcore} \usepgfmodule{shapes} \RequirePackage{l3keys2e} @@ -323,6 +323,7 @@ \bool_new:N \l__nicematrix_hlines_bool \bool_new:N \l__nicematrix_vlines_bool \bool_new:N \l__nicematrix_hvlines_bool +\bool_new:N \l__nicematrix_hvlines_except_corners_bool \bool_new:N \l__nicematrix_nullify_dots_bool \bool_new:N \l__nicematrix_auto_columns_width_bool \str_new:N \l__nicematrix_name_str @@ -418,6 +419,8 @@ } \keys_define:nn { NiceMatrix / Env } { + hvlines-except-corners .bool_set:N = \l__nicematrix_hvlines_except_corners_bool , + hvlines-except-corners .default:n = true , code-before .code:n = { \tl_if_empty:nF { #1 } @@ -1771,6 +1774,8 @@ { \bool_if:NT \l__nicematrix_hlines_bool \__nicematrix_draw_hlines: \bool_if:NT \l__nicematrix_vlines_bool \__nicematrix_draw_vlines: + \bool_if:NT \l__nicematrix_hvlines_except_corners_bool + \__nicematrix_draw_hvlines_except_corners: } \cs_set_eq:NN \ialign \__nicematrix_old_ialign: \seq_if_empty:NF \g__nicematrix_blocks_seq \__nicematrix_draw_blocks: @@ -3076,27 +3081,10 @@ { \group_begin: \CT@arc@ - \bool_if:NT \l__nicematrix_NiceArray_bool - { - \pgfpicture - \pgfrememberpicturepositiononpagetrue - \pgf@relevantforpicturesizefalse - \pgfsetlinewidth \arrayrulewidth - \pgfsetrectcap - \__nicematrix_qpoint:n { col - 1 } - \dim_set_eq:NN \l_tmpa_dim \pgf@x - \__nicematrix_qpoint:n { row -1 } - \dim_set_eq:NN \l_tmpb_dim \pgf@y - \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \c@jCol } - \dim_set_eq:NN \l_tmpc_dim \pgf@x - \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \c@iRow } - \pgfpathrectanglecorners - { \pgfpoint \l_tmpa_dim \l_tmpb_dim } - { \pgfpoint \l_tmpc_dim \pgf@y } - \pgfusepathqstroke - \endpgfpicture - } - \int_step_variable:nnNn 2 \c@iRow \l_tmpa_tl + \int_step_variable:nnNn + { \bool_if:NTF \l__nicematrix_NiceArray_bool 1 2 } + { \bool_if:NTF \l__nicematrix_NiceArray_bool { \__nicematrix_succ:n \c@iRow } \c@iRow } + \l_tmpa_tl { \int_step_variable:nNn \c@jCol \l_tmpb_tl { @@ -3105,6 +3093,31 @@ { \__nicematrix_test_if_hline_in_block:nnnn ##1 } \seq_map_inline:Nn \g__nicematrix_pos_of_xdots_seq { \__nicematrix_test_if_hline_in_block:nnnn ##1 } + \bool_if:NT \l__nicematrix_hvlines_except_corners_bool + { + \int_compare:nNnTF \l_tmpa_tl = { \c@iRow + 1 } + { + \seq_if_in:NxT + \l__nicematrix_empty_corner_cells_seq + { \__nicematrix_pred:n \l_tmpa_tl - \l_tmpb_tl } + { \bool_set_false:N \g_tmpa_bool } + } + { + \seq_if_in:NxT + \l__nicematrix_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__nicematrix_empty_corner_cells_seq + { \__nicematrix_pred:n \l_tmpa_tl - \l_tmpb_tl } + { \bool_set_false:N \g_tmpa_bool } + } + } + } + } \bool_if:NT \g_tmpa_bool { \pgfpicture @@ -3127,13 +3140,41 @@ } \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__nicematrix_NiceArray_bool 1 2 } + { \bool_if:NTF \l__nicematrix_NiceArray_bool { \__nicematrix_succ:n \c@jCol } \c@jCol } + \l_tmpb_tl { \bool_gset_true:N \g_tmpa_bool \seq_map_inline:Nn \g__nicematrix_pos_of_blocks_seq { \__nicematrix_test_if_vline_in_block:nnnn ##1 } \seq_map_inline:Nn \g__nicematrix_pos_of_xdots_seq { \__nicematrix_test_if_vline_in_block:nnnn ##1 } + \bool_if:NT \l__nicematrix_hvlines_except_corners_bool + { + \int_compare:nNnTF \l_tmpb_tl = { \__nicematrix_succ:n \c@jCol } + { + \seq_if_in:NxT + \l__nicematrix_empty_corner_cells_seq + { \l_tmpa_tl - \__nicematrix_pred:n \l_tmpb_tl } + { \bool_set_false:N \g_tmpa_bool } + } + { + \seq_if_in:NxT + \l__nicematrix_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__nicematrix_empty_corner_cells_seq + { \l_tmpa_tl - \__nicematrix_pred:n \l_tmpb_tl } + { \bool_set_false:N \g_tmpa_bool } + } + } + } + } \bool_if:NT \g_tmpa_bool { \pgfpicture @@ -3157,7 +3198,7 @@ \group_end: \seq_gclear:N \g__nicematrix_pos_of_xdots_seq } -\cs_set_protected:Npn \__nicematrix_test_if_hline_in_block:nnnn #1 #2 #3 #4 +\cs_new_protected:Npn \__nicematrix_test_if_hline_in_block:nnnn #1 #2 #3 #4 { \int_compare:nNnT \l_tmpa_tl > { #1 } { @@ -3171,7 +3212,7 @@ } } } -\cs_set_protected:Npn \__nicematrix_test_if_vline_in_block:nnnn #1 #2 #3 #4 +\cs_new_protected:Npn \__nicematrix_test_if_vline_in_block:nnnn #1 #2 #3 #4 { \int_compare:nNnT \l_tmpa_tl > { #1 - 1 } { @@ -3185,6 +3226,95 @@ } } } +\cs_new_protected:Npn \__nicematrix_draw_hvlines_except_corners: + { + \seq_clear_new:N \l__nicematrix_empty_corner_cells_seq + \__nicematrix_compute_a_corner:nnnnnn 1 1 1 1 \c@iRow \c@jCol + \__nicematrix_compute_a_corner:nnnnnn 1 \c@jCol 1 { -1 } \c@iRow 1 + \__nicematrix_compute_a_corner:nnnnnn \c@iRow 1 { -1 } 1 1 \c@jCol + \__nicematrix_compute_a_corner:nnnnnn \c@iRow \c@jCol { -1 } { -1 } 1 1 + \__nicematrix_draw_hvlines_ii: + } +\cs_new_protected:Npn \__nicematrix_compute_a_corner:nnnnnn #1 #2 #3 #4 #5 #6 + { + \bool_set_false:N \l_tmpa_bool + \int_zero_new:N \l__nicematrix_last_empty_row_int + \int_step_inline:nnnn { #1 } { #3 } { #5 } + { + \__nicematrix_test_if_cell_in_a_block:nx { ##1 } { \int_eval:n { #2 } } + \bool_if:nTF + { + \cs_if_exist_p:c + { pgf @ sh @ ns @ \__nicematrix_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__nicematrix_last_empty_row_int { ##1 } } + } + } + \bool_set_false:N \l_tmpa_bool + \int_zero_new:N \l__nicematrix_last_empty_column_int + \int_step_inline:nnnn { #2 } { #4 } { #6 } + { + \__nicematrix_test_if_cell_in_a_block:xn { \int_eval:n { #1 } } { ##1 } + \bool_if:nTF + { + \cs_if_exist_p:c + { pgf @ sh @ ns @ \__nicematrix_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__nicematrix_last_empty_column_int { ##1 } } + } + } + \int_step_inline:nnnn { #1 } { #3 } \l__nicematrix_last_empty_row_int + { + \bool_set_false:N \l_tmpa_bool + \int_step_inline:nnnn { #2 } { #4 } \l__nicematrix_last_empty_column_int + { + \__nicematrix_test_if_cell_in_a_block:nn { ##1 } { ####1 } + \bool_if:nTF + { + \cs_if_exist_p:c + { pgf @ sh @ ns @ \__nicematrix_env: - ##1 - ####1 } + || \l_tmpb_bool + } + { \bool_set_true:N \l_tmpa_bool } + { + \bool_if:NF \l_tmpa_bool + { + \int_set:Nn \l__nicematrix_last_empty_column_int { ####1 } + \seq_put_right:Nn + \l__nicematrix_empty_corner_cells_seq + { ##1 - ####1 } + } + } + } + } + } +\cs_new_protected:Npn \__nicematrix_test_if_cell_in_a_block:nn #1 #2 + { + \bool_set_false:N \l_tmpb_bool + \seq_map_inline:Nn \g__nicematrix_pos_of_blocks_seq + { \__nicematrix_test_if_cell_in_block:nnnnnnn { #1 } { #2 } ##1 } + } +\cs_generate_variant:Nn \__nicematrix_test_if_cell_in_a_block:nn { nx , xn } +\cs_new_protected:Npn \__nicematrix_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 } + } \cs_new:Npn \__nicematrix_hdottedline: { \noalign { \skip_vertical:N 2\l__nicematrix_radius_dim } @@ -3944,6 +4074,7 @@ first-row,~ hlines,~ hvlines,~ + hvlines-except-corners,~ last-col,~ last-row,~ left-margin,~ |