diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/nicematrix/nicematrix-code.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/nicematrix/nicematrix-code.dtx | 225 |
1 files changed, 154 insertions, 71 deletions
diff --git a/Master/texmf-dist/source/latex/nicematrix/nicematrix-code.dtx b/Master/texmf-dist/source/latex/nicematrix/nicematrix-code.dtx index 059c4b2ca6c..05251bd9cd5 100644 --- a/Master/texmf-dist/source/latex/nicematrix/nicematrix-code.dtx +++ b/Master/texmf-dist/source/latex/nicematrix/nicematrix-code.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -% This file should be compiled with $xelatex$. +% This file should be compiled with $lualatex$. % % Copyright (C) 2018-2024 by F. Pantigny % ------------------------------------------ @@ -17,8 +17,8 @@ % % \fi % \iffalse -\def\myfileversion{6.28} -\def\myfiledate{2024/05/29} +\def\myfileversion{6.28b} +\def\myfiledate{2024/06/29} % % %<*batchfile> @@ -155,9 +155,11 @@ version 2005/12/01 or later. % In the version 2.6a of \pkg{array}, important modifications have been done for % the Tagging Project. % \begin{macrocode} -\bool_const:Nn \c_@@_tagging_array_bool { \cs_if_exist_p:N \ar@ialign } +\bool_const:Nn \c_@@_tagging_array_bool + { \IfPackageAtLeastTF { array } { 2024/05/01 } \c_true_bool \c_false_bool } \bool_const:Nn \c_@@_testphase_table_bool - { \IfPackageLoadedTF { latex-lab-testphase-table } \c_true_bool \c_false_bool } + { \IfPackageLoadedTF { latex-lab-testphase-table } \c_true_bool \c_false_bool + } % \end{macrocode} % % @@ -287,19 +289,27 @@ version 2005/12/01 or later. % % \bigskip % \begin{macrocode} -\cs_new_protected:Npn \@@_security_test_i:w \ignorespaces #1 +\bool_if:NTF \c_@@_tagging_array_bool { - \peek_meaning:NF \unskip { \@@_error:n { Internal~error } } - #1 + \cs_new_protected:Npn \@@_security_test_i:w \ignorespaces #1 + { + \peek_meaning:NF \textonly@unskip { \@@_error:n { Internal~error } } + #1 + } + } + { + \cs_new_protected:Npn \@@_security_test_i:w \ignorespaces #1 + { + \peek_meaning:NF \unskip { \@@_error:n { Internal~error } } + #1 + } } % \end{macrocode} % % \bigskip % Here, the box |\l_tmpa_box| will be used as sandbox to take our security test. -% This code has been modified in version 6.18 (see question 682891 on TeX -% StackExchange). % \begin{macrocode} -\hook_gput_code:nnn { begindocument / after } { . } +\hook_gput_code:nnn { begindocument / end } { . } { \IfPackageLoadedTF { mdwtab } { \@@_fatal:n { mdwtab~loaded } } @@ -385,6 +395,7 @@ version 2005/12/01 or later. \tl_const:Nn \c_@@_dot_tl { . } \tl_const:Nn \c_@@_default_tl { default } \tl_const:Nn \c_@@_star_tl { * } +\str_const:Nn \c_@@_star_str { * } \str_const:Nn \c_@@_r_str { r } \str_const:Nn \c_@@_c_str { c } \str_const:Nn \c_@@_l_str { l } @@ -1489,10 +1500,11 @@ version 2005/12/01 or later. % \end{macrocode} % % \medskip -% For the vertical position, the possible values are |c|, |t| and |b|. +% For the vertical position, the possible values are |c|, |t|, |b|, |T| and |B| +% (but |\l_@@_vpos_block_str| will remain empty if the user doesn't use a key +% for the vertical position). % \begin{macrocode} \str_new:N \l_@@_vpos_block_str -\str_set:Nn \l_@@_vpos_block_str { c } % \end{macrocode} % % @@ -1765,6 +1777,14 @@ version 2005/12/01 or later. \newcounter { tabularnote } % \end{macrocode} % +% We want to avoid error messages for duplicate labels when the package +% \pkg{hyperref} is used. That's why we will count all the tabular notes of the +% whole document with |\g_@@_tabularnote_int|. +% \begin{macrocode} +\int_new:N \g_@@_tabularnote_int +\cs_set:Npn \theHtabularnote { \int_use:N \g_@@_tabularnote_int } +% \end{macrocode} +% % \begin{macrocode} \seq_new:N \g_@@_notes_seq \seq_new:N \g_@@_notes_in_caption_seq @@ -1990,7 +2010,12 @@ version 2005/12/01 or later. % \begin{macrocode} \int_gdecr:N \c@tabularnote \int_set_eq:NN \l_tmpa_int \c@tabularnote - \refstepcounter { tabularnote } +% \end{macrocode} +% The following line is only to avoid error messages for multipy defined labels +% when the package \pkg{hyperref} is used. +% \begin{macrocode} + \int_gincr:N \g_@@_tabularnote_int + \refstepcounter { tabularnote } \int_compare:nNnT \l_tmpa_int = \c@tabularnote { \int_gincr:N \c@tabularnote } \seq_clear:N \l_@@_notes_labels_seq @@ -2504,6 +2529,7 @@ version 2005/12/01 or later. { ampersand-in-blocks .bool_set:N = \l_@@_amp_in_blocks_bool , ampersand-in-blocks .default:n = true , + &-in-blocks .meta:n = ampersand-in-blocks , no-cell-nodes .code:n = \cs_set_protected:Npn \@@_node_for_cell: { \box_use_drop:N \l_@@_cell_box } , @@ -5416,22 +5442,12 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% % \begin{macrocode} \str_new:N \c_@@_ignorespaces_str \str_set:Nx \c_@@_ignorespaces_str { \ignorespaces } \str_remove_all:Nn \c_@@_ignorespaces_str { ~ } -% \end{macrocode} -% -% \bigskip -% In order to test whether a cell is empty, we test whether it begins by -% |\ignorespaces\unskip|. However, in some circunstancies, for example when -% |\collectcell| of \pkg{collcell} is used, the cell does not begin with -% |\ignorespaces|. In that case, we consider as not empty... -% -% First, we test if the next token is |\ignorespaces| and it's not very easy... -% \begin{macrocode} -\cs_new_protected:Npn \@@_test_if_empty: { \peek_after:Nw \@@_test_if_empty_i: } +\cs_new_protected:Npn \@@_test_if_empty: + { \peek_after:Nw \@@_test_if_empty_i: } \cs_new_protected:Npn \@@_test_if_empty_i: { \str_set:Nx \l_tmpa_str { \token_to_meaning:N \l_peek_token } @@ -5439,17 +5455,40 @@ version 2005/12/01 or later. { \@@_test_if_empty:w } } \cs_new_protected:Npn \@@_test_if_empty:w \ignorespaces - { - \peek_meaning:NT \unskip - { - \tl_gput_right:Nn \g_@@_cell_after_hook_tl - { - \box_set_wd:Nn \l_@@_cell_box \c_zero_dim - \skip_horizontal:N \l_@@_col_width_dim - } + { \peek_after:Nw \@@_test_if_empty_ii: } +% \end{macrocode} +% +% \bigskip +% \begin{macrocode} +\cs_new_protected:Npn \@@_nullify_cell: + { + \tl_gput_right:Nn \g_@@_cell_after_hook_tl + { + \box_set_wd:Nn \l_@@_cell_box \c_zero_dim + \skip_horizontal:N \l_@@_col_width_dim } } % \end{macrocode} +% +% \bigskip +% \begin{macrocode} +\bool_if:NTF \c_@@_tagging_array_bool + { + \cs_new_protected:Npn \@@_test_if_empty_ii: + { \peek_meaning:NT \textonly@unskip \@@_nullify_cell: } + } +% \end{macrocode} +% In the old version of \pkg{array}, we test whether it begins by +% |\ignorespaces\unskip|. However, in some circunstancies, for example when +% |\collectcell| of \pkg{collcell} is used, the cell does not begin with +% |\ignorespaces|. In that case, we consider as not empty... +% First, we test if the next token is |\ignorespaces| and it's not very easy... +% \begin{macrocode} + { + \cs_new_protected:Npn \@@_test_if_empty_ii: + { \peek_meaning:NT \unskip \@@_nullify_cell: } + } +% \end{macrocode} % % % \begin{macrocode} @@ -6769,7 +6808,7 @@ version 2005/12/01 or later. } } { - \@@_create_col_nodes: + \@@_create_col_nodes: \endarray } % \end{macrocode} @@ -6817,7 +6856,7 @@ version 2005/12/01 or later. % \begin{macrocode} { \@@_create_col_nodes: - \endarray + \endarray } % \end{macrocode} % @@ -7193,7 +7232,7 @@ version 2005/12/01 or later. \endpgfpicture } } - % \cr + % \cr } % \end{macrocode} % @@ -12984,6 +13023,9 @@ version 2005/12/01 or later. b .value_forbidden:n = true , B .code:n = \str_set:Nn \l_@@_vpos_block_str B , B .value_forbidden:n = true , + m .code:n = \str_set:Nn \l_@@_vpos_block_str c , + m .value_forbidden:n = true , + v-center .meta:n = m , p .code:n = \bool_set_true:N \l_@@_p_block_bool , p .value_forbidden:n = true , color .code:n = @@ -13071,12 +13113,12 @@ version 2005/12/01 or later. % \begin{macrocode} \bool_lazy_or:nnTF { \tl_if_blank_p:n { #1 } } - { \str_if_eq_p:nn { #1 } { * } } + { \str_if_eq_p:Vn \c_@@_star_str { #1 } } { \int_set:Nn \l_tmpa_int { 100 } } { \int_set:Nn \l_tmpa_int { #1 } } \bool_lazy_or:nnTF { \tl_if_blank_p:n { #2 } } - { \str_if_eq_p:nn { #2 } { * } } + { \str_if_eq_p:Vn \c_@@_star_str { #2 } } { \int_set:Nn \l_tmpb_int { 100 } } { \int_set:Nn \l_tmpb_int { #2 } } % \end{macrocode} @@ -13124,20 +13166,10 @@ version 2005/12/01 or later. \bool_set_false:N \l_tmpa_bool \bool_if:NT \l_@@_amp_in_blocks_bool { \tl_if_in:nnT { #5 } { & } { \bool_set_true:N \l_tmpa_bool } } - \bool_if:NTF \l_tmpa_bool - { \exp_args:Nee \@@_Block_vii:nnnnn } - { - \bool_if:NTF \l_@@_p_block_bool - { \exp_args:Nee \@@_Block_vi:nnnnn } - { - \bool_if:nTF - { - ( - \int_compare_p:nNn \l_tmpa_int = \c_one_int - || - \int_compare_p:nNn \l_tmpb_int = \c_one_int - ) - && ! \tl_if_empty_p:n { #5 } + \bool_case:nF + { + \l_tmpa_bool { \exp_args:Nee \@@_Block_vii:nnnnn } + \l_@@_p_block_bool { \exp_args:Nee \@@_Block_vi:nnnnn } % \end{macrocode} % For the blocks mono-column, we will compose right now in a box in order to % compute its width and take that width into account for the width of the @@ -13147,12 +13179,14 @@ version 2005/12/01 or later. % column, it's imperative. Otherwise, the process for the determination of the % widths of the columns will be wrong. % \begin{macrocode} - && ! \l_@@_X_bool - } - { \exp_args:Nee \@@_Block_iv:nnnnn } - { \exp_args:Nee \@@_Block_v:nnnnn } - } - } + \l_@@_X_bool { \exp_args:Nee \@@_Block_v:nnnnn } + { \tl_if_empty_p:n { #5 } } { \exp_args:Nee \@@_Block_v:nnnnn } + { \int_compare_p:nNn \l_tmpa_int = \c_one_int } + { \exp_args:Nee \@@_Block_iv:nnnnn } + { \int_compare_p:nNn \l_tmpb_int = \c_one_int } + { \exp_args:Nee \@@_Block_iv:nnnnn } + } + { \exp_args:Nee \@@_Block_v:nnnnn } { \l_tmpa_int } { \l_tmpb_int } { #3 } { #4 } { #5 } } % \end{macrocode} @@ -13265,7 +13299,7 @@ version 2005/12/01 or later. { ! \g_@@_rotate_bool } } % \end{macrocode} -% When the block is mono-column in a column with a fixed width (eg |p{3cm}|), we +% When the block is mono-column in a column with a fixed width (e.g. |p{3cm}|), we % use a |{minipage}|. % \begin{macrocode} { @@ -13339,9 +13373,16 @@ version 2005/12/01 or later. } % \end{macrocode} % If we are in a mono-row block we take into account the height and the depth of -% that block for the height and the depth of the row. +% that block for the height and the depth of the row, excepted when the block +% uses explicitely an option of vertical position. % \begin{macrocode} - \int_compare:nNnT { #1 } = \c_one_int + \bool_lazy_and:nnT + { \int_compare_p:nNn { #1 } = \c_one_int } +% \end{macrocode} +% If the user has not used a key for the vertical position of the block, then +% |\l_@@_vpos_block_str| remains empty. +% \begin{macrocode} + { \str_if_empty_p:N \l_@@_vpos_block_str } { \dim_gset:Nn \g_@@_blocks_ht_dim { @@ -13384,7 +13425,6 @@ version 2005/12/01 or later. { m } { \int_compare:nNnT \c@iRow = \l_@@_last_row_int T } } - } { \box_use_drop:c @@ -13576,6 +13616,9 @@ version 2005/12/01 or later. % \begin{macrocode} \keys_define:nn { NiceMatrix / Block / SecondPass } { + ampersand-in-blocks .bool_set:N = \l_@@_amp_in_blocks_bool , + ampersand-in-blocks .default:n = true , + &-in-blocks .meta:n = ampersand-in-blocks , tikz .code:n = \IfPackageLoadedTF { tikz } { \seq_put_right:Nn \l_@@_tikz_seq { { #1 } } } @@ -13707,10 +13750,22 @@ version 2005/12/01 or later. { \int_compare:nNnTF \l_@@_last_row_int > \g_@@_row_total_int { \msg_error:nnnn { nicematrix } { Block~too~large~1 } { #1 } { #2 } } - { \@@_Block_v:nnnnnn { #1 } { #2 } { #3 } { #4 } { #5 } { #6 } } + { + \@@_Block_v:nnVVnn + { #1 } + { #2 } + \l_@@_last_row_int + \l_@@_last_col_int + { #5 } + { #6 } + } } } % \end{macrocode} +% +% \begin{macrocode} +\cs_generate_variant:Nn \@@_Block_v:nnnnnn { n n V V n n } +% \end{macrocode} % % % \medskip @@ -14172,13 +14227,15 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% Now, we will put the label of the block. +% Now, we will put the label of the block. We recall that |\l_@@_vpos_block_str| +% is empty when the user has not used a key for the vertical position of the block. % \begin{macrocode} \pgfpicture \pgfrememberpicturepositiononpagetrue \pgf@relevantforpicturesizefalse \bool_lazy_any:nTF { + { \str_if_empty_p:N \l_@@_vpos_block_str } % added 2024/06/29 { \str_if_eq_p:on \l_@@_vpos_block_str { c } } { \str_if_eq_p:on \l_@@_vpos_block_str { T } } { \str_if_eq_p:on \l_@@_vpos_block_str { B } } @@ -14206,6 +14263,19 @@ version 2005/12/01 or later. { \str_case:on \l_@@_vpos_block_str { +% \end{macrocode} +% We recall that |\l_@@_vpos_block_str| is empty when the user has not used a key +% for the vertical position of the block. +% \begin{macrocode} + { } { % added 2024-06-29 + \str_case:on \l_@@_hpos_block_str + { + c { center } + l { west } + r { east } + j { center } + } + } c { \str_case:on \l_@@_hpos_block_str { @@ -15656,6 +15726,7 @@ version 2005/12/01 or later. { \nullfont \c_math_toggle_token + \colorlet { current-color } { . } \@@_color:o \l_@@_delimiters_color_tl \left . \vcenter @@ -15667,7 +15738,7 @@ version 2005/12/01 or later. } \right #1 \tl_if_empty:nF { #3 } { _ { \smash { #3 } } } - ^ { \smash { #4 } } + ^ { \color { current-color } \smash { #4 } } \c_math_toggle_token } { #2 } @@ -15705,9 +15776,12 @@ version 2005/12/01 or later. { left-shorten .bool_set:N = \l_@@_brace_left_shorten_bool , left-shorten .default:n = true , + left-shorten .value_forbidden:n = true , right-shorten .bool_set:N = \l_@@_brace_right_shorten_bool , - shorten .meta:n = { left-shorten , right-shorten } , right-shorten .default:n = true , + right-shorten .value_forbidden:n = true , + shorten .meta:n = { left-shorten , right-shorten } , + shorten .value_forbidden:n = true , yshift .dim_set:N = \l_@@_brace_yshift_dim , yshift .value_required:n = true , yshift .initial:n = \c_zero_dim , @@ -16438,7 +16512,7 @@ version 2005/12/01 or later. ~you~try~to~use~more~columns~than~allowed~by~your~ \@@_full_name_env:.\@@_message_hdotsfor:\ The~maximal~number~of~columns~is~ \int_use:N \g_@@_static_num_of_col_int\ - ~(plus~the~potential~exterior~ones). + ~(plus~the~potential~exterior~ones).~ This~error~is~fatal. } % \end{macrocode} @@ -17211,9 +17285,10 @@ version 2005/12/01 or later. \c_@@_available_keys_str } { - The~available~keys~are~(in~alphabetic~order):~b,~B,~borders,~c,~draw,~fill,~ - hlines,~hvlines,~l,~line-width,~name,~opacity,~rounded-corners,~r,~ - respect-arraystretch,~t,~T,~tikz,~transparent~and~vlines. + The~available~keys~are~(in~alphabetic~order):~&-in-blocks,~ampersand-in-blocks,~ + b,~B,~borders,~c,~draw,~fill,~hlines,~hvlines,~l,~line-width,~name,~ + opacity,~rounded-corners,~r,~respect-arraystretch,~t,~T,~tikz,~transparent~ + and~vlines. } % \end{macrocode} % @@ -17347,7 +17422,9 @@ version 2005/12/01 or later. } { The~available~keys~are~(in~alphabetic~order):~ + &-in-blocks,~ allow-duplicate-names,~ + ampersand-in-blocks,~ caption-above,~ cell-space-bottom-limit,~ cell-space-limits,~ @@ -17405,6 +17482,8 @@ version 2005/12/01 or later. } { The~available~keys~are~(in~alphabetic~order):~ + &-in-blocks,~ + ampersand-in-blocks,~ b,~ baseline,~ c,~ @@ -17469,6 +17548,8 @@ version 2005/12/01 or later. } { The~available~keys~are~(in~alphabetic~order):~ + &-in-blocks,~ + ampersand-in-blocks,~ b,~ baseline,~ c,~ @@ -17532,6 +17613,8 @@ version 2005/12/01 or later. } { The~available~keys~are~(in~alphabetic~order):~ + &-in-blocks,~ + ampersand-in-blocks,~ b,~ baseline,~ c,~ |