summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/nicematrix/nicematrix-code.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/nicematrix/nicematrix-code.dtx')
-rw-r--r--macros/latex/contrib/nicematrix/nicematrix-code.dtx1218
1 files changed, 827 insertions, 391 deletions
diff --git a/macros/latex/contrib/nicematrix/nicematrix-code.dtx b/macros/latex/contrib/nicematrix/nicematrix-code.dtx
index 7f7920ec77..39677ce108 100644
--- a/macros/latex/contrib/nicematrix/nicematrix-code.dtx
+++ b/macros/latex/contrib/nicematrix/nicematrix-code.dtx
@@ -17,8 +17,8 @@
%
% \fi
% \iffalse
-\def\myfileversion{6.21a}
-\def\myfiledate{2023/07/17}
+\def\myfileversion{6.22}
+\def\myfiledate{2023/08/14}
%
%
%<*batchfile>
@@ -181,7 +181,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\cs_new_protected:Npn \@@_msg_new:nnn #1 #2 #3
{
- \bool_if:NTF \c_@@_messages_for_Overleaf_bool
+ \bool_if:NTF \g_@@_messages_for_Overleaf_bool
{ \msg_new:nnn { nicematrix } { #1 } { #2 \\ #3 } }
{ \msg_new:nnnn { nicematrix } { #1 } { #2 } { #3 } }
}
@@ -192,14 +192,15 @@ version 2005/12/01 or later.
% warning on Overleaf. The argument is given by curryfication.
% \begin{macrocode}
\cs_new_protected:Npn \@@_error_or_warning:n
- { \bool_if:NTF \c_@@_messages_for_Overleaf_bool \@@_warning:n \@@_error:n }
+ { \bool_if:NTF \g_@@_messages_for_Overleaf_bool \@@_warning:n \@@_error:n }
% \end{macrocode}
%
% We try to detect whether the compilation is done on Overleaf. We use
% |\c_sys_jobname_str| because, with Overleaf, the value of |\c_sys_jobname_str|
% is always ``|output|''.
% \begin{macrocode}
-\bool_set:Nn \c_@@_messages_for_Overleaf_bool
+\bool_new:N \g_@@_messages_for_Overleaf_bool
+\bool_gset:Nn \g_@@_messages_for_Overleaf_bool
{
\str_if_eq_p:Vn \c_sys_jobname_str { _region_ } % for Emacs
|| \str_if_eq_p:Vn \c_sys_jobname_str { output } % for Overleaf
@@ -296,7 +297,7 @@ version 2005/12/01 or later.
\IfPackageLoadedTF { mdwtab }
{ \@@_fatal:n { mdwtab~loaded } }
{
- \bool_if:NF \c_@@_no_test_for_array_bool
+ \bool_if:NF \g_@@_no_test_for_array_bool
{
\group_begin:
\hbox_set:Nn \l_tmpa_box
@@ -310,10 +311,62 @@ version 2005/12/01 or later.
}
}
% \end{macrocode}
+%
+% \bigskip
+% \section{Collecting options}
+%
+% The following technic allows to create user commands with the ability to put
+% an arbitrary number of |[|\textsl{list of (key=val)}|]| after the name of the
+% command.
+%
+% \medskip
+% \emph{Exemple} :\par\nobreak
+%
+% |\@@_collect_options:n { \F } [x=a,y=b] [z=c,t=d] { arg }|
+%
+% will be transformed in :\quad |\F{x=a,y=b,z=c,t=d}{arg}|
+%
+% \smallskip
+% Therefore, by writing : |\def\G{\@@_collect_options:n{\F}}|,
+%
+% the command |\G| takes in an arbitrary number of optional arguments between
+% square brackets.
+%
+% \bigskip
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_collect_options:n #1
+ {
+ \peek_meaning:NTF [
+ { \@@_collect_options:nw { #1 } }
+ { #1 { } }
+ }
+% \end{macrocode}
+%
+% \bigskip
+% We use |\NewDocumentCommand| in order to be able to allow nested brackets
+% within the argument between |[| and |]|.
+% \begin{macrocode}
+\NewDocumentCommand \@@_collect_options:nw { m r[] }
+ { \@@_collect_options:nn { #1 } { #2 } }
+
+\cs_new_protected:Npn \@@_collect_options:nn #1 #2
+ {
+ \peek_meaning:NTF [
+ { \@@_collect_options:nnw { #1 } { #2 } }
+ { #1 { #2 } }
+ }
+
+\cs_new_protected:Npn \@@_collect_options:nnw #1#2[#3]
+ { \@@_collect_options:nn { #1 } { #2 , #3 } }
+% \end{macrocode}
+%
%
% \bigskip
% \section{Technical definitions}
%
+% The following token list will be used for definitions of user commands (with
+% |\NewDocumentCommand|) with an embellishment using an \emph{underscore} (there
+% may be problems because of the catcode of the underscore).
% \begin{macrocode}
\tl_new:N \l_@@_argspec_tl
% \end{macrocode}
@@ -942,6 +995,27 @@ version 2005/12/01 or later.
% \begin{macrocode}
\tl_new:N \g_@@_aux_tl
% \end{macrocode}
+%
+% During the second run, if informations concerning the current environment has
+% been found in the |aux| file, the following flag will be raised.
+% \begin{macrocode}
+\bool_new:N \g_@@_aux_found_bool
+% \end{macrocode}
+%
+% \bigskip
+% In particuler, in that |aux| file, there will, for each environment of
+% \pkg{nicematrix}, an affectation for the the following sequence that will
+% contain informations about the size of the array.
+% \begin{macrocode}
+\seq_new:N \g_@@_size_seq
+% \end{macrocode}
+%
+% \bigskip
+% \begin{macrocode}
+\tl_new:N \g_@@_left_delim_tl
+\tl_new:N \g_@@_right_delim_tl
+\tl_new:N \g_@@_preamble_tl
+% \end{macrocode}
%
% \bigskip
% The following parameter corresponds to the key |columns-type| of the
@@ -956,6 +1030,16 @@ version 2005/12/01 or later.
\hook_gput_code:nnn { begindocument } { . }
{ \@@_set_preamble:Nn \l_@@_columns_type_tl { c } }
% \end{macrocode}
+%
+% \bigskip
+% The following parameters correspond to the keys |down|, |up| and |middle| of a
+% command such as |\Cdots|. Usually, the final user doesn't use that keys
+% directly because he uses the syntax with the embellishments |_|, |^| and |:|.
+% \begin{macrocode}
+\tl_new:N \l_@@_xdots_down_tl
+\tl_new:N \l_@@_xdots_up_tl
+\tl_new:N \l_@@_xdots_middle_tl
+% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
@@ -1316,10 +1400,11 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \medskip
-% The following parameters correspond to the keys |fill|, |draw|, |tikz|, |borders|,
-% and |rounded-corners| of the command |\Block|.
+% The following parameters correspond to the keys |fill|, |opacity|, |draw|,
+% |tikz|, |borders|, and |rounded-corners| of the command |\Block|.
% \begin{macrocode}
\tl_new:N \l_@@_fill_tl
+\tl_new:N \l_@@_opacity_tl
\tl_new:N \l_@@_draw_tl
\seq_new:N \l_@@_tikz_seq
\clist_new:N \l_@@_borders_clist
@@ -1414,7 +1499,6 @@ version 2005/12/01 or later.
% \begin{macrocode}
\bool_new:N \l_@@_hvlines_bool
% \end{macrocode}
-%
%
%
% \bigskip
@@ -1569,6 +1653,27 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
+% \bigskip
+% The following internal parameters are for:
+% \begin{itemize}
+% \item |\Ldots| \emph{with both extremities open} (and hence also |\Hdotsfor| in an
+% exterior row;
+% \item |\Vdots| \emph{with both extremities open} (and hence also |\Vdotsfor| in an
+% exterior column;
+% \item when the special character ``|:|'' is used in order to put the label of
+% a so-called ``dotted line'' \emph{on the line}, a margin of
+% |\c_@@_innersep_middle_dim| will be added around the label.
+% \end{itemize}
+%
+% \begin{macrocode}
+\hook_gput_code:nnn { begindocument } { . }
+ {
+ \dim_const:Nn \c_@@_shift_Ldots_last_row_dim { 0.5 em }
+ \dim_const:Nn \c_@@_shift_exterior_Vdots_dim { 0.6 em }
+ \dim_const:Nn \c_@@_innersep_middle_dim { 0.17 em }
+ }
+% \end{macrocode}
+%
%
% \bigskip
% \section{The command \textbackslash tabularnote}
@@ -1937,7 +2042,6 @@ version 2005/12/01 or later.
\begin { pgfscope }
\pgfset
{
- % outer~sep = \c_zero_dim ,
inner~sep = \c_zero_dim ,
minimum~size = \c_zero_dim
}
@@ -1969,7 +2073,6 @@ version 2005/12/01 or later.
\begin { pgfscope }
\pgfset
{
- % outer~sep = \c_zero_dim ,
inner~sep = \c_zero_dim ,
minimum~size = \c_zero_dim
}
@@ -2051,14 +2154,13 @@ version 2005/12/01 or later.
\hook_gput_code:nnn { begindocument } { . }
{ \dim_set:Nn \l_@@_xdots_inter_dim { 0.45 em } }
% \end{macrocode}
-% We use a hook only by security in case \cls{revtex4-1}
-% is used (even though it is obsolete).
+% The unit is |em| and that's why we fix the dimension after the preamble.
%
% \bigskip
-% The following dimension is the minimal distance between a node (in fact an
-% anchor of that node) and a dotted line (we say ``minimal'' because, by
-% definition, a dotted line is not a continuous line and, therefore, this
-% distance may vary a little).
+% The following dimension is the distance between a node (in fact an
+% anchor of that node) and a dotted line (for real dotted lines, the actual
+% distance may, of course, be a bit larger, depending of the exact position of
+% the dots).
% \begin{macrocode}
\dim_new:N \l_@@_xdots_shorten_start_dim
\dim_new:N \l_@@_xdots_shorten_end_dim
@@ -2068,8 +2170,7 @@ version 2005/12/01 or later.
\dim_set:Nn \l_@@_xdots_shorten_end_dim { 0.3 em }
}
% \end{macrocode}
-% We use a hook only by security in case \cls{revtex4-1} is used (even though it
-% is obsolete).
+% The unit is |em| and that's why we fix the dimension after the preamble.
%
% \bigskip
% The following dimension is the radius of the dots for the dotted lines (when
@@ -2080,8 +2181,7 @@ version 2005/12/01 or later.
\hook_gput_code:nnn { begindocument } { . }
{ \dim_set:Nn \l_@@_xdots_radius_dim { 0.53 pt } }
% \end{macrocode}
-% We use a hook only by security in case \cls{revtex4-1} is used (even though it
-% is obsolete).
+% The unit is |em| and that's why we fix the dimension after the preamble.
%
%
% \bigskip
@@ -2130,7 +2230,7 @@ version 2005/12/01 or later.
%
% \bigskip
% The following parameter correspond to the key |corners|. The elements of that
-% |clist| must be in |NW|, |SW|, |NE| and |SE|.
+% |clist| must be within |NW|, |SW|, |NE| and |SE|.
% \begin{macrocode}
\clist_new:N \l_@@_corners_clist
% \end{macrocode}
@@ -2262,8 +2362,25 @@ version 2005/12/01 or later.
%
% \bigskip
% \begin{macrocode}
+% \bigskip
+% \begin{macrocode}
\keys_define:nn { NiceMatrix / xdots }
{
+ shorten-start .code:n =
+ \hook_gput_code:nnn { begindocument } { . }
+ { \dim_set:Nn \l_@@_xdots_shorten_start_dim { #1 } } ,
+ shorten-end .code:n =
+ \hook_gput_code:nnn { begindocument } { . }
+ { \dim_set:Nn \l_@@_xdots_shorten_end_dim { #1 } } ,
+ shorten-start .value_required:n = true ,
+ shorten-end .value_required:n = true ,
+ shorten .code:n =
+ \hook_gput_code:nnn { begindocument } { . }
+ {
+ \dim_set:Nn \l_@@_xdots_shorten_start_dim { #1 }
+ \dim_set:Nn \l_@@_xdots_shorten_end_dim { #1 }
+ } ,
+ shorten .value_required:n = true ,
horizontal-labels .bool_set:N = \l_@@_xdots_h_labels_bool ,
horizontal-labels .default:n = true ,
line-style .code:n =
@@ -2277,25 +2394,6 @@ version 2005/12/01 or later.
line-style .value_required:n = true ,
color .tl_set:N = \l_@@_xdots_color_tl ,
color .value_required:n = true ,
- shorten .code:n =
- \hook_gput_code:nnn { begindocument } { . }
- {
- \dim_set:Nn \l_@@_xdots_shorten_start_dim { #1 }
- \dim_set:Nn \l_@@_xdots_shorten_end_dim { #1 }
- } ,
- shorten-start .code:n =
- \hook_gput_code:nnn { begindocument } { . }
- { \dim_set:Nn \l_@@_xdots_shorten_start_dim { #1 } } ,
- shorten-end .code:n =
- \hook_gput_code:nnn { begindocument } { . }
- { \dim_set:Nn \l_@@_xdots_shorten_end_dim { #1 } } ,
-% \end{macrocode}
-% We use a hook only by security in case \cls{revtex4-1}
-% is used (even though it is obsolete). Idem for the following keys.
-% \begin{macrocode}
- shorten .value_required:n = true ,
- shorten-start .value_required:n = true ,
- shorten-end .value_required:n = true ,
radius .code:n =
\hook_gput_code:nnn { begindocument } { . }
{ \dim_set:Nn \l_@@_xdots_radius_dim { #1 } } ,
@@ -2305,14 +2403,17 @@ version 2005/12/01 or later.
{ \dim_set:Nn \l_@@_xdots_inter_dim { #1 } } ,
radius .value_required:n = true ,
% \end{macrocode}
-% The options |down| and |up| are not documented for the final user because he
-% should use the syntax with |^| and |_|.
+% The options |down|, |up| and |middle| are not documented for the final user
+% because he should use the syntax with |^|, |_| and |:|. We use
+% |\tl_put_right:Nn| and not |\tl_set:Nn| (or |.tl_set:N|) because we don't want
+% a direct use of |up=...| erased by a absent |^{...}|.
% \begin{macrocode}
- down .tl_set:N = \l_@@_xdots_down_tl ,
- up .tl_set:N = \l_@@_xdots_up_tl ,
+ down .code:n = \tl_put_right:Nn \l_@@_xdots_down_tl { #1 } , % modified 2023-08-09
+ up .code:n = \tl_put_right:Nn \l_@@_xdots_up_tl { #1 } ,
+ middle .code:n = \tl_put_right:Nn \l_@@_xdots_middle_tl { #1 } ,
% \end{macrocode}
% The key |draw-first|, which is meant to be used only with |\Ddots| and
-% |\Iddots|, which be catched when |\Ddots| or |\Iddots| is used (during the
+% |\Iddots|, will be catched when |\Ddots| or |\Iddots| is used (during the
% construction of the array and not when we draw the dotted lines).
% \begin{macrocode}
draw-first .code:n = \prg_do_nothing: ,
@@ -2787,6 +2888,7 @@ version 2005/12/01 or later.
unknown .code:n = \@@_error:n { Unknown~key~for~NiceTabular }
}
% \end{macrocode}
+%
%
% \bigskip
% \section{Important code used by \{NiceArrayWithDelims\} }
@@ -2812,9 +2914,9 @@ version 2005/12/01 or later.
% \begin{macrocode}
\cs_set_eq:NN \CodeAfter \@@_CodeAfter_i:
% \end{macrocode}
-% We increment |\c@jCol|, which is the counter of the columns.
+% We increment the LaTeX counter |jCol|, which is the counter of the columns.
% \begin{macrocode}
- \int_gincr:N \c@jCol
+ \int_gincr:N \c@jCol
% \end{macrocode}
% Now, we increment the counter of the rows. We don't do this incrementation in
% the |\everycr| because some packages, like \pkg{arydshln}, create special rows
@@ -3225,9 +3327,9 @@ version 2005/12/01 or later.
% \begin{macrocode}
\cs_new_protected:Npn \@@_array:n
{
- \bool_if:NTF \l_@@_tabular_bool
- { \dim_set_eq:NN \col@sep \tabcolsep }
- { \dim_set_eq:NN \col@sep \arraycolsep }
+ % modified 05-08-23
+ \dim_set:Nn \col@sep
+ { \bool_if:NTF \l_@@_tabular_bool \tabcolsep \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 } }
@@ -3240,7 +3342,7 @@ version 2005/12/01 or later.
% |\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
% right translation will be done further. Remark that |\str_if_eq:VnTF| is
-% fully expandable and you need something fully expandable here.
+% fully expandable and we need something fully expandable here.
% \begin{macrocode}
[ \str_if_eq:VnTF \l_@@_baseline_tl c c t ]
}
@@ -3740,7 +3842,6 @@ version 2005/12/01 or later.
\box_clear_new:N \l_@@_the_array_box
% \end{macrocode}
%
-%
% \medskip
% We compute the width of both delimiters. We remind that, when the
% environment |{NiceArray}| is used, it's possible to specify the delimiters in
@@ -3759,8 +3860,10 @@ version 2005/12/01 or later.
\dim_set:Nn \l_@@_right_delim_dim { \box_wd:N \l_tmpa_box }
}
{
- \dim_gset:Nn \l_@@_left_delim_dim { 2 \arraycolsep }
- \dim_gset:Nn \l_@@_right_delim_dim { 2 \arraycolsep }
+ % modified 05-08-23
+ \dim_gset:Nn \l_@@_left_delim_dim
+ { 2 \bool_if:NTF \l_@@_tabular_bool \tabcolsep \arraycolsep }
+ \dim_gset_eq:NN \l_@@_right_delim_dim \l_@@_left_delim_dim
}
% \end{macrocode}
%
@@ -4111,7 +4214,7 @@ version 2005/12/01 or later.
%
% \begin{macrocode}
\@@_provide_pgfsyspdfmark:
- \bool_if:NT \c_@@_footnote_bool \savenotes
+ \bool_if:NT \g_@@_footnote_bool \savenotes
% \end{macrocode}
%
% The aim of the following |\bgroup| (the corresponding |\egroup| is, of course,
@@ -4130,7 +4233,6 @@ version 2005/12/01 or later.
%
%
% \bigskip
-%
% \begin{macrocode}
\int_gzero:N \g_@@_block_box_int
\dim_zero:N \g_@@_width_last_col_dim
@@ -4199,12 +4301,12 @@ version 2005/12/01 or later.
% We load all the informations written in the |aux| file during previous
% compilations corresponding to the current environment.
% \begin{macrocode}
- \bool_gset_false:N \g_@@_aux_found_bool
- \tl_if_exist:cT { c_@@ _ \int_use:N \g_@@_env_int _ tl }
+ \tl_if_exist:cTF { c_@@ _ \int_use:N \g_@@_env_int _ tl }
{
\bool_gset_true:N \g_@@_aux_found_bool
\use:c { c_@@ _ \int_use:N \g_@@_env_int _ tl }
}
+ { \bool_gset_false:N \g_@@_aux_found_bool }
% \end{macrocode}
% Now, we prepare the token list for the instructions that we will have to write
% on the |aux| file at the end of the environment.
@@ -4358,7 +4460,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\int_compare:nNnT \l_@@_first_col_int = 0
{
- \skip_horizontal:N \col@sep
+ % \skip_horizontal:N \col@sep % 05-08-23
\skip_horizontal:N \g_@@_width_first_col_dim
}
% \end{macrocode}
@@ -4466,7 +4568,7 @@ version 2005/12/01 or later.
\bool_if:NT \g_@@_last_col_found_bool
{
\skip_horizontal:N \g_@@_width_last_col_dim
- \skip_horizontal:N \col@sep
+ % \skip_horizontal:N \col@sep % 2023-08-05
}
\bool_if:NT \l_@@_preamble_bool
{
@@ -4498,7 +4600,7 @@ version 2005/12/01 or later.
%
% \bigskip
% \begin{macrocode}
- \bool_if:NT \c_@@_footnote_bool \endsavenotes
+ \bool_if:NT \g_@@_footnote_bool \endsavenotes
}
% \end{macrocode}
% This is the end of the environment |{NiceArrayWithDelims}|.
@@ -4652,7 +4754,8 @@ version 2005/12/01 or later.
% \begin{macrocode}
\cs_new_protected:Npn \@@_transform_preamble_ii:
{
-%
+% \end{macrocode}
+%
% \medskip
% If there was delimiters at the beginning or at the end of the preamble, the
% environment |{NiceArray}| is transformed into an environment |{xNiceMatrix}|.
@@ -6030,8 +6133,11 @@ version 2005/12/01 or later.
% \begin{macrocode}
\bool_if:NT \l_@@_NiceMatrix_without_vlines_bool
{
- \box_set_wd:Nn \l_@@_the_array_box
- { \box_wd:N \l_@@_the_array_box - \arraycolsep }
+ \int_compare:nNnT \c@jCol > 1 % added 2023-08-13
+ {
+ \box_set_wd:Nn \l_@@_the_array_box
+ { \box_wd:N \l_@@_the_array_box - \arraycolsep }
+ }
}
% \end{macrocode}
% We need a |{minipage}| because we will insert a LaTeX list for the tabular
@@ -7211,6 +7317,9 @@ version 2005/12/01 or later.
% \section{After the construction of the array}
%
% \bigskip
+% The following command will be used when the key |rounded-corners| is in force
+% (this is the key |rounded-corners| for the whole environment and \emph{not}
+% the key |rounded-corners| of a command |\Block|).
% \begin{macrocode}
\cs_new_protected:Npn \@@_deal_with_rounded_corners:
{
@@ -7223,9 +7332,11 @@ version 2005/12/01 or later.
}
{
\bool_set_true:N \l_@@_except_borders_bool
+ \clist_if_empty:NF \l_@@_corners_clist
+ { \@@_error:n { hvlines,~rounded-corners~and~corners } }
\tl_gput_right:Nn \g_@@_pre_code_after_tl
{
- \_@@_stroke_block:nnn
+ \@@_stroke_block:nnn
{
rounded-corners = \dim_use:N \l_@@_tab_rounded_corners_dim ,
draw = \l_@@_rules_color_tl
@@ -7235,6 +7346,7 @@ version 2005/12/01 or later.
}
}
}
+% \end{macrocode}
%
%
% \medskip
@@ -7950,6 +8062,25 @@ version 2005/12/01 or later.
}
}
% \end{macrocode}
+%
+% \medskip
+% If the final user uses the key |xdots/shorten| in |\NiceMatrixOptions| or at the
+% level of an environment (such as |{pNiceMatrix}|, etc.), only the so called
+% ``closed extremities'' will be shortened by that key. The following command
+% will be used \emph{after} the detection of the extremities of a dotted line
+% (hence at a time when we known wheter the extremities are closed or open) but
+% before the analyse of the keys of the individual command |\Cdots|, |\Vdots|.
+% Hence, the keys |shorten|, |shorten-start| and |shorten-end| of that
+% individual command will be applied.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_open_shorten:
+ {
+ \bool_if:NT \l_@@_initial_open_bool
+ { \dim_zero:N \l_@@_xdots_shorten_start_dim }
+ \bool_if:NT \l_@@_final_open_bool
+ { \dim_zero:N \l_@@_xdots_shorten_end_dim }
+ }
+% \end{macrocode}
%
% \medskip
% The following commmand (\emph{when it will be written}) will set the four
@@ -8050,7 +8181,7 @@ version 2005/12/01 or later.
}
}
% \end{macrocode}
-% If, in fact, all the cells of the columns are empty (no PGF/Tikz nodes in
+% If, in fact, all the cells of the column are empty (no PGF/Tikz nodes in
% those cells).
% \begin{macrocode}
\dim_compare:nNnT \l_@@_x_initial_dim = \c_max_dim
@@ -8109,6 +8240,7 @@ version 2005/12/01 or later.
% of the line.
% \begin{macrocode}
\group_begin:
+ \@@_open_shorten:
\int_compare:nNnTF { #1 } = 0
{ \color { nicematrix-first-row } }
{
@@ -8159,12 +8291,30 @@ version 2005/12/01 or later.
}
{ \@@_set_final_coords_from_anchor:n { base~west } }
% \end{macrocode}
+% Now the case of a |\Hdotsfor| (or when there is only a |\Ldots|) in the ``last
+% row'' (that case will probably arise when the final user draws an arrow to
+% indicate the number of columns of the matrix). In the ``first row'', we don't
+% need any adjustment.
+% \begin{macrocode}
+ \bool_lazy_all:nTF
+ {
+ \l_@@_initial_open_bool
+ \l_@@_final_open_bool
+ { \int_compare_p:nNn \l_@@_initial_i_int = \l_@@_last_row_int }
+ }
+ {
+ \dim_add:Nn \l_@@_y_initial_dim \c_@@_shift_Ldots_last_row_dim
+ \dim_add:Nn \l_@@_y_final_dim \c_@@_shift_Ldots_last_row_dim
+ }
+% \end{macrocode}
% We raise the line of a quantity equal to the radius of the dots because we
% want the dots really ``on'' the line of texte. Of course, maybe we should not
% do that when the option |line-style| is used (?).
% \begin{macrocode}
- \dim_add:Nn \l_@@_y_initial_dim \l_@@_xdots_radius_dim
- \dim_add:Nn \l_@@_y_final_dim \l_@@_xdots_radius_dim
+ {
+ \dim_add:Nn \l_@@_y_initial_dim \l_@@_xdots_radius_dim
+ \dim_add:Nn \l_@@_y_final_dim \l_@@_xdots_radius_dim
+ }
\@@_draw_line:
}
% \end{macrocode}
@@ -8185,6 +8335,7 @@ version 2005/12/01 or later.
% of the line.
% \begin{macrocode}
\group_begin:
+ \@@_open_shorten:
\int_compare:nNnTF { #1 } = 0
{ \color { nicematrix-first-row } }
{
@@ -8248,15 +8399,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\cs_new_protected:Npn \@@_open_y_initial_dim:
{
- \@@_qpoint:n { row - \int_use:N \l_@@_initial_i_int - base }
- \dim_set:Nn \l_@@_y_initial_dim
- {
- \fp_to_dim:n
- {
- \pgf@y
- + ( \box_ht:N \strutbox + \extrarowheight ) * \arraystretch
- }
- } % modified 6.13c
+ \dim_set:Nn \l_@@_y_initial_dim { - \c_max_dim }
\int_step_inline:nnn \l_@@_first_col_int \g_@@_col_total_int
{
\cs_if_exist:cT
@@ -8269,6 +8412,19 @@ version 2005/12/01 or later.
{ \dim_max:nn \l_@@_y_initial_dim \pgf@y }
}
}
+ % modified 2023-08-10
+ \dim_compare:nNnT \l_@@_y_initial_dim = { - \c_max_dim }
+ {
+ \@@_qpoint:n { row - \int_use:N \l_@@_initial_i_int - base }
+ \dim_set:Nn \l_@@_y_initial_dim
+ {
+ \fp_to_dim:n
+ {
+ \pgf@y
+ + ( \box_ht:N \strutbox + \extrarowheight ) * \arraystretch
+ }
+ }
+ }
}
% \end{macrocode}
%
@@ -8276,10 +8432,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\cs_new_protected:Npn \@@_open_y_final_dim:
{
- \@@_qpoint:n { row - \int_use:N \l_@@_final_i_int - base }
- \dim_set:Nn \l_@@_y_final_dim
- { \fp_to_dim:n { \pgf@y - ( \box_dp:N \strutbox ) * \arraystretch } }
- % modified 6.13c
+ \dim_set_eq:NN \l_@@_y_final_dim \c_max_dim
\int_step_inline:nnn \l_@@_first_col_int \g_@@_col_total_int
{
\cs_if_exist:cT
@@ -8292,6 +8445,13 @@ version 2005/12/01 or later.
{ \dim_min:nn \l_@@_y_final_dim \pgf@y }
}
}
+ % modified 2023-08-10
+ \dim_compare:nNnT \l_@@_y_final_dim = \c_max_dim
+ {
+ \@@_qpoint:n { row - \int_use:N \l_@@_final_i_int - base }
+ \dim_set:Nn \l_@@_y_final_dim
+ { \fp_to_dim:n { \pgf@y - ( \box_dp:N \strutbox ) * \arraystretch } }
+ }
}
% \end{macrocode}
%
@@ -8310,6 +8470,7 @@ version 2005/12/01 or later.
% of the line.
% \begin{macrocode}
\group_begin:
+ \@@_open_shorten:
\int_compare:nNnTF { #2 } = 0
{ \color { nicematrix-first-col } }
{
@@ -8341,80 +8502,112 @@ version 2005/12/01 or later.
\cs_new_protected:Npn \@@_actually_draw_Vdots:
{
% \end{macrocode}
-% The boolean |\l_tmpa_bool| indicates whether the column is of type |l| or may
-% be considered as if.
-% \begin{macrocode}
- \bool_set_false:N \l_tmpa_bool
+%
+% First, the case of a dotted line open on both sides.
+% \begin{macrocode}
+ \bool_lazy_and:nnTF \l_@@_initial_open_bool \l_@@_final_open_bool
% \end{macrocode}
-% First the case when the line is closed on both ends.
+%
+% We have to determine the $x$-value of the vertical rule that we will have
+% to draw.
% \begin{macrocode}
- \bool_lazy_or:nnF \l_@@_initial_open_bool \l_@@_final_open_bool
{
- \@@_set_initial_coords_from_anchor:n { south~west }
- \@@_set_final_coords_from_anchor:n { north~west }
- \bool_set:Nn \l_tmpa_bool
- { \dim_compare_p:nNn \l_@@_x_initial_dim = \l_@@_x_final_dim }
- }
+ \@@_open_y_initial_dim:
+ \@@_open_y_final_dim:
+ \int_compare:nNnTF \l_@@_initial_j_int = \c_zero_int
% \end{macrocode}
-% Now, we try to determine whether the column is of type |c| or may be
-% considered as if.
+% We have a dotted line open on both sides in the ``first column''.
% \begin{macrocode}
- \bool_if:NTF \l_@@_initial_open_bool
- \@@_open_y_initial_dim:
- { \@@_set_initial_coords_from_anchor:n { south } }
- \bool_if:NTF \l_@@_final_open_bool
- \@@_open_y_final_dim:
- { \@@_set_final_coords_from_anchor:n { north } }
- \bool_if:NTF \l_@@_initial_open_bool
- {
- \bool_if:NTF \l_@@_final_open_bool
{
- \@@_qpoint:n { col - \int_use:N \l_@@_initial_j_int }
- \dim_set_eq:NN \l_tmpa_dim \pgf@x
- \@@_qpoint:n { col - \int_eval:n { \l_@@_initial_j_int + 1 } }
- \dim_set:Nn \l_@@_x_initial_dim { ( \pgf@x + \l_tmpa_dim ) / 2 }
- \dim_set_eq:NN \l_@@_x_final_dim \l_@@_x_initial_dim
-% \end{macrocode}
-% We may think that the final user won't use a ``last column'' which contains
-% only a command |\Vdots|. However, if the |\Vdots| is in fact used to draw, not
-% a dotted line, but an arrow (to indicate the number of rows of the matrix), it
-% may be really encountered. That's why we do an adjustemnt for that case.
-% \begin{macrocode}
- \int_compare:nNnT \l_@@_last_col_int > { -2 }
+ \@@_qpoint:n { col - 1 }
+ \dim_set_eq:NN \l_@@_x_initial_dim \pgf@x
+ \dim_sub:Nn \l_@@_x_initial_dim \l_@@_left_margin_dim
+ \dim_sub:Nn \l_@@_x_initial_dim \l_@@_extra_left_margin_dim
+ % \bool_if:NT \g_@@_delims_bool
+ % {
+ \dim_sub:Nn \l_@@_x_initial_dim \c_@@_shift_exterior_Vdots_dim
+ % }
+ }
+ {
+ \bool_lazy_and:nnTF
+ { \int_compare_p:nNn \l_@@_last_col_int > { -2 } }
+ { \int_compare_p:nNn \l_@@_initial_j_int = \g_@@_col_total_int }
+% \end{macrocode}
+% We have a dotted line open on both sides in the ``last column''.
+% \begin{macrocode}
{
- \int_compare:nNnT \l_@@_initial_j_int = \g_@@_col_total_int
- {
- \dim_set:Nn \l_tmpa_dim
- {
- \l_@@_right_margin_dim + \l_@@_extra_right_margin_dim
- + 2 mm
- }
- \dim_add:Nn \l_@@_x_initial_dim \l_tmpa_dim
- \dim_add:Nn \l_@@_x_final_dim \l_tmpa_dim
- }
+ \@@_qpoint:n { col - \int_use:N \l_@@_initial_j_int }
+ \dim_set_eq:NN \l_@@_x_initial_dim \pgf@x
+ \dim_add:Nn \l_@@_x_initial_dim \l_@@_right_margin_dim
+ \dim_add:Nn \l_@@_x_initial_dim \l_@@_extra_right_margin_dim
+ % \bool_if:NT \g_@@_delims_bool
+ % {
+ \dim_add:Nn
+ \l_@@_x_initial_dim
+ \c_@@_shift_exterior_Vdots_dim
+ % }
}
+% \end{macrocode}
+% We have a dotted line open on both sides which is \emph{not} in an exterior column.
+% \begin{macrocode}
+ {
+ \@@_qpoint:n { col - \int_use:N \l_@@_initial_j_int }
+ \dim_set_eq:NN \l_tmpa_dim \pgf@x
+ \@@_qpoint:n { col - \int_eval:n { \l_@@_initial_j_int + 1 } }
+ \dim_set:Nn \l_@@_x_initial_dim { ( \pgf@x + \l_tmpa_dim ) / 2 }
+ }
}
- { \dim_set_eq:NN \l_@@_x_initial_dim \l_@@_x_final_dim }
}
+% \end{macrocode}
+%
+% Now, the dotted line is \emph{not} open on both sides (maybe open on only one side).
+%
+% The boolean |\l_tmpa_bool| will indicate whether the column is of type |l| or
+% may be considered as if.
+% \begin{macrocode}
{
- \bool_if:NTF \l_@@_final_open_bool
- { \dim_set_eq:NN \l_@@_x_final_dim \l_@@_x_initial_dim }
+ \bool_set_false:N \l_tmpa_bool
+ \bool_lazy_and:nnT
+ { ! \l_@@_initial_open_bool }
+ { ! \l_@@_final_open_bool }
{
+ \@@_set_initial_coords_from_anchor:n { south~west }
+ \@@_set_final_coords_from_anchor:n { north~west }
+ \bool_set:Nn \l_tmpa_bool
+ { \dim_compare_p:nNn \l_@@_x_initial_dim = \l_@@_x_final_dim }
+ }
+% \end{macrocode}
+% Now, we try to determine whether the column is of type |c| or may be
+% considered as if.
+% \begin{macrocode}
+ \bool_if:NTF \l_@@_initial_open_bool
+ {
+ \@@_open_y_initial_dim:
+ \@@_set_final_coords_from_anchor:n { north }
+ \dim_set_eq:NN \l_@@_x_initial_dim \l_@@_x_final_dim
+ }
+ {
+ \@@_set_initial_coords_from_anchor:n { south }
+ \bool_if:NTF \l_@@_final_open_bool
+ \@@_open_y_final_dim:
% \end{macrocode}
% Now the case where both extremities are closed. The first conditional tests
% whether the column is of type |c| or may be considered as if.
% \begin{macrocode}
- \dim_compare:nNnF \l_@@_x_initial_dim = \l_@@_x_final_dim
{
- \dim_set:Nn \l_@@_x_initial_dim
+ \@@_set_final_coords_from_anchor:n { north }
+ \dim_compare:nNnF \l_@@_x_initial_dim = \l_@@_x_final_dim
{
- \bool_if:NTF \l_tmpa_bool \dim_min:nn \dim_max:nn
- \l_@@_x_initial_dim \l_@@_x_final_dim
+ \dim_set:Nn \l_@@_x_initial_dim
+ {
+ \bool_if:NTF \l_tmpa_bool \dim_min:nn \dim_max:nn
+ \l_@@_x_initial_dim \l_@@_x_final_dim
+ }
}
- \dim_set_eq:NN \l_@@_x_final_dim \l_@@_x_initial_dim
- }
- }
+ }
+ }
}
+ \dim_set_eq:NN \l_@@_x_final_dim \l_@@_x_initial_dim
\@@_draw_line:
}
% \end{macrocode}
@@ -8439,6 +8632,7 @@ version 2005/12/01 or later.
% of the line.
% \begin{macrocode}
\group_begin:
+ \@@_open_shorten:
\keys_set:nn { NiceMatrix / xdots } { #3 }
\tl_if_empty:VF \l_@@_xdots_color_tl { \color { \l_@@_xdots_color_tl } }
\@@_actually_draw_Ddots:
@@ -8533,6 +8727,7 @@ version 2005/12/01 or later.
% of the line.
% \begin{macrocode}
\group_begin:
+ \@@_open_shorten:
\keys_set:nn { NiceMatrix / xdots } { #3 }
\tl_if_empty:VF \l_@@_xdots_color_tl { \color { \l_@@_xdots_color_tl } }
\@@_actually_draw_Iddots:
@@ -8639,18 +8834,19 @@ version 2005/12/01 or later.
% \begin{macrocode}
\cs_new_protected:Npn \@@_draw_unstandard_dotted_line:n #1
{
- \@@_draw_unstandard_dotted_line:nVV
+ \@@_draw_unstandard_dotted_line:nVVV
{ #1 }
\l_@@_xdots_up_tl
\l_@@_xdots_down_tl
+ \l_@@_xdots_middle_tl
}
\cs_generate_variant:Nn \@@_draw_unstandard_dotted_line:n { o }
% \end{macrocode}
%
%
% \bigskip
-% The following Tikz styles are for both labels (set by the symbols |_| and |^|)
-% of a continous line with a non-standard style.
+% The following Tikz styles are for the three labels (set by the symbols |_|,
+% |^| and |=|) of a continous line with a non-standard style.
% \begin{macrocode}
\hook_gput_code:nnn { begindocument } { . }
{
@@ -8659,7 +8855,12 @@ version 2005/12/01 or later.
\tikzset
{
@@_node_above / .style = { sloped , above } ,
- @@_node_below / .style = { sloped , below }
+ @@_node_below / .style = { sloped , below } ,
+ @@_node_middle / .style =
+ {
+ sloped ,
+ inner~sep = \c_@@_innersep_middle_dim
+ }
}
}
{ }
@@ -8668,91 +8869,103 @@ version 2005/12/01 or later.
%
% \bigskip
% \begin{macrocode}
-\cs_new_protected:Npn \@@_draw_unstandard_dotted_line:nnn #1 #2 #3
+\cs_new_protected:Npn \@@_draw_unstandard_dotted_line:nnnn #1 #2 #3 #4
{
+% \end{macrocode}
+% We take into account the parameters |xdots/shorten-start| and
+% |xdots/shorten-end| ``by hand'' because, when we use the key |shorten >| and
+% |shorten <| of TikZ in the command |\draw|, we don't have the expected output
+% with |{decorate,decoration=brace}| is used.
+%
+% \medskip
+% The dimension |\l_@@_l_dim| is the length $\ell$ of the line to draw. We use
+% the floating point reals of the L3 programming layer to compute this length.
+% \begin{macrocode}
+ \dim_zero_new:N \l_@@_l_dim
+ \dim_set:Nn \l_@@_l_dim
+ {
+ \fp_to_dim:n
+ {
+ sqrt
+ (
+ ( \l_@@_x_final_dim - \l_@@_x_initial_dim ) ^ 2
+ +
+ ( \l_@@_y_final_dim - \l_@@_y_initial_dim ) ^ 2
+ )
+ }
+ }
+ \bool_lazy_and:nnT % security
+ { \dim_compare_p:nNn { \dim_abs:n \l_@@_l_dim } < \c_@@_max_l_dim }
+ { \dim_compare_p:nNn { \dim_abs:n \l_@@_l_dim } > { 1 pt } }
+ {
+ \dim_set:Nn \l_tmpa_dim
+ {
+ \l_@@_x_initial_dim
+ + ( \l_@@_x_final_dim - \l_@@_x_initial_dim )
+ * \dim_ratio:nn \l_@@_xdots_shorten_start_dim \l_@@_l_dim
+ }
+ \dim_set:Nn \l_tmpb_dim
+ {
+ \l_@@_y_initial_dim
+ + ( \l_@@_y_final_dim - \l_@@_y_initial_dim )
+ * \dim_ratio:nn \l_@@_xdots_shorten_start_dim \l_@@_l_dim
+ }
+ \dim_set:Nn \l_@@_tmpc_dim
+ {
+ \l_@@_x_final_dim
+ - ( \l_@@_x_final_dim - \l_@@_x_initial_dim )
+ * \dim_ratio:nn \l_@@_xdots_shorten_end_dim \l_@@_l_dim
+ }
+ \dim_set:Nn \l_@@_tmpd_dim
+ {
+ \l_@@_y_final_dim
+ - ( \l_@@_y_final_dim - \l_@@_y_initial_dim )
+ * \dim_ratio:nn \l_@@_xdots_shorten_end_dim \l_@@_l_dim
+ }
+ \dim_set_eq:NN \l_@@_x_initial_dim \l_tmpa_dim
+ \dim_set_eq:NN \l_@@_y_initial_dim \l_tmpb_dim
+ \dim_set_eq:NN \l_@@_x_final_dim \l_@@_tmpc_dim
+ \dim_set_eq:NN \l_@@_y_final_dim \l_@@_tmpd_dim
+ }
+% \end{macrocode}
+%
+%
+% If the key |xdots/horizontal-labels| has been used.
+% \begin{macrocode}
\bool_if:NT \l_@@_xdots_h_labels_bool
{
\tikzset
{
@@_node_above / .style = { auto = left } ,
- @@_node_below / .style = { auto = right }
+ @@_node_below / .style = { auto = right } ,
+ @@_node_middle / .style = { inner~sep = \c_@@_innersep_middle_dim }
}
}
+ \tl_if_empty:nF { #4 }
+ { \tikzset { @@_node_middle / .append~style = { fill = white } } }
\draw
- [
- shorten~> = \l_@@_xdots_shorten_end_dim ,
- shorten~< = \l_@@_xdots_shorten_start_dim ,
- #1
- ]
+ [ #1 ]
( \l_@@_x_initial_dim , \l_@@_y_initial_dim )
% \end{macrocode}
% Be careful: We can't put |\c_math_toggle_token| instead of |$| in the
% following lines because we are in the contents of Tikz nodes (and they will be
% \emph{rescanned} if the Tikz library \pkg{babel} is loaded).
% \begin{macrocode}
- -- node [ @@_node_above ] { $ \scriptstyle #2 $ }
+ -- node [ @@_node_middle] { $ \scriptstyle #4 $ }
node [ @@_node_below ] { $ \scriptstyle #3 $ }
+ node [ @@_node_above ] { $ \scriptstyle #2 $ }
( \l_@@_x_final_dim , \l_@@_y_final_dim ) ;
\end { scope }
}
-\cs_generate_variant:Nn \@@_draw_unstandard_dotted_line:nnn { n V V }
+\cs_generate_variant:Nn \@@_draw_unstandard_dotted_line:nnnn { n V V V }
% \end{macrocode}
%
% \bigskip
% The command |\@@_draw_standard_dotted_line:| draws the line with our system of dots
-% (which gives a dotted line with real round dots).
+% (which gives a dotted line with real rounded dots).
% \begin{macrocode}
\cs_new_protected:Npn \@@_draw_standard_dotted_line:
- {
- \bool_lazy_and:nnF
- { \tl_if_empty_p:N \l_@@_xdots_up_tl }
- { \tl_if_empty_p:N \l_@@_xdots_down_tl }
- {
- \pgfscope
- \pgftransformshift
- {
- \pgfpointlineattime { 0.5 }
- { \pgfpoint \l_@@_x_initial_dim \l_@@_y_initial_dim }
- { \pgfpoint \l_@@_x_final_dim \l_@@_y_final_dim }
- }
- \fp_set:Nn \l_tmpa_fp
- {
- atand
- (
- \l_@@_y_final_dim - \l_@@_y_initial_dim ,
- \l_@@_x_final_dim - \l_@@_x_initial_dim
- )
- }
- \pgftransformrotate { \fp_use:N \l_tmpa_fp }
- \bool_if:NF \l_@@_xdots_h_labels_bool { \fp_zero:N \l_tmpa_fp }
- \pgfnode
- { rectangle }
- { south }
- {
- \rotatebox { \fp_eval:n { - \l_tmpa_fp } }
- {
- \c_math_toggle_token
- \scriptstyle \l_@@_xdots_up_tl
- \c_math_toggle_token
- }
- }
- { }
- { \pgfusepath { } }
- \pgfnode
- { rectangle }
- { north }
- {
- \rotatebox { \fp_eval:n { - \l_tmpa_fp } }
- {
- \c_math_toggle_token
- \scriptstyle \l_@@_xdots_down_tl
- \c_math_toggle_token
- }
- }
- { }
- { \pgfusepath { } }
- \endpgfscope
- }
+ {
\group_begin:
% \end{macrocode}
% The dimension |\l_@@_l_dim| is the length $\ell$ of the line to draw. We use
@@ -8783,6 +8996,15 @@ version 2005/12/01 or later.
{ \dim_compare_p:nNn \l_@@_l_dim = \c_zero_dim }
\@@_draw_standard_dotted_line_i:
\group_end:
+% \end{macrocode}
+% \begin{macrocode}
+ \bool_lazy_all:nF
+ {
+ { \tl_if_empty_p:N \l_@@_xdots_up_tl }
+ { \tl_if_empty_p:N \l_@@_xdots_down_tl }
+ { \tl_if_empty_p:N \l_@@_xdots_middle_tl }
+ }
+ \l_@@_labels_standard_dotted_line:
}
% \end{macrocode}
%
@@ -8796,43 +9018,15 @@ version 2005/12/01 or later.
% \end{macrocode}
% The number of dots will be |\l_tmpa_int + 1|.
% \begin{macrocode}
- \bool_if:NTF \l_@@_initial_open_bool
- {
- \bool_if:NTF \l_@@_final_open_bool
- {
- \int_set:Nn \l_tmpa_int
- { \dim_ratio:nn \l_@@_l_dim \l_@@_xdots_inter_dim }
- }
- {
- \int_set:Nn \l_tmpa_int
- {
- \dim_ratio:nn
- { \l_@@_l_dim - \l_@@_xdots_shorten_start_dim }
- \l_@@_xdots_inter_dim
- }
- }
- }
+ \int_set:Nn \l_tmpa_int
{
- \bool_if:NTF \l_@@_final_open_bool
+ \dim_ratio:nn
{
- \int_set:Nn \l_tmpa_int
- {
- \dim_ratio:nn
- { \l_@@_l_dim - \l_@@_xdots_shorten_end_dim }
- \l_@@_xdots_inter_dim
- }
- }
- {
- \int_set:Nn \l_tmpa_int
- {
- \dim_ratio:nn
- {
- \l_@@_l_dim
- - \l_@@_xdots_shorten_start_dim - \l_@@_xdots_shorten_end_dim
- }
- \l_@@_xdots_inter_dim
- }
- }
+ \l_@@_l_dim
+ - \l_@@_xdots_shorten_start_dim
+ - \l_@@_xdots_shorten_end_dim
+ }
+ \l_@@_xdots_inter_dim
}
% \end{macrocode}
%
@@ -8873,7 +9067,7 @@ version 2005/12/01 or later.
\dim_ratio:nn
{
\l_@@_l_dim - \l_@@_xdots_inter_dim * \l_tmpa_int
- + \l_@@_xdots_shorten_start_dim - \l_@@_xdots_shorten_end_dim
+ + \l_@@_xdots_shorten_start_dim - \l_@@_xdots_shorten_end_dim
}
{ 2 \l_@@_l_dim }
}
@@ -8891,6 +9085,85 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
+% \begin{macrocode}
+\cs_new_protected:Npn \l_@@_labels_standard_dotted_line:
+ {
+ \pgfscope
+ \pgftransformshift
+ {
+ \pgfpointlineattime { 0.5 }
+ { \pgfpoint \l_@@_x_initial_dim \l_@@_y_initial_dim }
+ { \pgfpoint \l_@@_x_final_dim \l_@@_y_final_dim }
+ }
+ \fp_set:Nn \l_tmpa_fp
+ {
+ atand
+ (
+ \l_@@_y_final_dim - \l_@@_y_initial_dim ,
+ \l_@@_x_final_dim - \l_@@_x_initial_dim
+ )
+ }
+ \pgftransformrotate { \fp_use:N \l_tmpa_fp }
+ \bool_if:NF \l_@@_xdots_h_labels_bool { \fp_zero:N \l_tmpa_fp }
+ \tl_if_empty:NF \l_@@_xdots_middle_tl
+ {
+ \begin { pgfscope }
+ \pgfset { inner~sep = \c_@@_innersep_middle_dim }
+ \pgfnode
+ { rectangle }
+ { center }
+ {
+ \rotatebox { \fp_eval:n { - \l_tmpa_fp } }
+ {
+ \c_math_toggle_token
+ \scriptstyle \l_@@_xdots_middle_tl
+ \c_math_toggle_token
+ }
+ }
+ { }
+ {
+ \pgfsetfillcolor { white }
+ \pgfusepath { fill }
+ }
+ \end { pgfscope }
+ }
+ \tl_if_empty:NF \l_@@_xdots_up_tl
+ {
+ \pgfnode
+ { rectangle }
+ { south }
+ {
+ \rotatebox { \fp_eval:n { - \l_tmpa_fp } }
+ {
+ \c_math_toggle_token
+ \scriptstyle \l_@@_xdots_up_tl
+ \c_math_toggle_token
+ }
+ }
+ { }
+ { \pgfusepath { } }
+ }
+ \tl_if_empty:NF \l_@@_xdots_down_tl
+ {
+ \pgfnode
+ { rectangle }
+ { north }
+ {
+ \rotatebox { \fp_eval:n { - \l_tmpa_fp } }
+ {
+ \c_math_toggle_token
+ \scriptstyle \l_@@_xdots_down_tl
+ \c_math_toggle_token
+ }
+ }
+ { }
+ { \pgfusepath { } }
+ }
+ \endpgfscope
+ }
+% \end{macrocode}
+%
+% \bigskip
% \section{User commands available in the new environments}
%
%
@@ -8912,9 +9185,11 @@ version 2005/12/01 or later.
% \begin{macrocode}
\hook_gput_code:nnn { begindocument } { . }
{
- \tl_set:Nn \l_@@_argspec_tl { O { } E { _ ^ } { { } { } } }
+ \tl_set:Nn \l_@@_argspec_tl { m E { _ ^ : } { { } { } { } } }
\tl_set_rescan:Nno \l_@@_argspec_tl { } \l_@@_argspec_tl
- \exp_args:NNV \NewDocumentCommand \@@_Ldots \l_@@_argspec_tl
+ \cs_new_protected:Npn \@@_Ldots
+ { \@@_collect_options:n { \@@_Ldots_i } }
+ \exp_args:NNV \NewDocumentCommand \@@_Ldots_i \l_@@_argspec_tl
{
\int_compare:nNnTF \c@jCol = 0
{ \@@_error:nn { in~first~col } \Ldots }
@@ -8923,7 +9198,7 @@ version 2005/12/01 or later.
{ \@@_error:nn { in~last~col } \Ldots }
{
\@@_instruction_of_type:nnn \c_false_bool { Ldots }
- { #1 , down = #2 , up = #3 }
+ { #1 , down = #2 , up = #3 , middle = #4 }
}
}
\bool_if:NF \l_@@_nullify_dots_bool
@@ -8934,7 +9209,9 @@ version 2005/12/01 or later.
%
% \bigskip
% \begin{macrocode}
- \exp_args:NNV \NewDocumentCommand \@@_Cdots \l_@@_argspec_tl
+ \cs_new_protected:Npn \@@_Cdots
+ { \@@_collect_options:n { \@@_Cdots_i } }
+ \exp_args:NNV \NewDocumentCommand \@@_Cdots_i \l_@@_argspec_tl
{
\int_compare:nNnTF \c@jCol = 0
{ \@@_error:nn { in~first~col } \Cdots }
@@ -8943,7 +9220,7 @@ version 2005/12/01 or later.
{ \@@_error:nn { in~last~col } \Cdots }
{
\@@_instruction_of_type:nnn \c_false_bool { Cdots }
- { #1 , down = #2 , up = #3 }
+ { #1 , down = #2 , up = #3 , middle = #4 }
}
}
\bool_if:NF \l_@@_nullify_dots_bool
@@ -8954,7 +9231,9 @@ version 2005/12/01 or later.
%
% \bigskip
% \begin{macrocode}
- \exp_args:NNV \NewDocumentCommand \@@_Vdots \l_@@_argspec_tl
+ \cs_new_protected:Npn \@@_Vdots
+ { \@@_collect_options:n { \@@_Vdots_i } }
+ \exp_args:NNV \NewDocumentCommand \@@_Vdots_i \l_@@_argspec_tl
{
\int_compare:nNnTF \c@iRow = 0
{ \@@_error:nn { in~first~row } \Vdots }
@@ -8963,7 +9242,7 @@ version 2005/12/01 or later.
{ \@@_error:nn { in~last~row } \Vdots }
{
\@@_instruction_of_type:nnn \c_false_bool { Vdots }
- { #1 , down = #2 , up = #3 }
+ { #1 , down = #2 , up = #3 , middle = #4 }
}
}
\bool_if:NF \l_@@_nullify_dots_bool
@@ -8975,7 +9254,9 @@ version 2005/12/01 or later.
%
% \bigskip
% \begin{macrocode}
- \exp_args:NNV \NewDocumentCommand \@@_Ddots \l_@@_argspec_tl
+ \cs_new_protected:Npn \@@_Ddots
+ { \@@_collect_options:n { \@@_Ddots_i } }
+ \exp_args:NNV \NewDocumentCommand \@@_Ddots_i \l_@@_argspec_tl
{
\int_case:nnF \c@iRow
{
@@ -8991,7 +9272,7 @@ version 2005/12/01 or later.
{
\keys_set_known:nn { NiceMatrix / Ddots } { #1 }
\@@_instruction_of_type:nnn \l_@@_draw_first_bool { Ddots }
- { #1 , down = #2 , up = #3 }
+ { #1 , down = #2 , up = #3 , middle = #4 }
}
}
@@ -9003,7 +9284,9 @@ version 2005/12/01 or later.
%
% \bigskip
% \begin{macrocode}
- \exp_args:NNV \NewDocumentCommand \@@_Iddots \l_@@_argspec_tl
+ \cs_new_protected:Npn \@@_Iddots
+ { \@@_collect_options:n { \@@_Iddots_i } }
+ \exp_args:NNV \NewDocumentCommand \@@_Iddots_i \l_@@_argspec_tl
{
\int_case:nnF \c@iRow
{
@@ -9019,7 +9302,7 @@ version 2005/12/01 or later.
{
\keys_set_known:nn { NiceMatrix / Ddots } { #1 }
\@@_instruction_of_type:nnn \l_@@_draw_first_bool { Iddots }
- { #1 , down = #2 , up = #3 }
+ { #1 , down = #2 , up = #3 , middle = #4 }
}
}
\bool_if:NF \l_@@_nullify_dots_bool
@@ -9099,13 +9382,15 @@ version 2005/12/01 or later.
% \begin{macrocode}
\hook_gput_code:nnn { begindocument } { . }
{
- \tl_set:Nn \l_@@_argspec_tl { O { } m O { } E { _ ^ } { { } { } } }
+ \tl_set:Nn \l_@@_argspec_tl { m m O { } E { _ ^ : } { { } { } { } } }
\tl_set_rescan:Nno \l_@@_argspec_tl { } \l_@@_argspec_tl
% \end{macrocode}
% We don't put |!| before the last optionnal argument for homogeneity with
% |\Cdots|, etc. which have only one optional argument.
% \begin{macrocode}
- \exp_args:NNV \NewDocumentCommand \@@_Hdotsfor_i \l_@@_argspec_tl
+ \cs_new_protected:Npn \@@_Hdotsfor_i
+ { \@@_collect_options:n { \@@_Hdotsfor_ii } }
+ \exp_args:NNV \NewDocumentCommand \@@_Hdotsfor_ii \l_@@_argspec_tl
{
\tl_gput_right:Nx \g_@@_HVdotsfor_lines_tl
{
@@ -9116,7 +9401,8 @@ version 2005/12/01 or later.
{
#1 , #3 ,
down = \exp_not:n { #4 } ,
- up = \exp_not:n { #5 }
+ up = \exp_not:n { #5 } ,
+ middle = \exp_not:n { #6 }
}
}
\prg_replicate:nn { #2 - 1 } { & \multicolumn { 1 } { c } { } }
@@ -9178,12 +9464,17 @@ version 2005/12/01 or later.
%
% \begin{macrocode}
\group_begin:
+
+ \@@_open_shorten:
+
+
\int_compare:nNnTF { #1 } = 0
{ \color { nicematrix-first-row } }
{
\int_compare:nNnT { #1 } = \g_@@_row_total_int
{ \color { nicematrix-last-row } }
}
+
\keys_set:nn { NiceMatrix / xdots } { #4 }
\tl_if_empty:VF \l_@@_xdots_color_tl { \color { \l_@@_xdots_color_tl } }
\@@_actually_draw_Ldots:
@@ -9205,9 +9496,11 @@ version 2005/12/01 or later.
% \begin{macrocode}
\hook_gput_code:nnn { begindocument } { . }
{
- \tl_set:Nn \l_@@_argspec_tl { O { } m O { } E { _ ^ } { { } { } } }
+ \tl_set:Nn \l_@@_argspec_tl { m m O { } E { _ ^ : } { { } { } { } } }
\tl_set_rescan:Nno \l_@@_argspec_tl { } \l_@@_argspec_tl
- \exp_args:NNV \NewDocumentCommand \@@_Vdotsfor: \l_@@_argspec_tl
+ \cs_new_protected:Npn \@@_Vdotsfor:
+ { \@@_collect_options:n { \@@_Vdotsfor_i } }
+ \exp_args:NNV \NewDocumentCommand \@@_Vdotsfor_i \l_@@_argspec_tl
{
\bool_gset_true:N \g_@@_empty_cell_bool
\tl_gput_right:Nx \g_@@_HVdotsfor_lines_tl
@@ -9218,14 +9511,16 @@ version 2005/12/01 or later.
{ #2 }
{
#1 , #3 ,
- down = \exp_not:n { #4 } , up = \exp_not:n { #5 }
+ down = \exp_not:n { #4 } ,
+ up = \exp_not:n { #5 } ,
+ middle = \exp_not:n { #6 }
}
}
}
}
% \end{macrocode}
-% Enf of |\AddToHook|.
%
+% \bigskip
% \begin{macrocode}
\cs_new_protected:Npn \@@_Vdotsfor:nnnn #1 #2 #3 #4
{
@@ -9279,6 +9574,11 @@ version 2005/12/01 or later.
%
% \begin{macrocode}
\group_begin:
+ \@@_open_shorten:
+
+
+
+
\int_compare:nNnTF { #2 } = 0
{ \color { nicematrix-first-col } }
{
@@ -9309,8 +9609,11 @@ version 2005/12/01 or later.
% \begin{macrocode}
\NewDocumentCommand \@@_rotate: { O { } }
{
- \bool_gset_true:N \g_@@_rotate_bool
- \keys_set:nn { NiceMatrix / rotate } { #1 }
+ \peek_remove_spaces:n
+ {
+ \bool_gset_true:N \g_@@_rotate_bool
+ \keys_set:nn { NiceMatrix / rotate } { #1 }
+ }
}
% \end{macrocode}
%
@@ -9364,7 +9667,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\hook_gput_code:nnn { begindocument } { . }
{
- \tl_set:Nn \l_@@_argspec_tl { O { } m m ! O { } E { _ ^ } { { } { } } }
+ \tl_set:Nn \l_@@_argspec_tl { O { } m m ! O { } E { _ ^ : } { { } { } { } } }
\tl_set_rescan:Nno \l_@@_argspec_tl { } \l_@@_argspec_tl
\exp_args:NNV \NewDocumentCommand \@@_line \l_@@_argspec_tl
{
@@ -9659,28 +9962,23 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
-% The macro |\@@_actually_color:| will actually fill all the rectangles, color by
-% color (using the sequence |\l_@@_colors_seq| and all the token lists of the
-% form |\l_@@_color_|$i$|_tl|).
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_actually_color:
- {
- \pgfpicture
- \pgf@relevantforpicturesizefalse
-% \end{macrocode}
-% If the final user has used the key |rounded-corners| for the environment
-% |{NiceTabular}|, we will clip to a rectangle with rounded corners before
-% filling the rectangles.
+% The following command must be used within a |\pgfpicture|.
% \begin{macrocode}
+\cs_new_protected:Npn \@@_clip_with_rounded_corners:
+ {
\dim_compare:nNnT \l_@@_tab_rounded_corners_dim > \c_zero_dim
{
+% \end{macrocode}
+% The TeX group is for |\pgfsetcornersarced| (whose scope is the TeX scope).
+% \begin{macrocode}
+ \group_begin:
\pgfsetcornersarced
{
\pgfpoint
{ \l_@@_tab_rounded_corners_dim }
{ \l_@@_tab_rounded_corners_dim }
}
-% \end{macrococde}
+% \end{macrocode}
% Because we want \pkg{nicematrix} compatible with arrays constructed by
% \pkg{array}, the nodes for the rows and columns (that is to say the nodes
% |row-|\textsl{i} and |col-|\textsl{j}) have not always the expected position,
@@ -9719,7 +10017,29 @@ version 2005/12/01 or later.
}
}
\pgfusepath { clip }
+ \group_end:
+% \end{macrocode}
+% The TeX group was for |\pgfsetcornersarced|.
+% \begin{macrocode}
}
+ }
+% \end{macrocode}
+%
+% \bigskip
+% The macro |\@@_actually_color:| will actually fill all the rectangles, color by
+% color (using the sequence |\l_@@_colors_seq| and all the token lists of the
+% form |\l_@@_color_|$i$|_tl|).
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_actually_color:
+ {
+ \pgfpicture
+ \pgf@relevantforpicturesizefalse
+% \end{macrocode}
+% If the final user has used the key |rounded-corners| for the environment
+% |{NiceTabular}|, we will clip to a rectangle with rounded corners before
+% filling the rectangles.
+% \begin{macrocode}
+ \@@_clip_with_rounded_corners:
\seq_map_indexed_inline:Nn \g_@@_colors_seq
{
\begin { pgfscope }
@@ -9916,11 +10236,12 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \medskip
-% The command |\rowcolors| (accessible in the |code-before|) is inspired by the
+% The command |\rowcolors| (accessible in the |\CodeBefore|) is inspired by the
% command |\rowcolors| of the package \pkg{xcolor} (with the option |table|).
% However, the command |\rowcolors| of \pkg{nicematrix} has \emph{not} the
-% optional argument of the command |\rowcolors| of \pkg{xcolor}. Here is an
-% example: |\rowcolors{1}{blue!10}{}[respect-blocks]|.
+% optional argument of the command |\rowcolors| of \pkg{xcolor}.
+%
+% Here is an example: |\rowcolors{1}{blue!10}{}[respect-blocks]|.
%
% In \pkg{nicematrix}, the commmand |\@@_rowcolors| apperas as a special case of
% |\@@_rowlistcolors|.
@@ -9951,7 +10272,7 @@ version 2005/12/01 or later.
{
% \end{macrocode}
% We don't want to take into account a block which is completely in the ``first
-% column'' of (number $0$) or in the ``last column'' and that's why we filter
+% column'' (number~$0$) or in the ``last column'' and that's why we filter
% the sequence of the blocks (in a the sequence |\l_tmpa_seq|).
% \begin{macrocode}
\seq_set_eq:NN \l_tmpb_seq \g_@@_pos_of_blocks_seq
@@ -10276,7 +10597,8 @@ version 2005/12/01 or later.
\tl_gput_right:Nx \g__nicematrix_pre_code_before_tl
{
\@@_rowlistcolors
- [ #1 ] { \int_use:N \c@iRow } { #2 } [ restart, #3 ]
+ [ #1 ] { \int_use:N \c@iRow } { #2 }
+ [ restart, cols = \int_use:N \c@jCol - , #3 ]
}
}
}
@@ -10806,7 +11128,6 @@ version 2005/12/01 or later.
% \begin{macrocode}
\cs_new_protected:Npn \@@_hline_ii:
{
- % \bool_set_false:N \l_@@_dotted_bool
\keys_set:nV { NiceMatrix / RulesBis } \l_@@_other_keys_tl
\bool_if:NTF \l_@@_dotted_bool
\@@_hline_iv:
@@ -10989,7 +11310,7 @@ version 2005/12/01 or later.
% \bigskip
% The command |\@@_draw_hlines:| draws all the horizontal rules excepted in the
% blocks (even the virtual blocks determined by commands such as |\Cdots| and in
-% the corners (if the key |corners| is used)).
+% the corners --- if the key |corners| is used).
% \begin{macrocode}
\cs_new_protected:Npn \@@_draw_hlines:
{
@@ -11097,6 +11418,7 @@ version 2005/12/01 or later.
\str_clear_new:N \l_@@_command_str
\str_clear_new:N \l_@@_ccommand_str
\str_clear_new:N \l_@@_letter_str
+ \tl_clear_new:N \l_@@_other_keys_tl
\keys_set_known:nnN { NiceMatrix / custom-line } { #1 } \l_@@_other_keys_tl
% \end{macrocode}
% If the final user only wants to draw horizontal rules, he does not need to
@@ -11277,7 +11599,6 @@ version 2005/12/01 or later.
}
\seq_put_left:NV \l_@@_custom_line_commands_seq \l_@@_command_str
}
-\cs_generate_variant:Nn \@@_h_custom_line:nn { n V }
% \end{macrocode}
%
% \bigskip
@@ -11330,7 +11651,6 @@ version 2005/12/01 or later.
}
}
}
-\cs_generate_variant:Nn \@@_c_custom_line:nn { n V }
% \end{macrocode}
%
% \begin{macrocode}
@@ -11705,6 +12025,7 @@ version 2005/12/01 or later.
}
\iow_shipout:Nn \@mainaux \ExplSyntaxOff
}
+ \ignorespacesafterend
}
% \end{macrocode}
%
@@ -12089,12 +12410,21 @@ version 2005/12/01 or later.
C .value_forbidden:n = true ,
t .code:n = \str_set:Nn \l_@@_vpos_of_block_str t ,
t .value_forbidden:n = true ,
+ T .code:n = \str_set:Nn \l_@@_vpos_of_block_str T ,
+ T .value_forbidden:n = true ,
b .code:n = \str_set:Nn \l_@@_vpos_of_block_str b ,
b .value_forbidden:n = true ,
- color .tl_set:N = \l_@@_color_tl ,
+ B .code:n = \str_set:Nn \l_@@_vpos_of_block_str B ,
+ B .value_forbidden:n = true ,
+ color .code:n =
+ \@@_color:n { #1 }
+ \tl_set_rescan:Nnn
+ \l_@@_draw_tl
+ { \char_set_catcode_other:N ! }
+ { #1 } ,
color .value_required:n = true ,
respect-arraystretch .bool_set:N = \l_@@_respect_arraystretch_bool ,
- respect-arraystretch .default:n = true ,
+ respect-arraystretch .default:n = true
}
% \end{macrocode}
%
@@ -12105,22 +12435,14 @@ version 2005/12/01 or later.
% |<| and |>|. It's mandatory to use an expandable command.
%
%
+%
% \begin{macrocode}
-\cs_new_protected:Npn \@@_block:n #1
- {
- \peek_meaning:NTF [
- { \@@_block_i:n { #1 } }
- { \@@_Block_i:[#1] }
- }
-
-\cs_new_protected:Npn \@@_block_i:n #1[#2] { \@@_block:n {#1,#2} }
-
-\cs_new_protected:Npn \@@_Block: { \@@_block:n { } }
+\cs_new_protected:Npn \@@_Block: { \@@_collect_options:n { \@@_Block_i: } }
% \end{macrocode}
-%
+%
% \bigskip
% \begin{macrocode}
-\NewExpandableDocumentCommand \@@_Block_i: { O { } m D < > { } +m }
+\NewExpandableDocumentCommand \@@_Block_i: { m m D < > { } +m }
{
% \end{macrocode}
% If the first mandatory argument of the command (which is the size of the block
@@ -12160,11 +12482,11 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \medskip
-% Now, the arguments have been extracted: |#1| is $i$ (the number of rows of the
-% block), |#2| is $j$ (the number of columns of the block), |#3| is the list of
-% \textsl{key=values} pairs, |#4| are the tokens to put before the math mode and
-% the beginning of the small array of the block and |#5| is the label of the
-% block.
+% Now, the arguments have been extracted:
+% |#1| is $i$ (the number of rows of the block), |#2| is $j$ (the number of
+% columns of the block), |#3| is the list of \textsl{key=values} pairs, |#4| are
+% the tokens to put before the math mode and before the composition of the block
+% and |#5| is the label (=content) of the block.
% \begin{macrocode}
\cs_new_protected:Npn \@@_Block_ii:nnnnn #1 #2 #3 #4 #5
{
@@ -12261,7 +12583,13 @@ version 2005/12/01 or later.
% right now in a box (because we have to take into account the dimensions of
% that box for the width of the current column or the height and the depth of the
% current row). However, that box will be put in the array \emph{after the
-% construction of the array} (by using \textsc{pgf}).
+% construction of the array} (by using \textsc{pgf}) with |\@@_draw_blocks:| and
+% above all |\@@_Block_v:nnnnnn| which will do the main job.
+%
+% |#1| is $i$ (the number of rows of the block), |#2| is $j$ (the number of
+% columns of the block), |#3| is the list of \textsl{key=values} pairs, |#4| are
+% the tokens to put before the math mode and before the composition of the block
+% and |#5| is the label (=content) of the block.
% \begin{macrocode}
\cs_new_protected:Npn \@@_Block_iv:nnnnn #1 #2 #3 #4 #5
{
@@ -12280,6 +12608,13 @@ version 2005/12/01 or later.
}
\box_gclear_new:c
{ g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box }
+% \end{macrocode}
+% Now, we will actually compose the content of the |\Block| in a TeX box.
+% \emph{Be careful}: if after, the construction of the box, the boolean
+% |\g_@@_rotate_bool| is raised (which means that the command |\rotate| was
+% present in the content of the |\Block|) we will rotate the box but also,
+% maybe, change the position of the baseline!
+% \begin{macrocode}
\hbox_gset:cn
{ g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box }
{
@@ -12309,30 +12644,44 @@ version 2005/12/01 or later.
}
\g_@@_row_style_tl
}
- \group_begin:
\bool_if:NF \l_@@_respect_arraystretch_bool
{ \cs_set:Npn \arraystretch { 1 } }
\dim_zero:N \extrarowheight
+% \end{macrocode}
+% |#4| is the optional argument of the command |\Block|, provided with the
+% syntax |<...>|.
+% \begin{macrocode}
#4
% \end{macrocode}
-% If the box is rotated (the key |\rotate| may be in the previous |#4|), the
-% tabular used for the content of the cell will be constructed with a format
-% |c|. In the other cases, the tabular will be constructed with a format equal
-% to the key of position of the box. In other words: the alignment internal to
-% the tabular is the same as the external alignment of the tabular (that is to
-% say the position of the block in its zone of merged cells).
+% We adjust |\l_@@_hpos_block_str| when |\rotate| has been used (in the cell
+% where the command |\Block| is used but maybe in |#4|, |\RowStyle|,
+% |code-for-first-row|, etc.).
+% \begin{macrocode}
+ \@@_adjust_hpos_rotate:
+% \end{macrocode}
+% The boolean |\g_@@_rotate_bool| will be also considered \emph{after the composition
+% of the box} (in order to rotate the box).
+%
+% \medskip
+% Remind that we are in the command of composition of the box of the block.
+% Previously, we have only done some tuning. Now, we will actually compose the
+% content with a |{tabular}|, an |{array}| or a |{minipage}|.
% \begin{macrocode}
- \bool_if:NT \g_@@_rotate_bool { \str_set:Nn \l_@@_hpos_block_str c }
\bool_if:NTF \l_@@_tabular_bool
{
\bool_lazy_all:nTF
{
{ \int_compare_p:nNn { #2 } = 1 }
- { \dim_compare_p:n { \l_@@_col_width_dim >= \c_zero_dim } }
+% \end{macrocode}
+% Remind that, when the column has not a fixed width, the dimension
+% |\l_@@_col_width_dim| has the conventionnal value of $-1$~cm.
+% \begin{macrocode}
+ { \dim_compare_p:n { \l_@@_col_width_dim >= \c_zero_dim } }
{ ! \g_@@_rotate_bool }
}
% \end{macrocode}
-% When the block is mono-column in a column with a fixed width (eg |p{3cm}|).
+% When the block is mono-column in a column with a fixed width (eg |p{3cm}|), we
+% use a |{minipage}|.
% \begin{macrocode}
{
\use:x
@@ -12341,16 +12690,15 @@ version 2005/12/01 or later.
[ \str_lowercase:V { \l_@@_vpos_of_block_str } ]
{ \l_@@_col_width_dim }
\str_case:Vn \l_@@_hpos_block_str
- {
- c \centering
- r \raggedleft
- l \raggedright
- }
+ { c \centering r \raggedleft l \raggedright }
}
#5
\end { minipage }
}
- {
+% \end{macrocode}
+% In the other cases, we use a |{tabular}|.
+% \begin{macrocode}
+ {
\use:x
{
\exp_not:N \begin { tabular }%
@@ -12361,6 +12709,10 @@ version 2005/12/01 or later.
\end { tabular }
}
}
+% \end{macrocode}
+% If we are in a mathematical array (|\l_@@_tabular_bool| is |false|). The
+% composition is always done with an |{array}| (never with a |{minipage}|).
+% \begin{macrocode}
{
\c_math_toggle_token
\use:x
@@ -12373,30 +12725,18 @@ version 2005/12/01 or later.
\end { array }
\c_math_toggle_token
}
- \group_end:
- }
- \bool_if:NT \g_@@_rotate_bool
- {
- \box_grotate:cn
- { g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box }
- { 90 }
- \bool_if:NT \g_@@_rotate_c_bool
- {
- \hbox_gset:cn
- { g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box }
- {
- \c_math_toggle_token
- \vcenter
- {
- \box_use:c
- { g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box }
- }
- \c_math_toggle_token
- }
- }
- \bool_gset_false:N \g_@@_rotate_bool
}
% \end{macrocode}
+% The box which will contain the content of the block has now been composed.
+%
+% \bigskip
+% If there were |\rotate| (which raises |\g_@@_rotate_bool|) in the content of
+% the |\Block|, we do a rotation of the box (and we also adjust the
+% baseline the rotated box).
+% \begin{macrocode}
+ \bool_if:NT \g_@@_rotate_bool \@@_rotate_box_of_block:
+% \end{macrocode}
+%
% If we are in a mono-column block, we take into account the width of that block
% for the width of the column.
% \begin{macrocode}
@@ -12449,8 +12789,17 @@ version 2005/12/01 or later.
% \begin{macrocode}
{
\exp_not:n { #3 } ,
- \l_@@_hpos_block_str ,
- \bool_if:NT \g_@@_rotate_c_bool { v-center }
+ \l_@@_hpos_block_str ,
+% \end{macrocode}
+% Now, we put a key for the vertical alignment.
+% \begin{macrocode}
+ \bool_if:NT \g_@@_rotate_bool
+ {
+ \bool_if:NTF \g_@@_rotate_c_bool
+ { v-center }
+ { \int_compare:nNnT \c@iRow = \l_@@_last_row_int T }
+ }
+
}
{
\box_use_drop:c
@@ -12460,12 +12809,74 @@ version 2005/12/01 or later.
\bool_set_false:N \g_@@_rotate_c_bool
}
% \end{macrocode}
+%
+% \bigskip
+% \begin{macrocode}
+\cs_new:Npn \@@_adjust_hpos_rotate:
+ {
+ \bool_if:NT \g_@@_rotate_bool
+ {
+ \str_set:Nx \l_@@_hpos_block_str
+ {
+ \bool_if:NTF \g_@@_rotate_c_bool
+ { c }
+ {
+ \str_case:VnF \l_@@_vpos_of_block_str
+ { b l B l t r T r }
+ { \int_compare:nNnTF \c@iRow = \l_@@_last_row_int r l }
+ }
+ }
+ }
+ }
+% \end{macrocode}
+%
+% \bigskip
+% Despite its name the following command rotates the box of the block \emph{but
+% also does vertical adjustement of the baseline of the block}.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_rotate_box_of_block:
+ {
+ \box_grotate:cn
+ { g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box }
+ { 90 }
+ \int_compare:nNnT \c@iRow = \l_@@_last_row_int
+ {
+ \vbox_gset_top:cn
+ { g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box }
+ {
+ \skip_vertical:n { 0.8 ex }
+ \box_use:c
+ { g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box }
+ }
+ }
+ \bool_if:NT \g_@@_rotate_c_bool
+ {
+ \hbox_gset:cn
+ { g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box }
+ {
+ \c_math_toggle_token
+ \vcenter
+ {
+ \box_use:c
+ { g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box }
+ }
+ \c_math_toggle_token
+ }
+ }
+ }
+% \end{macrocode}
%
% \bigskip
% The following macro is for the standard case, where the block is not mono-row
% and not mono-column. In that case, the content of the block is \emph{not}
% composed right now in a box. The composition in a box will be done further,
-% just after the construction of the array.
+% just after the construction of the array (cf. |\@@_draw_blocks:| and
+% above all |\@@_Block_v:nnnnnn|).
+%
+% |#1| is $i$ (the number of rows of the block), |#2| is $j$ (the number of
+% columns of the block), |#3| is the list of \textsl{key=values} pairs, |#4| are
+% the tokens to put before the math mode and before the composition of the block
+% and |#5| is the label (=content) of the block.
% \begin{macrocode}
\cs_new_protected:Npn \@@_Block_v:nnnnn #1 #2 #3 #4 #5
{
@@ -12491,8 +12902,7 @@ version 2005/12/01 or later.
% the tabular is the same as the external alignment of the tabular (that is to
% say the position of the block in its zone of merged cells).
% \begin{macrocode}
- \bool_if:NT \g_@@_rotate_bool
- { \str_set:Nn \l_@@_hpos_block_str c }
+ % \@@_adjust_hpos_rotate:
\use:x
{
\exp_not:N \begin { tabular } [ \l_@@_vpos_of_block_str ]
@@ -12503,6 +12913,9 @@ version 2005/12/01 or later.
}
\group_end:
}
+% \end{macrocode}
+% When we are \emph{not} in an environments |{NiceTabular}| (or similar).
+% \begin{macrocode}
{
\group_begin:
\bool_if:NF \l_@@_respect_arraystretch_bool
@@ -12511,9 +12924,8 @@ version 2005/12/01 or later.
{
\dim_zero:N \extrarowheight
#4
- \bool_if:NT \g_@@_rotate_bool
- { \str_set:Nn \l_@@_hpos_block_str c }
- \c_math_toggle_token
+ % \@@_adjust_hpos_rotate:
+ \c_math_toggle_token % :n c
\use:x
{
\exp_not:N \begin { array } [ \l_@@_vpos_of_block_str ]
@@ -12550,6 +12962,8 @@ version 2005/12/01 or later.
{ \char_set_catcode_other:N ! }
{ #1 } ,
fill .value_required:n = true ,
+ opacity .tl_set:N = \l_@@_opacity_tl ,
+ opacity .value_required:n = true ,
draw .code:n =
\tl_set_rescan:Nnn
\l_@@_draw_tl
@@ -12564,7 +12978,6 @@ version 2005/12/01 or later.
\l_@@_draw_tl
{ \char_set_catcode_other:N ! }
{ #1 } ,
- color .value_required:n = true ,
borders .clist_set:N = \l_@@_borders_clist ,
borders .value_required:n = true ,
hvlines .meta:n = { vlines , hlines } ,
@@ -12574,36 +12987,29 @@ version 2005/12/01 or later.
hlines .default:n = true ,
line-width .dim_set:N = \l_@@_line_width_dim ,
line-width .value_required:n = true ,
+% \end{macrocode}
+% Some keys have not a property |.value_required:n| (or similar) because they
+% are in |FirstPass|.
+% \begin{macrocode}
l .code:n = \str_set:Nn \l_@@_hpos_block_str l ,
- l .value_forbidden:n = true ,
r .code:n = \str_set:Nn \l_@@_hpos_block_str r ,
- r .value_forbidden:n = true ,
c .code:n = \str_set:Nn \l_@@_hpos_block_str c ,
- c .value_forbidden:n = true ,
L .code:n = \str_set:Nn \l_@@_hpos_block_str l
\bool_set_true:N \l_@@_hpos_of_block_cap_bool ,
- L .value_forbidden:n = true ,
R .code:n = \str_set:Nn \l_@@_hpos_block_str r
\bool_set_true:N \l_@@_hpos_of_block_cap_bool ,
- R .value_forbidden:n = true ,
C .code:n = \str_set:Nn \l_@@_hpos_block_str c
\bool_set_true:N \l_@@_hpos_of_block_cap_bool ,
- C .value_forbidden:n = true ,
t .code:n = \str_set:Nn \l_@@_vpos_of_block_str t ,
- t .value_forbidden:n = true ,
T .code:n = \str_set:Nn \l_@@_vpos_of_block_str T ,
- T .value_forbidden:n = true ,
b .code:n = \str_set:Nn \l_@@_vpos_of_block_str b ,
- b .value_forbidden:n = true ,
B .code:n = \str_set:Nn \l_@@_vpos_of_block_str B ,
- B .value_forbidden:n = true ,
v-center .code:n = \str_set:Nn \l_@@_vpos_of_block_str { c } ,
v-center .value_forbidden:n = true ,
name .tl_set:N = \l_@@_block_name_str ,
name .value_required:n = true ,
name .initial:n = ,
respect-arraystretch .bool_set:N = \l_@@_respect_arraystretch_bool ,
- respect-arraystretch .default:n = true ,
transparent .bool_set:N = \l_@@_transparent_bool ,
transparent .default:n = true ,
transparent .initial:n = false ,
@@ -12765,6 +13171,21 @@ version 2005/12/01 or later.
% \begin{macrocode}
\tl_if_empty:NF \l_@@_fill_tl
{
+ \tl_if_empty:NF \l_@@_opacity_tl
+ {
+ \tl_if_head_eq_meaning:nNTF \l_@@_fill_tl [
+ {
+ \tl_set:Nx \l_@@_fill_tl
+ {
+ [ opacity = \l_@@_opacity_tl ,
+ \tl_tail:V \l_@@_fill_tl
+ }
+ }
+ {
+ \tl_set:Nx \l_@@_fill_tl
+ { [ opacity = \l_@@_opacity_tl ] { \l_@@_fill_tl } }
+ }
+ }
\tl_gput_right:Nx \g_@@_pre_code_before_tl
{
\exp_not:N \roundedrectanglecolor
@@ -13005,14 +13426,17 @@ version 2005/12/01 or later.
% \end{macrocode}
% If we are in the first column, we must put the block as if it was with the key~|r|.
% \begin{macrocode}
- \int_compare:nNnT { #2 } = 0
- { \str_set:Nn \l_@@_hpos_block_str r }
+ \int_compare:nNnT { #2 } = 0 { \str_set:Nn \l_@@_hpos_block_str r }
+% \end{macrocode}
+% If we are in the last column, we must put the block as if it was with the key~|l|.
+% \begin{macrocode}
\bool_if:nT \g_@@_last_col_found_bool
{
\int_compare:nNnT { #2 } = \g_@@_col_total_int
{ \str_set:Nn \l_@@_hpos_block_str l }
}
% \end{macrocode}
+% |\l_tmpa_tl| will contain the anchor of the \textsc{pgf} node which will be used.
% \begin{macrocode}
\tl_set:Nx \l_tmpa_tl
{
@@ -13069,9 +13493,10 @@ version 2005/12/01 or later.
{ \box_use_drop:N \l_@@_cell_box } { } { }
}
% \end{macrocode}
-%
+% End of the case when |\l_@@_vpos_of_block_str| is equal to |c|, |T| or |B|.
+% Now, the other cases.
% \begin{macrocode}
- {
+ {
% \end{macrocode}
%
% \begin{macrocode}
@@ -13151,11 +13576,11 @@ version 2005/12/01 or later.
{ \CT@arc@ }
{ \@@_color:V \l_@@_draw_tl }
}
- \pgfsetcornersarced
+ \pgfsetcornersarced
{
\pgfpoint
- { \dim_use:N \l_@@_rounded_corners_dim }
- { \dim_use:N \l_@@_rounded_corners_dim }
+ { \l_@@_rounded_corners_dim }
+ { \l_@@_rounded_corners_dim }
}
\@@_cut_on_hyphen:w #2 \q_stop
\bool_lazy_and:nnT
@@ -13163,22 +13588,22 @@ version 2005/12/01 or later.
{ \int_compare_p:n { \l_tmpb_tl <= \c@jCol } }
{
\@@_qpoint:n { row - \l_tmpa_tl }
- \dim_set:Nn \l_tmpb_dim { \pgf@y }
+ \dim_set_eq:NN \l_tmpb_dim \pgf@y
\@@_qpoint:n { col - \l_tmpb_tl }
- \dim_set:Nn \l_@@_tmpc_dim { \pgf@x }
+ \dim_set_eq:NN \l_@@_tmpc_dim \pgf@x
\@@_cut_on_hyphen:w #3 \q_stop
\int_compare:nNnT \l_tmpa_tl > \c@iRow
{ \tl_set:Nx \l_tmpa_tl { \int_use:N \c@iRow } }
\int_compare:nNnT \l_tmpb_tl > \c@jCol
{ \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } }
\@@_qpoint:n { row - \int_eval:n { \l_tmpa_tl + 1 } }
- \dim_set:Nn \l_tmpa_dim { \pgf@y }
+ \dim_set_eq:NN \l_tmpa_dim \pgf@y
\@@_qpoint:n { col - \int_eval:n { \l_tmpb_tl + 1 } }
- \dim_set:Nn \l_@@_tmpd_dim { \pgf@x }
+ \dim_set_eq:NN \l_@@_tmpd_dim \pgf@x
+ \pgfsetlinewidth { 1.1 \l_@@_line_width_dim }
\pgfpathrectanglecorners
{ \pgfpoint \l_@@_tmpc_dim \l_tmpb_dim }
{ \pgfpoint \l_@@_tmpd_dim \l_tmpa_dim }
- \pgfsetlinewidth { 1.1 \l_@@_line_width_dim }
\dim_compare:nNnTF \l_@@_rounded_corners_dim = \c_zero_dim
{ \pgfusepathqstroke }
{ \pgfusepath { stroke } }
@@ -13252,7 +13677,7 @@ version 2005/12/01 or later.
position = ##1 ,
start = \l_@@_tmpd_tl ,
end = \int_eval:n { \l_tmpb_tl - 1 } ,
- total-width = \dim_use:N \l_@@_line_width_dim % added 2022-08-06
+ total-width = \dim_use:N \l_@@_line_width_dim
}
}
}
@@ -13405,6 +13830,7 @@ version 2005/12/01 or later.
\cs_new_protected:Npn \@@_block_tikz:nnnnn #1 #2 #3 #4 #5
{
\begin { tikzpicture }
+ \@@_clip_with_rounded_corners:
\clist_map_inline:nn { #5 }
{
\path [ ##1 ]
@@ -13702,6 +14128,7 @@ version 2005/12/01 or later.
delimiters / color .value_required:n = true ,
rules .code:n = \keys_set:nn { NiceMatrix / rules } { #1 } ,
rules .value_required:n = true ,
+ xdots .code:n = \keys_set:nn { NiceMatrix / xdots } { #1 } ,
unknown .code:n = \@@_error:n { Unknown~key~for~CodeAfter }
}
% \end{macrocode}
@@ -14863,15 +15290,15 @@ version 2005/12/01 or later.
% The boolean |\g_@@_footnotehyper_bool| will indicate if the option
% |footnotehyper| is used.
% \begin{macrocode}
-\bool_new:N \c_@@_footnotehyper_bool
+\bool_new:N \g_@@_footnotehyper_bool
% \end{macrocode}
%
% \medskip
-% The boolean |\c_@@_footnote_bool| will indicate if the option |footnote| is
+% The boolean |\g_@@_footnote_bool| will indicate if the option |footnote| is
% used, but quicky, it will also be set to |true| if the option |footnotehyper|
% is used.
% \begin{macrocode}
-\bool_new:N \c_@@_footnote_bool
+\bool_new:N \g_@@_footnote_bool
% \end{macrocode}
%
% \begin{macrocode}
@@ -14900,10 +15327,10 @@ version 2005/12/01 or later.
renew-dots .value_forbidden:n = true ,
renew-matrix .code:n = \@@_renew_matrix: ,
renew-matrix .value_forbidden:n = true ,
- messages-for-Overleaf .bool_set:N = \c_@@_messages_for_Overleaf_bool ,
- footnote .bool_set:N = \c_@@_footnote_bool ,
- footnotehyper .bool_set:N = \c_@@_footnotehyper_bool ,
- no-test-for-array .bool_set:N = \c_@@_no_test_for_array_bool ,
+ messages-for-Overleaf .bool_set:N = \g_@@_messages_for_Overleaf_bool ,
+ footnote .bool_set:N = \g_@@_footnote_bool ,
+ footnotehyper .bool_set:N = \g_@@_footnotehyper_bool ,
+ no-test-for-array .bool_set:N = \g_@@_no_test_for_array_bool ,
no-test-for-array .default:n = true ,
unknown .code:n = \@@_error:n { Unknown~key~for~package }
}
@@ -14937,14 +15364,14 @@ version 2005/12/01 or later.
%
% \medskip
% \begin{macrocode}
-\bool_if:NT \c_@@_footnote_bool
+\bool_if:NT \g_@@_footnote_bool
{
% \end{macrocode}
% The class \cls{beamer} has its own system to extract footnotes and that's why
% we have nothing to do if \cls{beamer} is used.
% \begin{macrocode}
\IfClassLoadedTF { beamer }
- { \bool_set_false:N \c_@@_footnote_bool }
+ { \bool_set_false:N \g_@@_footnote_bool }
{
\IfPackageLoadedTF { footnotehyper }
{ \@@_error:n { footnote~with~footnotehyper~package } }
@@ -14954,24 +15381,24 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \begin{macrocode}
-\bool_if:NT \c_@@_footnotehyper_bool
+\bool_if:NT \g_@@_footnotehyper_bool
{
% \end{macrocode}
% The class \cls{beamer} has its own system to extract footnotes and that's why
% we have nothing to do if \cls{beamer} is used.
% \begin{macrocode}
\IfClassLoadedTF { beamer }
- { \bool_set_false:N \c_@@_footnote_bool }
+ { \bool_set_false:N \g_@@_footnote_bool }
{
\IfPackageLoadedTF { footnote }
{ \@@_error:n { footnotehyper~with~footnote~package } }
{ \usepackage { footnotehyper } }
}
- \bool_set_true:N \c_@@_footnote_bool
+ \bool_set_true:N \g_@@_footnote_bool
}
% \end{macrocode}
-% The flag |\c_@@_footnote_bool| is raised and so, we will only have to test
-% |\c_@@_footnote_bool| in order to know if we have to insert an environment
+% The flag |\g_@@_footnote_bool| is raised and so, we will only have to test
+% |\g_@@_footnote_bool| in order to know if we have to insert an environment
% |{savenotes}|.
%
% \bigskip
@@ -15004,7 +15431,7 @@ version 2005/12/01 or later.
% \section{Error messages of the package}
%
% \begin{macrocode}
-\bool_if:NTF \c_@@_messages_for_Overleaf_bool
+\bool_if:NTF \g_@@_messages_for_Overleaf_bool
{ \str_const:Nn \c_@@_available_keys_str { } }
{
\str_const:Nn \c_@@_available_keys_str
@@ -15078,6 +15505,15 @@ version 2005/12/01 or later.
{ ~Maybe~your~use~of~\token_to_str:N \Hdotsfor\ is~incorrect.}
}
% \end{macrocode}
+%
+% \begin{macrocode}
+\@@_msg_new:nn { hvlines,~rounded-corners~and~corners }
+ {
+ Incompatible~options.\\
+ You~should~not~use~'hvlines',~'rounded-corners'~and~'corners'~at~this~time.\\
+ The~output~will~not~be~reliable.
+ }
+% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { negative~weight }
@@ -15159,7 +15595,7 @@ version 2005/12/01 or later.
The~preamble~of~your~\@@_full_name_env:\ announces~\int_use:N
\g_@@_static_num_of_col_int\ columns~but~you~use~only~\int_use:N \c@jCol.\\
The~columns~you~did~not~used~won't~be~created.\\
- We~won't~have~similar~error~till~the~end~of~the~document.
+ You~won't~have~similar~error~till~the~end~of~the~document.
}
% \end{macrocode}
%
@@ -15546,7 +15982,7 @@ version 2005/12/01 or later.
The~name~'#1'~is~already~used~for~a~\token_to_str:N \SubMatrix\
in~this~\@@_full_name_env:.\\
This~key~will~be~ignored.\\
- \bool_if:NF \c_@@_messages_for_Overleaf_bool
+ \bool_if:NF \g_@@_messages_for_Overleaf_bool
{ For~a~list~of~the~names~already~used,~type~H~<return>. }
}
{
@@ -15626,7 +16062,7 @@ version 2005/12/01 or later.
\@@_msg_new:nn { last-col~non~empty~for~NiceMatrixOptions }
{
Erroneous~use.\\
- In~\NiceMatrixoptions,~you~must~use~the~key~
+ In~\token_to_str:N \NiceMatrixOptions,~you~must~use~the~key~
'last-col'~without~value.\\
However,~you~can~go~on~for~this~time~
(the~value~'\l_keys_value_tl'~will~be~ignored).
@@ -15844,8 +16280,8 @@ version 2005/12/01 or later.
}
{
The~available~keys~are~(in~alphabetic~order):~b,~B,~borders,~c,~draw,~fill,~
- hlines,~hvlines,~l,~line-width,~name,~rounded-corners,~r,~respect-arraystretch,~
- t,~T,~tikz,~transparent~and~vlines.
+ hlines,~hvlines,~l,~line-width,~name,~opacity,~rounded-corners,~r,~
+ respect-arraystretch,~t,~T,~tikz,~transparent~and~vlines.
}
% \end{macrocode}
%
@@ -16231,7 +16667,7 @@ version 2005/12/01 or later.
if~you~use~'columns-width=auto'.~If~you~don't~want~to~see~this~
message~again,~use~the~key~'allow-duplicate-names'~in~
'\token_to_str:N \NiceMatrixOptions'.\\
- \bool_if:NF \c_@@_messages_for_Overleaf_bool
+ \bool_if:NF \g_@@_messages_for_Overleaf_bool
{ For~a~list~of~the~names~already~used,~type~H~<return>. }
}
{