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.dtx87
1 files changed, 60 insertions, 27 deletions
diff --git a/macros/latex/contrib/nicematrix/nicematrix-code.dtx b/macros/latex/contrib/nicematrix/nicematrix-code.dtx
index 07b6fe8513..86e54a5643 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.20}
-\def\myfiledate{2023/06/04}
+\def\myfileversion{6.20a}
+\def\myfiledate{2023/06/30}
%
%
%<*batchfile>
@@ -801,11 +801,11 @@ version 2005/12/01 or later.
% \bigskip
% The following token list will contain the type of horizontal alignment of the
% current cell as provided by the corresponding column. The possible values are
-% |r|, |l|, |c|. For example, a column |p[l]{3cm}| will provide the value |l|
-% for all the cells of the column.
+% |r|, |l|, |c| and |j|. For example, a column |p[l]{3cm}| will provide the
+% value |l| for all the cells of the column.
% \begin{macrocode}
\str_new:N \l_@@_hpos_cell_str
-\str_set:Nn \l_@@_hpos_cell_str { c }
+\str_set:Nn \l_@@_hpos_cell_str { c }
% \end{macrocode}
%
% \bigskip
@@ -1779,7 +1779,8 @@ version 2005/12/01 or later.
% sequence of successive commands |\tabularnote| and we have to format the
% labels of these tabular notes (in the array). We compose those labels in a box
% |\l_tmpa_box| because we will do a special construction in order to have this
-% box in an overlapping position if we are at the end of a cell.
+% box in an overlapping position if we are at the end of a cell when
+% |\l_@@_hpos_cell_str| is equal to |c| or |r|.
% \begin{macrocode}
\hbox_set:Nn \l_tmpa_box
{
@@ -1802,14 +1803,20 @@ version 2005/12/01 or later.
\int_compare:nNnT \l_tmpa_int = \c@tabularnote
{ \int_gincr:N \c@tabularnote }
\seq_clear:N \l_@@_notes_labels_seq
- \hbox_overlap_right:n { \box_use:N \l_tmpa_box }
+ \bool_lazy_or:nnTF
+ { \str_if_eq_p:Vn \l_@@_hpos_cell_str { c } }
+ { \str_if_eq_p:Vn \l_@@_hpos_cell_str { r } }
+ {
+ \hbox_overlap_right:n { \box_use:N \l_tmpa_box }
% \end{macrocode}
% If the command |\tabularnote| is used exactly at the end of the cell, the
% |\unskip| (inserted by \pkg{array}?) will delete the skip we insert now
% and the label of the footnote will be composed in an overlapping position (by
% design).
% \begin{macrocode}
- \skip_horizontal:n { \box_wd:N \l_tmpa_box }
+ \skip_horizontal:n { \box_wd:N \l_tmpa_box }
+ }
+ { \box_use:N \l_tmpa_box }
}
}
% \end{macrocode}
@@ -2430,7 +2437,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\legacy_if:nF { measuring@ }
{
- \str_set:Nn \l_tmpa_str { #1 }
+ \str_set:Nx \l_tmpa_str { #1 }
\seq_if_in:NVTF \g_@@_names_seq \l_tmpa_str
{ \@@_error:nn { Duplicate~name } { #1 } }
{ \seq_gput_left:NV \g_@@_names_seq \l_tmpa_str }
@@ -3501,16 +3508,15 @@ version 2005/12/01 or later.
% 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,
% we have now that information because it has been written in the |aux| file at
-% a previous run. We use that information to start couting the tabular notes in
-% the main array at the right value (that remember that the caption will be
+% a previous run. We use that information to start counting the tabular notes in
+% the main array at the right value (we remember that the caption will be
% composed \emph{after} the array!).
% \begin{macrocode}
\tl_if_exist:NT \l_@@_note_in_caption_tl
{
\tl_if_empty:NF \l_@@_note_in_caption_tl
{
- \int_gset_eq:NN \g_@@_notes_caption_int
- { \l_@@_note_in_caption_tl }
+ \int_gset_eq:NN \g_@@_notes_caption_int \l_@@_note_in_caption_tl
\int_gset:Nn \c@tabularnote { \l_@@_note_in_caption_tl }
}
}
@@ -4810,7 +4816,7 @@ version 2005/12/01 or later.
{
position = \int_eval:n { \c@jCol + 1 } ,
multiplicity = \int_use:N \l_tmpa_int ,
- total-width = \dim_use:N \l_tmpa_dim % added 2022-08-06
+ total-width = \dim_use:N \l_tmpa_dim
}
% \end{macrocode}
% We don't have provided value for |start| nor for |end|, which means that the
@@ -4961,7 +4967,7 @@ version 2005/12/01 or later.
% will provide the horizontal alignment of the column to which belongs the cell.
% \begin{macrocode}
\str_if_eq:VnTF \l_@@_hpos_col_str j
- { \str_set:Nn \exp_not:N \l_@@_hpos_cell_str { c } }
+ { \str_set:Nn \exp_not:N \l_@@_hpos_cell_str { } }
{
\str_set:Nn \exp_not:N \l_@@_hpos_cell_str
{ \str_lowercase:V \l_@@_hpos_col_str }
@@ -6088,6 +6094,21 @@ version 2005/12/01 or later.
{ \caption }
{ \caption [ \l_@@_short_caption_tl ] }
{ \l_@@_caption_tl }
+% \end{macrocode}
+% In some circonstancies (in particular when the package \pkg{caption} is
+% loaded), the caption is composed several times. That's why, when the same
+% tabular note is encountered (in the caption!), we consider that you are in the
+% second compilation and you can give to |\g_@@_notes_caption_int| its final
+% value, which is the number of tabular notes in the caption. But sometimes, the
+% caption is composed only once. In that case, we fix the value of
+% |\g_@@_caption_finished_bool| now.
+% \begin{macrocode}
+ \bool_if:NF \g_@@_caption_finished_bool % added 2023/06/30
+ {
+ \bool_gset_true:N \g_@@_caption_finished_bool
+ \int_gset_eq:NN \g_@@_notes_caption_int \c@tabularnote
+ \int_gzero:N \c@tabularnote
+ }
\tl_if_empty:NF \l_@@_label_tl { \label { \l_@@_label_tl } }
\group_end:
}
@@ -6857,7 +6878,7 @@ version 2005/12/01 or later.
>
{
% \end{macrocode}
-% At the beginning of the cell, we link |\CodeAfter| to a command which do
+% At the beginning of the cell, we link |\CodeAfter| to a command which
% begins with |\\| (whereas the standard version of |\CodeAfter| begins does
% not).
% \begin{macrocode}
@@ -6956,7 +6977,7 @@ version 2005/12/01 or later.
{
\NewDocumentEnvironment { #1 NiceArray } { }
{
- \bool_gset_false:N \g_@@_NiceArray_bool
+ \bool_gset_false:N \g_@@_NiceArray_bool
\str_if_empty:NT \g_@@_name_env_str
{ \str_gset:Nn \g_@@_name_env_str { #1 NiceArray } }
\@@_test_if_math_mode:
@@ -8308,14 +8329,17 @@ version 2005/12/01 or later.
% 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.
+% may be really encountered. That's why we do an adjustemnt for that case.
% \begin{macrocode}
\int_compare:nNnT \l_@@_last_col_int > { -2 }
{
\int_compare:nNnT \l_@@_initial_j_int = \g_@@_col_total_int
{
- \dim_set_eq:NN \l_tmpa_dim \l_@@_right_margin_dim
- \dim_add:Nn \l_tmpa_dim \l_@@_extra_right_margin_dim
+ \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
}
@@ -8607,9 +8631,9 @@ version 2005/12/01 or later.
}
\draw
[
- #1 ,
shorten~> = \l_@@_xdots_shorten_end_dim ,
shorten~< = \l_@@_xdots_shorten_start_dim ,
+ #1
]
( \l_@@_x_initial_dim , \l_@@_y_initial_dim )
% \end{macrocode}
@@ -9136,6 +9160,7 @@ version 2005/12/01 or later.
\tl_set_rescan:Nno \l_@@_argspec_tl { } \l_@@_argspec_tl
\exp_args:NNV \NewDocumentCommand \@@_Vdotsfor: \l_@@_argspec_tl
{
+ \bool_gset_true:N \g_@@_empty_cell_bool % added
\tl_gput_right:Nx \g_@@_HVdotsfor_lines_tl
{
\@@_Vdotsfor:nnnn
@@ -13287,8 +13312,8 @@ version 2005/12/01 or later.
%
%
%
-% We will extract the potential keys |columns-type|, |l|, |c|, |r| and pass
-% the other keys to the environment |{NiceArrayWithDelims}|.
+% We will extract some keys and pass the other keys to the environment
+% |{NiceArrayWithDelims}|.
% \begin{macrocode}
\keys_define:nn { NiceMatrix / Auto }
{
@@ -13321,6 +13346,11 @@ version 2005/12/01 or later.
% \begin{macrocode}
\group_begin:
\bool_set_true:N \l_@@_Matrix_bool
+ \str_if_eq:nnT { #1 } { . }
+ {
+ \str_if_eq:nnT { #2 } { . }
+ { \bool_set_false:N \l_@@_Matrix_bool }
+ }
\keys_set_known:nnN { NiceMatrix / Auto } { #6 } \l_tmpa_tl
% \end{macrocode}
% We nullify the command |\@@_transform_preamble:| because we will provide a
@@ -13363,13 +13393,14 @@ version 2005/12/01 or later.
\group_end:
}
% \end{macrocode}
+%
%
% \begin{macrocode}
\cs_set_protected:Npn \@@_define_com:nnn #1 #2 #3
{
\cs_set_protected:cpn { #1 AutoNiceMatrix }
{
- \bool_gset_false:N \g_@@_NiceArray_bool
+ \bool_gset_false:N \g_@@_NiceArray_bool
\str_gset:Nx \g_@@_name_env_str { #1 AutoNiceMatrix }
\AutoNiceMatrixWithDelims { #2 } { #3 }
}
@@ -13388,9 +13419,10 @@ version 2005/12/01 or later.
% We define also a command |\AutoNiceMatrix| similar to the environment |{NiceMatrix}|.
% \begin{macrocode}
\NewDocumentCommand \AutoNiceMatrix { O { } m O { } m ! O { } }
- {
+ {
\group_begin:
- \bool_gset_true:N \g_@@_NiceArray_bool
+ \bool_gset_true:N \g_@@_NiceArray_bool
+ % \bool_set_true:N \l_@@_Matrix_bool
\AutoNiceMatrixWithDelims . . { #2 } { #4 } [ #1 , #3 , #5 ]
\group_end:
}
@@ -16061,7 +16093,8 @@ 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'.\\
- \c_@@_available_keys_str
+ \bool_if:NF \c_@@_messages_for_Overleaf_bool
+ { For~a~list~of~the~names~already~used,~type~H~<return>. }
}
{
The~names~already~defined~in~this~document~are:~