diff options
Diffstat (limited to 'macros/latex/contrib/nicematrix/nicematrix-code.dtx')
-rw-r--r-- | macros/latex/contrib/nicematrix/nicematrix-code.dtx | 123 |
1 files changed, 76 insertions, 47 deletions
diff --git a/macros/latex/contrib/nicematrix/nicematrix-code.dtx b/macros/latex/contrib/nicematrix/nicematrix-code.dtx index 39677ce108..9a4e6cc863 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.22} -\def\myfiledate{2023/08/14} +\def\myfileversion{6.23} +\def\myfiledate{2023/09/02} % % %<*batchfile> @@ -331,6 +331,9 @@ version 2005/12/01 or later. % % the command |\G| takes in an arbitrary number of optional arguments between % square brackets. +% +% Be careful: that command is \emph{not} ``fully expandable'' (because of +% |\peek_meaning:NTF|). % % \bigskip % \begin{macrocode} @@ -4945,37 +4948,43 @@ version 2005/12/01 or later. { \str_if_eq:nnTF { #1 } | { \@@_patch_preamble_iii:n | } + { + \str_if_eq:nnTF { #1 } [ + { \@@_patch_preamble_iii_ii:nw { } [ } + { \@@_patch_preamble_iii_ii:nw { #1 } [ ] } + } + } +% \end{macrocode} +% +% \begin{macrocode} +\cs_new_protected:Npn \@@_patch_preamble_iii_ii:nw #1 [ #2 ] + { + \@@_compute_rule_width:n { multiplicity = \l_tmpa_int , #2 } + \tl_gput_right:Nx \g_@@_preamble_tl { - \dim_set:Nn \l_tmpa_dim - { - \arrayrulewidth * \l_tmpa_int - + \doublerulesep * ( \l_tmpa_int - 1) - } - \tl_gput_right:Nx \g_@@_preamble_tl - { % \end{macrocode} % Here, the command |\dim_eval:n| is mandatory. % \begin{macrocode} - \exp_not:N ! { \skip_horizontal:n { \dim_eval:n { \l_tmpa_dim } } } - } - \tl_gput_right:Nx \g_@@_pre_code_after_tl + \exp_not:N ! { \skip_horizontal:n { \dim_eval:n { \l_@@_rule_width_dim } } } + } + \tl_gput_right:Nx \g_@@_pre_code_after_tl + { + \@@_vline:n { - \@@_vline:n - { - position = \int_eval:n { \c@jCol + 1 } , - multiplicity = \int_use:N \l_tmpa_int , - total-width = \dim_use:N \l_tmpa_dim - } + position = \int_eval:n { \c@jCol + 1 } , + multiplicity = \int_use:N \l_tmpa_int , + total-width = \dim_use:N \l_@@_rule_width_dim , + #2 + } % \end{macrocode} % We don't have provided value for |start| nor for |end|, which means that the % rule will cover (potentially) all the rows of the array. % % \begin{macrocode} - } - \int_zero:N \l_tmpa_int - \str_if_eq:nnT { #1 } { \q_stop } { \bool_gset_true:N \g_tmpb_bool } - \@@_patch_preamble:n #1 } + \int_zero:N \l_tmpa_int + \str_if_eq:nnT { #1 } { \q_stop } { \bool_gset_true:N \g_tmpb_bool } + \@@_patch_preamble:n #1 } % \end{macrocode} % @@ -9405,7 +9414,12 @@ version 2005/12/01 or later. middle = \exp_not:n { #6 } } } - \prg_replicate:nn { #2 - 1 } { & \multicolumn { 1 } { c } { } } + \prg_replicate:nn { #2 - 1 } + { + & + \multicolumn { 1 } { c } { } + \cs_set_eq:NN \CodeAfter \@@_CodeAfter_i: % added 2023-08-26 + } } } % \end{macrocode} @@ -11350,7 +11364,7 @@ version 2005/12/01 or later. { \peek_meaning:NTF \Hline { \@@_Hline_ii:nn { #1 + 1 } } - { \@@_Hline_iii:n { #1 } } + { \@@_Hline_iii:n { #1 } } } } % \end{macrocode} @@ -11360,16 +11374,13 @@ version 2005/12/01 or later. % \end{macrocode} % % \begin{macrocode} -\cs_set:Npn \@@_Hline_iii:n #1 - { - \peek_meaning:NTF [ - { \@@_Hline_iv:nw { #1 } } - { \@@_Hline_iv:nw { #1 } [ ] } - } +\cs_set:Npn \@@_Hline_iii:n #1 + { \@@_collect_options:n { \@@_Hline_iv:nn { #1 } } } % \end{macrocode} +% % % \begin{macrocode} -\cs_set:Npn \@@_Hline_iv:nw #1 [ #2 ] +\cs_set:Npn \@@_Hline_iv:nn #1 #2 { \@@_compute_rule_width:n { multiplicity = #1 , #2 } \skip_vertical:n { \l_@@_rule_width_dim } @@ -11994,10 +12005,14 @@ version 2005/12/01 or later. \keys_set:nn { NiceMatrix / NiceMatrixBlock } { #1 } \bool_if:NT \l_@@_block_auto_columns_width_bool { - \cs_if_exist:cT { @@_max_cell_width_ \int_use:N \g_@@_NiceMatrixBlock_int } + \cs_if_exist:cT + { @@_max_cell_width_ \int_use:N \g_@@_NiceMatrixBlock_int } { - \exp_args:NNc \dim_set:Nn \l_@@_columns_width_dim - { @@_max_cell_width _ \int_use:N \g_@@_NiceMatrixBlock_int } + \exp_args:NNx \dim_set:Nn \l_@@_columns_width_dim + { + \use:c + { @@_max_cell_width _ \int_use:N \g_@@_NiceMatrixBlock_int } + } } } } @@ -12010,20 +12025,29 @@ version 2005/12/01 or later. % the counter |\l_@@_first_env_block_int|). % \begin{macrocode} { - \bool_if:NT \l_@@_block_auto_columns_width_bool + \legacy_if:nTF { measuring@ } +% \end{macrocode} +% If |{NiceMatrixBlock}| is used in an environment of \pkg{amsmath} such as +% |{align}|: cf. question 694957 on TeX StackExchange. The most important line +% in that case is the following one. +% \begin{macrocode} + { \int_gdecr:N \g_@@_NiceMatrixBlock_int } { - \iow_shipout:Nn \@mainaux \ExplSyntaxOn - \iow_shipout:Nx \@mainaux - { - \cs_gset:cpn - { @@ _ max _ cell _ width _ \int_use:N \g_@@_NiceMatrixBlock_int } + \bool_if:NT \l_@@_block_auto_columns_width_bool + { + \iow_shipout:Nn \@mainaux \ExplSyntaxOn + \iow_shipout:Nx \@mainaux + { + \cs_gset:cpn + { @@ _ max _ cell _ width _ \int_use:N \g_@@_NiceMatrixBlock_int } % \end{macrocode} % For technical reasons, we have to include the width of a potential rule on the % right side of the cells. % \begin{macrocode} - { \dim_eval:n { \g_@@_max_cell_width_dim + \arrayrulewidth } } + { \dim_eval:n { \g_@@_max_cell_width_dim + \arrayrulewidth } } + } + \iow_shipout:Nn \@mainaux \ExplSyntaxOff } - \iow_shipout:Nn \@mainaux \ExplSyntaxOff } \ignorespacesafterend } @@ -12434,8 +12458,6 @@ version 2005/12/01 or later. % |\NewExpandableDocumentCommand| because it has an optional argument between % |<| and |>|. It's mandatory to use an expandable command. % -% -% % \begin{macrocode} \cs_new_protected:Npn \@@_Block: { \@@_collect_options:n { \@@_Block_i: } } % \end{macrocode} @@ -13146,7 +13168,7 @@ version 2005/12/01 or later. \tl_gput_right:Nx \g_nicematrix_code_after_tl { \@@_stroke_block:nnn - { \exp_not:n { #5 } } + { \exp_not:n { #5 } } % #5 are the options { #1 - #2 } { \int_use:N \l_@@_last_row_int - \int_use:N \l_@@_last_col_int } } @@ -15314,7 +15336,7 @@ version 2005/12/01 or later. footnotehyper,~ messages-for-Overleaf,~ no-test-for-array,~ - renew-dots,~and + renew-dots,~and~ renew-matrix. } % \end{macrocode} @@ -15897,11 +15919,18 @@ version 2005/12/01 or later. % \end{macrocode} % % \begin{macrocode} -\@@_msg_new:nn { width~without~X~columns } +\@@_msg_new:nnn { width~without~X~columns } { You~have~used~the~key~'width'~but~you~have~put~no~'X'~column.~ That~key~will~be~ignored. } + { + This~message~is~the~message~'width~without~X~columns'~ + of~the~module~'nicematrix'.~ + The~experimented~users~can~disable~that~message~with~ + \token_to_str:N \msg_redirect_name:nnn.\\ + } + % \end{macrocode} % % \begin{macrocode} |