summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/nicematrix/nicematrix.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/nicematrix/nicematrix.dtx')
-rw-r--r--macros/latex/contrib/nicematrix/nicematrix.dtx661
1 files changed, 378 insertions, 283 deletions
diff --git a/macros/latex/contrib/nicematrix/nicematrix.dtx b/macros/latex/contrib/nicematrix/nicematrix.dtx
index 2f7bfdc597..034b863418 100644
--- a/macros/latex/contrib/nicematrix/nicematrix.dtx
+++ b/macros/latex/contrib/nicematrix/nicematrix.dtx
@@ -15,8 +15,8 @@
%
% \fi
% \iffalse
-\def\myfileversion{6.1}
-\def\myfiledate{2021/08/20}
+\def\myfileversion{6.2}
+\def\myfiledate{2021/09/09}
%
%
%<*batchfile>
@@ -65,7 +65,7 @@ version 2005/12/01 or later.
\usepackage{titlesec}
\titlespacing*{\section}{0pt}{6.5ex plus 1ex minus .2ex}{4.3ex plus .2ex}
\titlespacing*{\subsection}{0pt}{4.5ex plus 1ex minus .2ex}{2ex plus .2ex}
-\usepackage[hyperfootnotes=false]{footnotehyper}
+\usepackage{footnotehyper}
\usepackage{varwidth}
\def\LetterAt{@}
\parindent 0pt
@@ -223,9 +223,7 @@ version 2005/12/01 or later.
% \end{tabular}
% \end{ttfamily}
%
-%
-%
-%
+% %
% \medskip
% The environments |{NiceArray}|, |{NiceTabular}| and |{NiceTabular*}| are
% similar to the environments |{array}|, |{tabular}| and |{tabular*}| of the
@@ -893,7 +891,7 @@ version 2005/12/01 or later.
% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
% \setlength{\arrayrulewidth}{2pt}
% \begin{NiceTabular}{cccc} \hline
-% A&B&C&D \\ ~emphase#\cline{2-2}@
+% A&B&C&D \\ ~emphase#\cline{2}@
% A&B&C&D \\ \hline
% \end{NiceTabular}
% \end{BVerbatim}
@@ -902,12 +900,18 @@ version 2005/12/01 or later.
% \begin{NiceTabular}[c]{cccc}
% \hline
% A&B&C&D \\
-% \cline{2-2}
+% \cline{2}
% A&B&C&D \\
% \hline
% \end{NiceTabular}
% \end{scope}
%
+% \medskip
+% \colorbox{yellow!50}{\textbf{New 6.2}}
+%
+% In the environments of \pkg{nicematrix}, an instruction |\cline{|\textsl{\texttt{i}}|}|
+% is equivalent to |\cline{|\textsl{\texttt{i}}|-|\textsl{\texttt{i}}|}|.
+%
%
% \subsection{The thickness and the color of the rules}
%
@@ -1953,7 +1957,10 @@ version 2005/12/01 or later.
%
% For sake of similarity with the environment |{tabularx}|, \pkg{nicematrix}
% also provides an environment |{NiceTabularX}| with a first mandatory argument
-% which is the width of the tabular.
+% which is the width of the tabular.\footnote{If \pkg{tabularx} is loaded, one
+% must use |{NiceTabularX}| (and not |{NiceTabular}|) in order to use the
+% columns `X` (this point comes from a conflict in the definitions of the
+% specifier `X`).}
%
% As with the packages \pkg{tabu} and \pkg{tabularray}, the specifier |X| takes
% in an optional argument (between square brackets) which is a list of keys.
@@ -4335,11 +4342,6 @@ version 2005/12/01 or later.
% \NiceMatrixOptions{letter-for-dotted-lines=;}
% \end{Verbatim}
%
-% \bigskip
-% Up to now, the package \pkg{nicematrix} is not compatible with
-% \cls{aastex63}. If you want to use \pkg{nicematrix} with \cls{aastex63}, send
-% me an email and I will try to solve the incompatibilies.
-%
%
% \bigskip
% The package \pkg{nicematrix} is not compatible with the class \cls{ieeeaccess}
@@ -4351,6 +4353,17 @@ version 2005/12/01 or later.
%\label{tikz-key-examples}
%
%
+% The key |tikz| of the command |\Block| is available only when Tikz is
+% loaded.\footnote{By default, \pkg{nicematrix} only loads \textsc{pgf}, which is
+% a sub-layer of Tikz.}
+%
+% For the following example, you need also the Tikz library |patterns|
+%
+% \begin{Verbatim}
+% \usetikzlibrary{patterns}
+% \end{Verbatim}
+%
+%
% \begin{Verbatim}
% \ttfamily \small
% \begin{NiceTabular}{X[m]X[m]X[m]}[hvlines,cell-space-limits=3pt]
@@ -4843,6 +4856,83 @@ version 2005/12/01 or later.
% \end{NiceMatrix}\]
% \end{scope}
%
+% \bigskip
+% In this tabular, the instructions |\SubMatrix| are executed after the
+% composition of the tabular and, thus, the vertical rules are drawn without
+% adding space between the columns.
+%
+%
+%\bigskip
+% \colorbox{yellow!50}{\textbf{New 6.2}}\enskip In fact, it's possible, with the
+% key |vlines-in-sub-matrix|, to choice a letter in the preamble of the
+% array to specify vertical rules which will be drawn in the |\SubMatrix| only
+% (by adding space between the columns).
+%
+% \medskip
+% \begin{Verbatim}
+% \setlength{\extrarowheight}{1mm}
+% \[\begin{NiceArray}
+% [
+% ~emphase#vlines-in-sub-matrix=I@,
+% last-col,
+% code-for-last-col = \scriptstyle \color{blue}
+% ]
+% {rrrrIr}
+% 12 & -8 & 7 & 5 & 3 \\
+% 3 & -18 & 12 & 1 & 4 \\
+% -3 & -46 & 29 &-2 &-15 \\
+% 9 & 10 &-5 &4 & 7 \\[1mm]
+% 12 & -8 & 7 &5 & 3 \\
+% 0 & 64 &-41 & 1 & 19 & L_2 \gets L_1-4L_2 \\
+% 0 & -192 &123 &-3 &-57 & L_3 \gets L_1+4L_3 \\
+% 0 & -64 & 41 &-1 &-19 & L_4 \gets 3L_1-4L_4 \\[1mm]
+% 12 & -8 &7 &5 & 3 \\
+% 0 & 64 &-41 &1 &19 \\
+% 0 & 0 &0 &0 & 0 & L_3 \gets 3L_2+L_3 \\[1mm]
+% 12 & -8 &7 &5 & 3 \\
+% 0 & 64 &-41 & 1 & 19 \\
+% \CodeAfter
+% \SubMatrix({1-1}{4-5})
+% \SubMatrix({5-1}{8-5})
+% \SubMatrix({9-1}{11-5})
+% \SubMatrix({12-1}{13-5})
+% \end{NiceArray}\]
+% \end{Verbatim}
+%
+%
+% \medskip
+% \begin{scope}
+% \setlength{\extrarowheight}{1mm}
+% \[\begin{NiceArray}
+% [
+% vlines-in-sub-matrix=I,
+% last-col,
+% code-for-last-col = \scriptstyle \color{blue}
+% ]
+% {rrrrIr}
+% 12 & -8 & 7 & 5 & 3 \\
+% 3 & -18 & 12 & 1 & 4 \\
+% -3 & -46 & 29 &-2 &-15 \\
+% 9 & 10 &-5 &4 & 7 \\[1mm]
+% 12 & -8 & 7 &5 & 3 \\
+% 0 & 64 &-41 & 1 & 19 & L_2 \gets L_1-4L_2 \\
+% 0 & -192 &123 &-3 &-57 & L_3 \gets L_1+4L_3 \\
+% 0 & -64 & 41 &-1 &-19 & L_4 \gets 3L_1-4L_4 \\[1mm]
+% 12 & -8 &7 &5 & 3 \\
+% 0 & 64 &-41 &1 &19 \\
+% 0 & 0 &0 &0 & 0 & L_3 \gets 3L_2+L_3 \\[1mm]
+% 12 & -8 &7 &5 & 3 \\
+% 0 & 64 &-41 & 1 & 19 \\
+% \CodeAfter
+% \SubMatrix({1-1}{4-5})
+% \SubMatrix({5-1}{8-5})
+% \SubMatrix({9-1}{11-5})
+% \SubMatrix({12-1}{13-5})
+% \end{NiceArray}\]
+% \end{scope}
+%
+%
+%
%
%
% \subsection{How to highlight cells of a matrix}
@@ -5210,6 +5300,7 @@ version 2005/12/01 or later.
\bool_new:N \c_@@_arydshln_loaded_bool
\bool_new:N \c_@@_booktabs_loaded_bool
\bool_new:N \c_@@_enumitem_loaded_bool
+\bool_new:N \c_@@_tabularx_loaded_bool
\bool_new:N \c_@@_tikz_loaded_bool
\AtBeginDocument
{
@@ -5222,6 +5313,9 @@ version 2005/12/01 or later.
\@ifpackageloaded { enumitem }
{ \bool_set_true:N \c_@@_enumitem_loaded_bool }
{ }
+ \@ifpackageloaded { tabularx }
+ { \bool_set_true:N \c_@@_tabularx_loaded_bool }
+ { }
\@ifpackageloaded { tikz }
{
% \end{macrocode}
@@ -5459,10 +5553,19 @@ version 2005/12/01 or later.
% \end{macrocode}
% The command |\cline_i:nn| has two arguments. The first is the number of the
% current column (it \emph{must} be used in that column). The second is a
-% standard argument of |\cline| of the form \textsl{i}-\textsl{j}.
+% standard argument of |\cline| of the form \textsl{i}-\textsl{j} or the form
+% \textsl{i}.
% \begin{macrocode}
-\cs_set:Npn \@@_cline_i:nn #1 #2 { \@@_cline_i:w #1-#2 \q_stop }
-\cs_set:Npn \@@_cline_i:w #1-#2-#3 \q_stop
+\cs_set:Npn \@@_cline_i:nn #1 #2 { \@@_cline_i:w #1|#2- \q_stop }
+\cs_set:Npn \@@_cline_i:w #1|#2-#3 \q_stop
+ {
+ \tl_if_empty:nTF { #3 }
+ { \@@_cline_iii:w #1|#2-#2 \q_stop }
+ { \@@_cline_ii:w #1|#2-#3 \q_stop }
+ }
+\cs_set:Npn \@@_cline_ii:w #1|#2-#3-\q_stop
+ { \@@_cline_iii:w #1|#2-#3 \q_stop }
+\cs_set:Npn \@@_cline_iii:w #1|#2-#3 \q_stop
{
% \end{macrocode}
% Now, |#1| is the number of the current column and we have to draw a line from
@@ -5934,7 +6037,7 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
-% The following token list will contain ce code inserted in each cell of the
+% The following token list will contain the code inserted in each cell of the
% current row (this token list will be cleared at the beginning of each row).
% \begin{macrocode}
\tl_new:N \g_@@_row_style_tl
@@ -6167,6 +6270,18 @@ version 2005/12/01 or later.
% \end{macrocode}
%
%
+% \bigskip
+% The following flag will be used by (for instance) |\@@_vline_ii:nnnn|.
+% When |\l_@@_dotted_bool| is |true|, a dotted line (with our system) will be drawn.
+% \begin{macrocode}
+\bool_new:N \l_@@_dotted_bool
+% \end{macrocode}
+%
+% \bigskip
+% The following dimension will be used to trim the rules drawn in the array.
+% \begin{macrocode}
+\dim_new:N \l_@@_trim_dim
+% \end{macrocode}
%
% \bigskip
% \textbf{Variables for the exterior rows and columns}\par\nobreak
@@ -7323,6 +7438,21 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
+% \bigskip
+% For unexplained reason, with XeTeX (and not with the other engines), the
+% environments of \pkg{nicematrix} were all composed in black and do not take
+% into account the color of the encompassing text. As a workaround, you peek the
+% color in force at the beginning of the environment and we use it now (in each
+% cell of the array).
+% \begin{macrocode}
+ \color { nicematrix }
+% \end{macrocode}
+%
+%
+% \begin{macrocode}
+ \g_@@_row_style_tl
+% \end{macrocode}
+%
% We will call \emph{corners} of the matrix the cases which are at the
% intersection of the exterior rows and exterior columns (of course, the four
% corners doesn't always exist simultaneously).
@@ -7330,7 +7460,6 @@ version 2005/12/01 or later.
% The codes |\l_@@_code_for_first_row_tl| and \emph{al} don't apply in the
% corners of the matrix.
% \begin{macrocode}
- \g_@@_row_style_tl
\int_compare:nNnTF \c@iRow = 0
{
\int_compare:nNnT \c@jCol > 0
@@ -7449,7 +7578,7 @@ version 2005/12/01 or later.
\cs_new_protected:Npn \@@_cell_end:
{
\@@_math_toggle_token:
- \hbox_set_end:
+ \hbox_set_end:
% \end{macrocode}
% The token list |\g_@@_post_action_cell_tl| is (potentially) set during the
% composition of the box |\l_@@_cell_box| and is used now \emph{after} the
@@ -7651,42 +7780,21 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
-%
-% \bigskip
-% We want to use |\array| of \pkg{array}. However, if the class used is
-% \cls{revtex4-1} or \cls{revtex4-2}, we have to do some tuning and use the
-% command |\@array@array| instead of |\array| because these classes do a
-% redefinition of |\array| incompatible with our use of |\array|.
-%
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_revtex_array:
- {
- \cs_set_eq:NN \@acoll \@arrayacol
- \cs_set_eq:NN \@acolr \@arrayacol
- \cs_set_eq:NN \@acol \@arrayacol
- \cs_set_nopar:Npn \@halignto { }
- \@array@array
- }
-% \end{macrocode}
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_array:
{
- \bool_if:NTF \c_@@_revtex_bool
- \@@_revtex_array:
- {
- \bool_if:NTF \l_@@_NiceTabular_bool
- { \dim_set_eq:NN \col@sep \tabcolsep }
- { \dim_set_eq:NN \col@sep \arraycolsep }
- \dim_compare:nNnTF \l_@@_tabular_width_dim = \c_zero_dim
- { \cs_set_nopar:Npn \@halignto { } }
- { \cs_set_nopar:Npx \@halignto { to \dim_use:N \l_@@_tabular_width_dim } }
+ \bool_if:NTF \l_@@_NiceTabular_bool
+ { \dim_set_eq:NN \col@sep \tabcolsep }
+ { \dim_set_eq:NN \col@sep \arraycolsep }
+ \dim_compare:nNnTF \l_@@_tabular_width_dim = \c_zero_dim
+ { \cs_set_nopar:Npn \@halignto { } }
+ { \cs_set_nopar:Npx \@halignto { to \dim_use:N \l_@@_tabular_width_dim } }
% \end{macrocode}
% It \pkg{colortbl} is loaded, |\@tabarray| has been redefined to incorporate
% |\CT@start|.
% \begin{macrocode}
- \@tabarray
- }
+ \@tabarray
% \end{macrocode}
% |\l_@@_baseline_tl| may have the value |t|, |c| or |b|. However, if the value
% is |b|, we compose the |\array| (of \pkg{array}) with the option |t| and the
@@ -7840,7 +7948,14 @@ version 2005/12/01 or later.
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_pre_array_ii:
- {
+ {
+% \end{macrocode}
+% For unexplained reason, with XeTeX (and not with the other engines), the
+% environments of \pkg{nicematrix} were all composed in black and do not take
+% into account the color of the encompassing text. As a workaround, you peek the
+% color in force at the beginning of the environment and we will it in each cell.
+% \begin{macrocode}
+ \xglobal \colorlet { nicematrix } { . }
% \end{macrocode}
% The number of letters |X| in the preamble of the array.
% \begin{macrocode}
@@ -8109,6 +8224,7 @@ version 2005/12/01 or later.
%
% \bigskip
% \begin{macrocode}
+ \seq_gclear:N \g_@@_cols_vlism_seq
\seq_gclear:N \g_@@_submatrix_seq
% \end{macrocode}
%
@@ -8460,7 +8576,25 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
-%
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_patch_for_revtex:
+ {
+ \cs_set_eq:NN \@addamp \@addamp@LaTeX
+ \cs_set_eq:NN \insert@column \insert@column@array
+ \cs_set_eq:NN \@classx \@classx@array
+ \cs_set_eq:NN \@xarraycr \@xarraycr@array
+ \cs_set_eq:NN \@arraycr \@arraycr@array
+ \cs_set_eq:NN \@xargarraycr \@xargarraycr@array
+ \cs_set_eq:NN \array \array@array
+ \cs_set_eq:NN \@array \@array@array
+ \cs_set_eq:NN \@tabular \@tabular@array
+ \cs_set_eq:NN \@mkpream \@mkpream@array
+ \cs_set_eq:NN \endarray \endarray@array
+ \cs_set:Npn \@tabarray { \@ifnextchar [ { \@array } { \@array [ c ] } }
+ \cs_set:Npn \endtabular { \endarray $\egroup} % $
+ }
+% \end{macrocode}
+%
% \bigskip
% \subsection*{The environment \{NiceArrayWithDelims\}}
%
@@ -8468,6 +8602,7 @@ version 2005/12/01 or later.
\NewDocumentEnvironment { NiceArrayWithDelims }
{ m m O { } m ! O { } t \CodeBefore }
{
+ \bool_if:NT \c_@@_revtex_bool \@@_patch_for_revtex:
% \end{macrocode}
%
% \begin{macrocode}
@@ -9084,6 +9219,12 @@ version 2005/12/01 or later.
] { \@@_patch_preamble_viii:nn #1 }
\} { \@@_patch_preamble_viii:nn #1 }
X { \@@_patch_preamble_ix:n }
+% \end{macrocode}
+% When \pkg{tabularx} is loaded, a local redefinition of the specifier `X` is
+% done to replace `X` by `\@@_X`. Thus, our column type `X` will be used in the
+% `{NiceTabularX}`.
+% \begin{macrocode}
+ \@@_X { \@@_patch_preamble_ix:n }
\q_stop { }
}
{
@@ -10134,7 +10275,7 @@ version 2005/12/01 or later.
% We need a |{minipage}| because we will insert a LaTeX list for the tabular
% notes (that means that a |\vtop{\hsize=...}| is not enough).
% \begin{macrocode}
- \begin { minipage } [ t ] { \box_wd:N \l_@@_the_array_box }
+ \begin { minipage } [ t ] { \box_wd:N \l_@@_the_array_box }
% \end{macrocode}
% The |\hbox| avoids that the |pgfpicture| inside |\@@_draw_blocks| adds a extra
% vertical space before the notes.
@@ -11007,8 +11148,28 @@ version 2005/12/01 or later.
%
% \bigskip
% \begin{macrocode}
+\cs_set_protected:Npn \@@_newcolumntype #1
+ {
+ \cs_if_free:cT { NC @ find @ #1 }
+ { \NC@list \expandafter { \the \NC@list \NC@do #1 } }
+ \cs_set:cpn {NC @ find @ #1 } ##1 #1 { \NC@ { ##1 } }
+ \peek_meaning:NTF [
+ { \newcol@ #1 }
+ { \newcol@ #1 [ 0 ] }
+ }
+% \end{macrocode}
+%
+% \bigskip
+% \begin{macrocode}
\NewDocumentEnvironment { NiceTabularX } { m O { } m ! O { } }
{
+% \end{macrocode}
+% The following code prevents the expansion of the `X` columns with the
+% definition of that columns in \pkg{tabularx} (this would result in an error in
+% |{NiceTabularX}|).
+% \begin{macrocode}
+ \bool_if:NT \c_@@_tabularx_loaded_bool
+ { \newcolumntype { X } { \@@_X } }
\str_gset:Nn \g_@@_name_env_str { NiceTabularX }
\dim_zero_new:N \l_@@_width_dim
\dim_set:Nn \l_@@_width_dim { #1 }
@@ -11151,7 +11312,7 @@ version 2005/12/01 or later.
%
% If the option |small| is used, the values |\l_@@_radius_dim| and
% |\l_@@_inter_dots_dim| (used to draw the dotted lines created by
-% |\hdottedline| and |\vdotteline| and also for all the other dotted lines when
+% |\hdottedline| and |\vdottedline| and also for all the other dotted lines when
% |line-style| is equal to |standard|, which is the initial value) are changed.
% \begin{macrocode}
\bool_if:NT \l_@@_small_bool
@@ -11190,24 +11351,7 @@ version 2005/12/01 or later.
\@@_adjust_pos_of_blocks_seq:
% \end{macrocode}
%
-% \bigskip
-% The following code is only for efficiency. We determine whether the potential
-% horizontal and vertical rules are ``complete'', that is to say drawn in the
-% whole array. We are sure that all the rules will be complete when there is no
-% block, no virtual block (determined by a command such as |\Cdots|, |\Vdots|,
-% etc.) and no corners. In that case, we switch to a shortcut version of
-% |\@@_vline_i:nn| and |\@@_hline:nn|.
-% \begin{macrocode}
- % \bool_lazy_all:nT
- % {
- % { \seq_if_empty_p:N \g_@@_pos_of_blocks_seq }
- % { \seq_if_empty_p:N \g_@@_pos_of_xdots_seq }
- % { \seq_if_empty_p:N \l_@@_corners_cells_seq }
- % }
- % {
- % \cs_set_eq:NN \@@_vline_i:nn \@@_vline_i_complete:nn
- % \cs_set_eq:NN \@@_hline_i:nn \@@_hline_i_complete:nn
- % }
+% \begin{macrocode}
\tl_if_empty:NF \l_@@_hlines_clist \@@_draw_hlines:
\tl_if_empty:NF \l_@@_vlines_clist \@@_draw_vlines:
% \end{macrocode}
@@ -11757,9 +11901,13 @@ version 2005/12/01 or later.
\seq_gput_right:Nx \g_@@_pos_of_xdots_seq
{
{ \int_use:N \l_@@_initial_i_int }
- { \int_use:N \l_@@_initial_j_int }
+% \end{macrocode}
+% Be careful: with |\Iddots|, |\l_@@_final_j_int| is inferior to
+% |\l_@@_initial_j_int|. That's why we use |\int_min:nn| and |\int_max:nn|.
+% \begin{macrocode}
+ { \int_min:nn \l_@@_initial_j_int \l_@@_final_j_int }
{ \int_use:N \l_@@_final_i_int }
- { \int_use:N \l_@@_final_j_int }
+ { \int_max:nn \l_@@_initial_j_int \l_@@_final_j_int }
}
}
% \end{macrocode}
@@ -12422,7 +12570,7 @@ version 2005/12/01 or later.
\pgf@relevantforpicturesizefalse
\tl_if_eq:NNTF \l_@@_xdots_line_style_tl \c_@@_standard_tl
\@@_draw_standard_dotted_line:
- \@@_draw_non_standard_dotted_line:
+ \@@_draw_unstandard_dotted_line:
}
% \end{macrocode}
%
@@ -12430,10 +12578,10 @@ version 2005/12/01 or later.
% We have to do a special construction with |\exp_args:NV| to be able to put in
% the list of options in the correct place in the Tikz instruction.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_draw_non_standard_dotted_line:
+\cs_new_protected:Npn \@@_draw_unstandard_dotted_line:
{
\begin { scope }
- \exp_args:No \@@_draw_non_standard_dotted_line:n
+ \exp_args:No \@@_draw_unstandard_dotted_line:n
{ \l_@@_xdots_line_style_tl , \l_@@_xdots_color_tl }
}
% \end{macrocode}
@@ -12441,11 +12589,11 @@ version 2005/12/01 or later.
% in a list of options (that's why we have put diredtly |\l_@@_xdots_color_tl|).
%
% \smallskip
-% The argument of |\@@_draw_non_standard_dotted_line:n| is, in fact, the list of options.
+% The argument of |\@@_draw_unstandard_dotted_line:n| is, in fact, the list of options.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_draw_non_standard_dotted_line:n #1
+\cs_new_protected:Npn \@@_draw_unstandard_dotted_line:n #1
{
- \@@_draw_non_standard_dotted_line:nVV
+ \@@_draw_unstandard_dotted_line:nVV
{ #1 }
\l_@@_xdots_up_tl
\l_@@_xdots_down_tl
@@ -12453,7 +12601,7 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new_protected:Npn \@@_draw_non_standard_dotted_line:nnn #1 #2 #3
+\cs_new_protected:Npn \@@_draw_unstandard_dotted_line:nnn #1 #2 #3
{
\draw
[
@@ -12472,7 +12620,7 @@ version 2005/12/01 or later.
( \l_@@_x_final_dim , \l_@@_y_final_dim ) ;
\end { scope }
}
-\cs_generate_variant:Nn \@@_draw_non_standard_dotted_line:nnn { n V V }
+\cs_generate_variant:Nn \@@_draw_unstandard_dotted_line:nnn { n V V }
% \end{macrocode}
%
% \bigskip
@@ -13848,7 +13996,7 @@ version 2005/12/01 or later.
% \smallskip
% The command |\@@_OnlyMainNiceMatrix_i:n| is only a short-cut which is used
% twice in the above command. This command must \emph{not} be protected.
-% % \begin{macrocode}
+% \begin{macrocode}
\cs_new_protected:Npn \@@_OnlyMainNiceMatrix_i:n #1
{
\int_compare:nNnF \c@iRow = 0
@@ -13864,8 +14012,8 @@ version 2005/12/01 or later.
% The following command will be executed in the |internal-code-after|. The rule
% will be drawn \emph{before} the column |#1| (that is to say on the left side).
% |#2| is the number of consecutive occurrences of \verb+|+. |#3| and |#4| are
-% numbers of rows that define the delimitation of the horizontal rule that we
-% have to draw. If |#4| is empty, that means that the rule extends until the
+% the numbers of rows that define the delimitation of the horizontal rule that
+% we have to draw. If |#4| is empty, that means that the rule extends until the
% last row.
% \begin{macrocode}
\cs_new_protected:Npn \@@_vline:nnnn #1 #2 #3 #4
@@ -13974,7 +14122,7 @@ version 2005/12/01 or later.
}
}
% \end{macrocode}
-%
+%
% \bigskip
% |#1| is the number of the column; |#2| is the number of vertical rules to
% draw (with potentially a color between); |#3| and |#4| are the numbers of the
@@ -13982,6 +14130,22 @@ version 2005/12/01 or later.
% \begin{macrocode}
\cs_new_protected:Npn \@@_vline_ii:nnnn #1 #2 #3 #4
{
+ \bool_if:NTF \l_@@_dotted_bool
+ { \@@_vline_iv:nnn { #1 } { #3 } { #4 } }
+ { \@@_vline_iii:nnnn { #1 } { #2 } { #3 } { #4 } }
+ }
+% \end{macrocode}
+%
+% \bigskip
+% The following code is for the standard case (the rule which is drawn is a
+% solid rule).
+%
+% |#1| is the number of the column; |#2| is the number of vertical rules to
+% draw (with potentially a color between); |#3| and |#4| are the numbers of the
+% rows between which the rule has to be drawn.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_vline_iii:nnnn #1 #2 #3 #4
+ {
\pgfrememberpicturepositiononpagetrue
\pgf@relevantforpicturesizefalse
\@@_qpoint:n { row - #3 }
@@ -13993,7 +14157,7 @@ version 2005/12/01 or later.
\bool_lazy_all:nT
{
{ \int_compare_p:nNn { #2 } > 1 }
- { \cs_if_exist_p:N \CT@drsc@ } % condition added in version 5.18a
+ { \cs_if_exist_p:N \CT@drsc@ }
{ ! \tl_if_blank_p:V \CT@drsc@ }
}
{
@@ -14025,16 +14189,29 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
+%
% \bigskip
-% The following command draws a complete vertical rule in the column |#1| (|#2|
-% is the number of consecutive rules specified by the number of \verb+|+ in the
-% preamble). This command will be used if there is no block in the array (and
-% the key |corners| is not used).
+% The following code is for the case of a dotted rule (with our system).
+%
+% |#1| is the number of the column; |#2| and |#3| are the numbers of the
+% rows between which the rule has to be drawn.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_vline_i_complete:nn #1 #2
- { \@@_vline_ii:nnnn { #1 } { #2 } 1 { \int_use:N \c@iRow } }
+\cs_new_protected:Npn \@@_vline_iv:nnn #1 #2 #3
+ {
+ \pgfrememberpicturepositiononpagetrue
+ \pgf@relevantforpicturesizefalse
+ \@@_qpoint:n { col - #1 }
+ \dim_set_eq:NN \l_@@_x_initial_dim \pgf@x
+ \dim_set_eq:NN \l_@@_x_final_dim \pgf@x
+ \@@_qpoint:n { row - #2 }
+ \dim_set_eq:NN \l_@@_y_initial_dim \pgf@y
+ \@@_qpoint:n { row - \@@_succ:n { #3 } }
+ \dim_set_eq:NN \l_@@_y_final_dim \pgf@y
+ \@@_draw_line:
+ }
% \end{macrocode}
%
+%
% \bigskip
% 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
@@ -14169,13 +14346,23 @@ version 2005/12/01 or later.
}
}
% \end{macrocode}
-%
+%
+% \bigskip
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_hline_ii:nnnn #1 #2 #3 #4
+ {
+ \bool_if:NTF \l_@@_dotted_bool
+ { \@@_hline_iv:nnn { #1 } { #3 } { #4 } }
+ { \@@_hline_iii:nnnn { #1 } { #2 } { #3 } { #4 } }
+ }
+% \end{macrocode}
+%
% \bigskip
% |#1| is the number of the row; |#2| is the number of horizontal rules to
% draw (with potentially a color between); |#3| and |#4| are the number of the
% columns between which the rule has to be drawn.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_hline_ii:nnnn #1 #2 #3 #4
+\cs_new_protected:Npn \@@_hline_iii:nnnn #1 #2 #3 #4
{
\pgfrememberpicturepositiononpagetrue
\pgf@relevantforpicturesizefalse
@@ -14188,7 +14375,7 @@ version 2005/12/01 or later.
\bool_lazy_all:nT
{
{ \int_compare_p:nNn { #2 } > 1 }
- { \cs_if_exist_p:N \CT@drsc@ } % condition added in version 6.0
+ { \cs_if_exist_p:N \CT@drsc@ }
{ ! \tl_if_blank_p:V \CT@drsc@ }
}
{
@@ -14219,14 +14406,92 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
+% The following code is for the case of a dotted rule (with our system of
+% rounded dots).
+% The aim is that, by standard the dotted line fits between square brackets
+% (|\hline| doesn't).
+%
+% \smallskip
+% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
+% \begin{bNiceMatrix}
+% 1 & 2 & 3 & 4 \\
+% \hline
+% 1 & 2 & 3 & 4 \\
+% \hdottedline
+% 1 & 2 & 3 & 4
+% \end{bNiceMatrix}
+% \end{BVerbatim}
+% $\begin{bNiceMatrix}
+% 1 & 2 & 3 & 4 \\
+% \hline
+% 1 & 2 & 3 & 4 \\
+% \hdottedline
+% 1 & 2 & 3 & 4
+% \end{bNiceMatrix}$
+%
+% \smallskip
+% But, if the user uses |margin|, the dotted line extends to have the same width
+% as a |\hline|.
+%
+% \smallskip
+% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
+% \begin{bNiceMatrix}[margin]
+% 1 & 2 & 3 & 4 \\
+% \hline
+% 1 & 2 & 3 & 4 \\
+% \hdottedline
+% 1 & 2 & 3 & 4
+% \end{bNiceMatrix}
+% \end{BVerbatim}
+% $\begin{bNiceMatrix}[margin]
+% 1 & 2 & 3 & 4 \\
+% \hline
+% 1 & 2 & 3 & 4 \\
+% \hdottedline
+% 1 & 2 & 3 & 4
+% \end{bNiceMatrix}$
+%
% \begin{macrocode}
-\cs_new_protected:Npn \@@_hline_i_complete:nn #1 #2
- { \@@_hline_ii:nnnn { #1 } { #2 } 1 { \int_use:N \c@jCol } }
+\cs_new_protected:Npn \@@_hline_iv:nnn #1 #2 #3
+ {
+ \pgfrememberpicturepositiononpagetrue
+ \pgf@relevantforpicturesizefalse
+ \@@_qpoint:n { row - #1 }
+ \dim_set_eq:NN \l_@@_y_initial_dim \pgf@y
+ \dim_set_eq:NN \l_@@_y_final_dim \pgf@y
+ \@@_qpoint:n { col - #2 }
+ \dim_set_eq:NN \l_@@_x_initial_dim \pgf@x
+ \int_compare:nNnT { #2 } = 1
+ {
+ \dim_sub:Nn \l_@@_x_initial_dim \l_@@_left_margin_dim
+ \bool_if:NT \l_@@_NiceArray_bool
+ { \dim_sub:Nn \l_@@_x_initial_dim \arraycolsep }
% \end{macrocode}
-%
+% For reasons purely aesthetic, we do an adjustment in the case of a rounded
+% bracket. The correction by |0.5 \l_@@_inter_dots_dim| is \emph{ad hoc} for a
+% better result.
+% \begin{macrocode}
+ \tl_if_eq:NnF \g_@@_left_delim_tl (
+ { \dim_add:Nn \l_@@_x_initial_dim { 0.5 \l_@@_inter_dots_dim } }
+ }
+ \@@_qpoint:n { col - \@@_succ:n { #3 } }
+ \dim_set_eq:NN \l_@@_x_final_dim \pgf@x
+ \int_compare:nNnT { #3 } = \c@jCol
+ {
+ \dim_add:Nn \l_@@_x_final_dim \l_@@_right_margin_dim
+ \bool_if:NT \l_@@_NiceArray_bool
+ { \dim_add:Nn \l_@@_x_final_dim \arraycolsep }
+ \tl_if_eq:NnF \g_@@_right_delim_tl )
+ { \dim_gsub:Nn \l_@@_x_final_dim { 0.5 \l_@@_inter_dots_dim } }
+ }
+ \@@_draw_line:
+ }
+% \end{macrocode}
+%
+%
% \bigskip
% The command |\@@_draw_hlines:| draws all the horizontal rules excepted in the
-% blocks (even the virtual drawn determined by commands such as |\Cdots| and in
+% blocks (even the virtual blocks determined by commands such as |\Cdots| and in
% the corners (if the key |corners| is used).
% \begin{macrocode}
\cs_new_protected:Npn \@@_draw_hlines:
@@ -14578,129 +14843,12 @@ version 2005/12/01 or later.
% that will actually draw the dotted line. Its argument is the number of the row
% \emph{before} which we will draw the row.
% \begin{macrocode}
-\AtBeginDocument
- {
-% \end{macrocode}
-% We recall that, when externalization is used, |\tikzpicture| and
-% |\endtikzpicture| (or |\pgfpicture| and |\endpgfpicture|) must be directly
-% ``visible''. That's why we construct now a version of |\@@_hdottedline:n| with
-% the right environment (|\begin{pgfpicture}\end{pgfpicture}| or
-% |\begin{tikzpiture}...\end{tikzpicture}|).
-% \begin{macrocode}
- \cs_new_protected:Npx \@@_hdottedline:n #1
- {
- \bool_set_true:N \exp_not:N \l_@@_initial_open_bool
- \bool_set_true:N \exp_not:N \l_@@_final_open_bool
- \c_@@_pgfortikzpicture_tl
- \@@_hdottedline_i:n { #1 }
- \c_@@_endpgfortikzpicture_tl
- }
- }
-% \end{macrocode}
-%
-% The following command \emph{must} be protected since it is used in the
-% construction of |\@@_hdottedline:n|.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_hdottedline_i:n #1
+\cs_new_protected:Npn \@@_hdottedline:n #1
{
- \pgfrememberpicturepositiononpagetrue
- \@@_qpoint:n { row - #1 }
-% \end{macrocode}
-% We do a translation par |-\l_@@_radius_dim| because we want the dotted line to
-% have exactly the same position as a vertical rule drawn by ``"|"''
-% (considering the rule having a width equal to the diameter of the dots).
-% \begin{macrocode}
- \dim_set_eq:NN \l_@@_y_initial_dim \pgf@y
- \dim_sub:Nn \l_@@_y_initial_dim \l_@@_radius_dim
- \dim_set_eq:NN \l_@@_y_final_dim \l_@@_y_initial_dim
-% \end{macrocode}
-%
-% \medskip
-% The dotted line will be extended if the user uses |margin| (or |left-margin|
-% and |right-margin|).
-%
-% \smallskip
-% The aim is that, by standard the dotted line fits between square brackets
-% (|\hline| doesn't).
-%
-% \smallskip
-% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
-% \begin{bNiceMatrix}
-% 1 & 2 & 3 & 4 \\
-% \hline
-% 1 & 2 & 3 & 4 \\
-% \hdottedline
-% 1 & 2 & 3 & 4
-% \end{bNiceMatrix}
-% \end{BVerbatim}
-% $\begin{bNiceMatrix}
-% 1 & 2 & 3 & 4 \\
-% \hline
-% 1 & 2 & 3 & 4 \\
-% \hdottedline
-% 1 & 2 & 3 & 4
-% \end{bNiceMatrix}$
-%
-% \smallskip
-% But, if the user uses |margin|, the dotted line extends to have the same width
-% as a |\hline|.
-%
-% \smallskip
-% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
-% \begin{bNiceMatrix}[margin]
-% 1 & 2 & 3 & 4 \\
-% \hline
-% 1 & 2 & 3 & 4 \\
-% \hdottedline
-% 1 & 2 & 3 & 4
-% \end{bNiceMatrix}
-% \end{BVerbatim}
-% $\begin{bNiceMatrix}[margin]
-% 1 & 2 & 3 & 4 \\
-% \hline
-% 1 & 2 & 3 & 4 \\
-% \hdottedline
-% 1 & 2 & 3 & 4
-% \end{bNiceMatrix}$
-%
-% \medskip
-% \begin{macrocode}
- \@@_qpoint:n { col - 1 }
- \dim_set:Nn \l_@@_x_initial_dim
- {
- \pgf@x +
-% \end{macrocode}
-% We do a reduction by |\arraycolsep| for the environments with delimiters (and
-% not for the other).
-% \begin{macrocode}
- \bool_if:NTF \l_@@_NiceArray_bool \c_zero_dim \arraycolsep
- - \l_@@_left_margin_dim
- }
- \@@_qpoint:n { col - \@@_succ:n \c@jCol }
- \dim_set:Nn \l_@@_x_final_dim
- {
- \pgf@x -
- \bool_if:NTF \l_@@_NiceArray_bool \c_zero_dim \arraycolsep
- + \l_@@_right_margin_dim
- }
-% \end{macrocode}
-% For reasons purely aesthetic, we do an adjustment in the case of a rounded
-% bracket. The correction by |0.5 \l_@@_inter_dots_dim| is \emph{ad hoc} for a
-% better result.
-% \begin{macrocode}
- \tl_if_eq:NnF \g_@@_left_delim_tl (
- { \dim_gadd:Nn \l_@@_x_initial_dim { 0.5 \l_@@_inter_dots_dim } }
- \tl_if_eq:NnF \g_@@_right_delim_tl )
- { \dim_gsub:Nn \l_@@_x_final_dim { 0.5 \l_@@_inter_dots_dim } }
-% \end{macrocode}
-%
-% \medskip
-% Up to now, we have no option to control the style of the lines drawn by
-% |\hdottedline| and the specifier ``|:|'' in the preamble. That's why we impose
-% the style |standard|.
-% \begin{macrocode}
- \tl_set_eq:NN \l_@@_xdots_line_style_tl \c_@@_standard_tl
- \@@_draw_line:
+ \group_begin:
+ \bool_set_true:N \l_@@_dotted_bool
+ \@@_hline:nnnn { #1 } { 1 } { 1 } { \int_use:N \c@jCol }
+ \group_end:
}
% \end{macrocode}
%
@@ -14713,66 +14861,13 @@ version 2005/12/01 or later.
% \begin{macrocode}
\cs_new_protected:Npn \@@_vdottedline:n #1
{
- \bool_set_true:N \l_@@_initial_open_bool
- \bool_set_true:N \l_@@_final_open_bool
-% \end{macrocode}
-% We recall that, when externalization is used, |\tikzpicture| and
-% |\endtikzpicture| (or |\pgfpicture| and |\endpgfpicture|) must be directly
-% ``visible''.
-% \begin{macrocode}
- \bool_if:NTF \c_@@_tikz_loaded_bool
- {
- \tikzpicture
- \@@_vdottedline_i:n { #1 }
- \endtikzpicture
- }
- {
- \pgfpicture
- \@@_vdottedline_i:n { #1 }
- \endpgfpicture
- }
- }
-% \end{macrocode}
-%
-% \medskip
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_vdottedline_i:n #1
- {
-% \end{macrocode}
-% The command |\CT@arc@| is a command of \pkg{colortbl} which sets the color of
-% the rules in the array. The package \pkg{nicematrix} uses it even if \pkg{colortbl} is not
-% loaded.
-% \begin{macrocode}
- \CT@arc@
- \pgfrememberpicturepositiononpagetrue
- \@@_qpoint:n { col - \int_eval:n { #1 + 1 } }
-% \end{macrocode}
-% We do a translation par |-\l_@@_radius_dim| because we want the dotted line to
-% have exactly the same position as a vertical rule drawn by ``"|"''
-% (considering the rule having a width equal to the diameter of the dots).
-% \begin{macrocode}
- \dim_set:Nn \l_@@_x_initial_dim { \pgf@x - \l_@@_radius_dim }
- \dim_set:Nn \l_@@_x_final_dim { \pgf@x - \l_@@_radius_dim }
- \@@_qpoint:n { row - 1 }
-% \end{macrocode}
-% We arbitrary decrease the height of the dotted line by a quantity equal to
-% |\l_@@_inter_dots_dim| in order to improve the visual impact.
-% \begin{macrocode}
- \dim_set:Nn \l_@@_y_initial_dim { \pgf@y - 0.5 \l_@@_inter_dots_dim }
- \@@_qpoint:n { row - \@@_succ:n \c@iRow }
- \dim_set:Nn \l_@@_y_final_dim { \pgf@y + 0.5 \l_@@_inter_dots_dim }
-% \end{macrocode}
-% Up to now, we have no option to control the style of the lines drawn by
-% |\hdottedline| and the specifier ``|:|'' in the preamble. That's why we impose
-% the style |standard|.
-% \begin{macrocode}
- \tl_set_eq:NN \l_@@_xdots_line_style_tl \c_@@_standard_tl
- \@@_draw_line:
+ \group_begin:
+ \bool_set_true:N \l_@@_dotted_bool
+ \@@_vline:nnnn { \int_eval:n { #1 + 1 } } { 1 } { 1 } { \int_use:N \c@iRow }
+ \group_end:
}
% \end{macrocode}
%
-%
-%
% \bigskip
% \subsection*{The environment \{NiceMatrixBlock\}}
%
@@ -15233,7 +15328,7 @@ version 2005/12/01 or later.
% |<| and |>|. It's mandatory to use an expandable command.
%
% \begin{macrocode}
-\NewExpandableDocumentCommand \@@_Block: { O { } m D < > { } m }
+\NewExpandableDocumentCommand \@@_Block: { O { } m D < > { } +m }
{
% \end{macrocode}
% If the first mandatory argument of the command (which is the size of the block
@@ -15399,7 +15494,7 @@ version 2005/12/01 or later.
\int_compare:nNnT { #1 } = 1 \g_@@_row_style_tl
\group_begin:
\cs_set:Npn \arraystretch { 1 }
- \dim_set_eq:NN \extrarowheight \c_zero_dim
+ \dim_zero:N \extrarowheight
#4
% \end{macrocode}
% If the box is rotated (the key |\rotate| may be in the previous |#4|), the
@@ -15419,7 +15514,7 @@ version 2005/12/01 or later.
% When the block is mono-column in a column with a fixed width (eg |p{3cm}|).
% \begin{macrocode}
{
- \begin { minipage } [ l_@@_vpos_of_block_tl ]
+ \begin { minipage } [ \l_@@_vpos_of_block_tl ]
{ \l_@@_col_width_dim }
\str_case:Vn \l_@@_hpos_block_str
{
@@ -15539,7 +15634,7 @@ version 2005/12/01 or later.
{
\group_begin:
\cs_set:Npn \arraystretch { 1 }
- \dim_set_eq:NN \extrarowheight \c_zero_dim
+ \dim_zero:N \extrarowheight
#4
% \end{macrocode}
% If the box is rotated (the key |\rotate| may be in the previous |#4|), the
@@ -15563,7 +15658,7 @@ version 2005/12/01 or later.
{
\group_begin:
\cs_set:Npn \arraystretch { 1 }
- \dim_set_eq:NN \extrarowheight \c_zero_dim
+ \dim_zero:N \extrarowheight
#4
\bool_if:NT \g_@@_rotate_bool
{ \str_set:Nn \l_@@_hpos_block_str c }
@@ -16949,7 +17044,7 @@ version 2005/12/01 or later.
\l_@@_y_initial_dim - \l_@@_y_final_dim +
\l_@@_submatrix_extra_height_dim - \arrayrulewidth
}
- \dim_set_eq:NN \nulldelimiterspace \c_zero_dim
+ \dim_zero:N \nulldelimiterspace
% \end{macrocode}
%
% \bigskip