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.dtx170
1 files changed, 125 insertions, 45 deletions
diff --git a/macros/latex/contrib/nicematrix/nicematrix-code.dtx b/macros/latex/contrib/nicematrix/nicematrix-code.dtx
index 6e883a8b82..d70404e997 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.25a}
-\def\myfiledate{2023/11/03}
+\def\myfileversion{6.25b}
+\def\myfiledate{2023/11/16}
%
%
%<*batchfile>
@@ -2294,7 +2294,7 @@ version 2005/12/01 or later.
% array).
% \begin{macrocode}
\tl_new:N \l_@@_baseline_tl
-\tl_set:Nn \l_@@_baseline_tl c
+\tl_set:Nn \l_@@_baseline_tl { c }
% \end{macrocode}
%
% \bigskip
@@ -3795,6 +3795,7 @@ version 2005/12/01 or later.
\cs_set_eq:NN \multicolumn \@@_multicolumn:nnn
\hook_gput_code:nnn { env / tabular / begin } { . }
{ \cs_set_eq:NN \multicolumn \@@_old_multicolumn }
+ \@@_revert_colortbl:
% \end{macrocode}
% If there is one or several commands |\tabularnote| in the caption specified
% by the key |caption| and if that caption has to be composed above the tabular,
@@ -4027,7 +4028,10 @@ version 2005/12/01 or later.
% \begin{macrocode}
\cs_new_protected_nopar:Npn \@@_CodeBefore_Body:w #1 \Body
{
- \tl_gput_left:Nn \g_@@_pre_code_before_tl { #1 }
+ \tl_set:Nn \l_tmpa_tl { #1 }
+ \int_compare:nNnT { \char_value_catcode:n { 60 } } = { 13 }
+ { \@@_rescan_for_spanish:N \l_tmpa_tl }
+ \tl_gput_left:NV \g_@@_pre_code_before_tl \l_tmpa_tl
\bool_set_true:N \l_@@_code_before_bool
% \end{macrocode}
% We go on with |\@@_pre_array:| which will (among other) execute the
@@ -4040,6 +4044,7 @@ version 2005/12/01 or later.
% \end{macrocode}
%
%
+%
% \bigskip
% \section{The \textbackslash CodeBefore}
%
@@ -4156,11 +4161,8 @@ version 2005/12/01 or later.
% \textsc{ascci} 60) and |>| are activated and Tikz is not able to solve the
% problem (even with the Tikz library \pkg{babel}).
% \begin{macrocode}
- \int_compare:nNnT { \char_value_catcode:n { 60 } } = { 13 }
- {
- \@@_rescan_for_spanish:N \g_@@_pre_code_before_tl
- \@@_rescan_for_spanish:N \l_@@_code_before_tl
- }
+ \int_compare:nNnT { \char_value_catcode:n { 60 } } = { 13 }
+ { \@@_rescan_for_spanish:N \l_@@_code_before_tl }
% \end{macrocode}
%
% Here is the |\CodeBefore|. The construction is a bit complicated because
@@ -5951,7 +5953,8 @@ version 2005/12/01 or later.
\multispan { #1 }
\cs_set_eq:NN \@@_update_max_cell_width: \prg_do_nothing: % added 2023-10-04
\begingroup
- \cs_set:Npn \@addamp { \if@firstamp \@firstampfalse \else \@preamerr 5 \fi }
+ \cs_set:Npn \@addamp
+ { \legacy_if:nTF { @firstamp } { \@firstampfalse } { \@preamerr 5 } }
% \end{macrocode}
%
% \medskip
@@ -7049,6 +7052,7 @@ version 2005/12/01 or later.
\hbox_overlap_right:n
{
\skip_horizontal:N \g_@@_width_last_col_dim
+ \skip_horizontal:N \col@sep % added 2023-11-05
\bool_if:NT \l_@@_code_before_bool
{
\pgfsys@markposition
@@ -9880,6 +9884,47 @@ version 2005/12/01 or later.
% \bigskip
% \section{The command \textbackslash RowStyle}
%
+%
+% |\g_@@_row_style_tl| may contain several instructions of the form:
+%
+% \qquad |\@@_if_row_less_than:nn { number } { instructions }|
+%
+% \smallskip
+% Then, |\g_@@_row_style_tl| will be inserted in all the cells of the array (and
+% also in both components of a |\diagbox| in a cell of in a mono-row block).
+%
+% The test |\@@_if_row_less_then:nn| ensures that the instructions are inserted
+% only if you are in a row which is (still) in the scope of that instructions
+% (which depends on the value of the key |nb-rows| of |\RowStyle|).
+%
+% That test will be active even in an expandable context because
+% |\@@_if_row_less_then:nn| is \emph{not} protected.
+%
+% |#1| is the first row \emph{after} the scope of the instructions in |#2|
+% \begin{macrocode}
+\cs_new:Npn \@@_if_row_less_than:nn #1 #2
+ { \int_compare:nNnT { \int_use:N \c@iRow } < { #1 } { #2 } }
+% \end{macrocode}
+%
+% \bigskip
+% |\@@_put_in_row_style| will be used several times by |\RowStyle|.
+% \begin{macrocode}
+\cs_set_protected:Npn \@@_put_in_row_style:n #1
+ {
+ \tl_gput_right:Nx \g_@@_row_style_tl
+ {
+% \end{macrocode}
+% Be careful, |\exp_not:N \@@_if_row_less_than:nn| can't be replaced by a
+% protected version of |\@@_if_row_less_than:nn|.
+% \begin{macrocode}
+ \exp_not:N
+ \@@_if_row_less_than:nn
+ { \int_eval:n { \c@iRow + \l_@@_key_nb_rows_int } }
+ { \exp_not:n { #1 } }
+ }
+ }
+\cs_generate_variant:Nn \@@_put_in_row_style:n { e }
+% \end{macrocode}
% \medskip
% \begin{macrocode}
\keys_define:nn { NiceMatrix / RowStyle }
@@ -9954,21 +9999,21 @@ version 2005/12/01 or later.
}
}
}
- \tl_gput_right:Nn \g_@@_row_style_tl { \ifnum \c@iRow < }
- \tl_gput_right:Nx \g_@@_row_style_tl
- { \int_eval:n { \c@iRow + \l_@@_key_nb_rows_int } }
- \tl_gput_right:Nn \g_@@_row_style_tl { #2 }
+ \@@_put_in_row_style:n { \exp_not:n { #2 } }
% \end{macrocode}
% |\l_tmpa_dim| is the value of the key |cell-space-top-limit| of |\RowStyle|.
% \begin{macrocode}
\dim_compare:nNnT \l_tmpa_dim > \c_zero_dim
{
- \tl_gput_right:Nx \g_@@_row_style_tl
+ \@@_put_in_row_style:n
{
- \tl_gput_right:Nn \exp_not:N \g_@@_cell_after_hook_tl
- {
- \dim_set:Nn \l_@@_cell_space_top_limit_dim
- { \dim_use:N \l_tmpa_dim }
+ \exp_not:n
+ {
+ \tl_gput_right:Nn \g_@@_cell_after_hook_tl
+ {
+ \dim_set:Nn \l_@@_cell_space_top_limit_dim
+ { \dim_use:N \l_tmpa_dim }
+ }
}
}
}
@@ -9977,12 +10022,15 @@ version 2005/12/01 or later.
% \begin{macrocode}
\dim_compare:nNnT \l_tmpb_dim > \c_zero_dim
{
- \tl_gput_right:Nx \g_@@_row_style_tl
+ \@@_put_in_row_style:n
{
- \tl_gput_right:Nn \exp_not:N \g_@@_cell_after_hook_tl
- {
- \dim_set:Nn \l_@@_cell_space_bottom_limit_dim
- { \dim_use:N \l_tmpb_dim }
+ \exp_not:n
+ {
+ \tl_gput_right:Nn \g_@@_cell_after_hook_tl
+ {
+ \dim_set:Nn \l_@@_cell_space_bottom_limit_dim
+ { \dim_use:N \l_tmpb_dim }
+ }
}
}
}
@@ -9991,7 +10039,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\tl_if_empty:NF \l_@@_color_tl
{
- \tl_gput_right:Nx \g_@@_row_style_tl
+ \@@_put_in_row_style:e
{
\mode_leave_vertical:
\@@_color:n { \l_@@_color_tl }
@@ -10002,24 +10050,27 @@ version 2005/12/01 or later.
% \begin{macrocode}
\bool_if:NT \l_tmpa_bool
{
- \tl_gput_right:Nn \g_@@_row_style_tl
+ \@@_put_in_row_style:n
{
- \if_mode_math:
- \c_math_toggle_token
- \bfseries \boldmath
- \c_math_toggle_token
- \else:
- \bfseries \boldmath
- \fi:
+ \exp_not:n
+ {
+ \if_mode_math:
+ \c_math_toggle_token
+ \bfseries \boldmath
+ \c_math_toggle_token
+ \else:
+ \bfseries \boldmath
+ \fi:
+ }
}
}
- \tl_gput_right:Nn \g_@@_row_style_tl { \fi }
\group_end:
\g_@@_row_style_tl
\ignorespaces
}
% \end{macrocode}
%
+%
% \bigskip
% \section{Colors of cells, rows and columns}
%
@@ -10578,8 +10629,8 @@ version 2005/12/01 or later.
{ \tl_if_blank_p:V \l_tmpb_tl }
{ \str_if_eq_p:Vn \l_tmpb_tl { * } }
{ \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } }
- \int_compare:nNnT \l_tmpb_tl > \c@jCol
- { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } }
+ \int_compare:nNnT \l_tmpb_tl > \g_@@_col_total_int
+ { \tl_set:Nx \l_tmpb_tl { \int_use:N \g_@@_col_total_int } }
% \end{macrocode}
% |\l_@@_tmpc_tl| will contain the number of column.
% \begin{macrocode}
@@ -10608,8 +10659,8 @@ version 2005/12/01 or later.
\tl_if_empty:NT \l_tmpa_tl { \tl_set:Nn \l_tmpa_tl { 1 } }
\tl_if_empty:NT \l_tmpb_tl
{ \tl_set:Nx \l_tmpb_tl { \int_use:N \c@iRow } }
- \int_compare:nNnT \l_tmpb_tl > \c@iRow
- { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@iRow } }
+ \int_compare:nNnT \l_tmpb_tl > \g_@@_row_total_int
+ { \tl_set:Nx \l_tmpb_tl { \int_use:N \g_@@_row_total_int } }
% \end{macrocode}
% Now, the numbers of both rows are in |\l_tmpa_tl| and |\l_tmpb_tl|.
% \begin{macrocode}
@@ -10858,6 +10909,26 @@ version 2005/12/01 or later.
% \end{macrocode}
%
%
+% \bigskip
+% \begin{macrocode}
+\hook_gput_code:nnn { begindocument } { . }
+ {
+ \IfPackageLoadedTF { colortbl }
+ {
+ \cs_set_eq:NN \@@_old_cellcolor \cellcolor
+ \cs_set_eq:NN \@@_old_rowcolor \rowcolor
+ \cs_new_protected:Npn \@@_revert_colortbl:
+ {
+ \hook_gput_code:nnn { env / tabular / begin } { . }
+ {
+ \cs_set_eq:NN \cellcolor \@@_old_cellcolor
+ \cs_set_eq:NN \rowcolor \@@_old_rowcolor
+ }
+ }
+ }
+ { \cs_new_protected:Npn \@@_revert_colortbl: { } }
+ }
+% \end{macrocode}
%
% \bigskip
% \section{The vertical and horizontal rules}
@@ -12840,15 +12911,15 @@ version 2005/12/01 or later.
{ \int_use:N \c@jCol }
{ \int_eval:n { \c@iRow + #1 - 1 } }
{ \int_eval:n { \c@jCol + #2 - 1 } }
- { \exp_not:n { ##1 } }
- { \exp_not:n { ##2 } }
+ { \g_@@_row_style_tl \exp_not:n { ##1 } }
+ { \g_@@_row_style_tl \exp_not:n { ##2 } }
}
}
\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
+% \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!
@@ -14296,8 +14367,17 @@ version 2005/12/01 or later.
{ \int_use:N \c@jCol }
{ \int_use:N \c@iRow }
{ \int_use:N \c@jCol }
- { \exp_not:n { #1 } }
- { \exp_not:n { #2 } }
+% \end{macrocode}
+% |\g_@@_row_style_tl| contains several instructions of the form:
+%
+% \qquad |\@@_if_row_less_than:nn { number } { instructions }|
+%
+% The command |\@@_if_row_less:nn| is fully expandable and, thus, the
+% instructions will be inserted in the |\g_@@_pre_code_after_tl| only if
+% |\diagbox| is used in a row which is the scope of that chunck of instructions.
+% \begin{macrocode}
+ { \g_@@_row_style_tl \exp_not:n { #1 } }
+ { \g_@@_row_style_tl \exp_not:n { #2 } }
}
% \end{macrocode}
% We put the cell with |\diagbox| in the sequence |\g_@@_pos_of_blocks_seq|
@@ -16448,6 +16528,7 @@ version 2005/12/01 or later.
Block~too~large.\\
You~try~to~draw~a~block~in~the~cell~#1-#2~of~your~matrix~but~the~matrix~is~
too~small~for~that~block. \\
+ This~block~and~maybe~others~will~be~ignored.
}
% \end{macrocode}
%
@@ -16459,8 +16540,7 @@ version 2005/12/01 or later.
\g_@@_static_num_of_col_int\
columns~but~you~use~only~\int_use:N \c@jCol\ and~that's~why~a~block~
specified~in~the~cell~#1-#2~can't~be~drawn.~You~should~add~some~ampersands~
- (&)~at~the~end~of~the~first~row~of~your~
- \@@_full_name_env:.\\
+ (&)~at~the~end~of~the~first~row~of~your~\@@_full_name_env:.\\
This~block~and~maybe~others~will~be~ignored.
}
% \end{macrocode}