summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-10-06 21:58:56 +0000
committerKarl Berry <karl@freefriends.org>2020-10-06 21:58:56 +0000
commit42c9869fd0659b61892a63fc676663752227d4c3 (patch)
tree1f011eaaa8d8ea210a363e2c647171fff95b22e3 /Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
parent959bfd3e34f66df3f1392701684e2b04133ed6f9 (diff)
nicematrix (6oct20)
git-svn-id: svn://tug.org/texlive/trunk@56574 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty')
-rw-r--r--Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty451
1 files changed, 337 insertions, 114 deletions
diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
index ca4ab2c60d7..4801b011bbf 100644
--- a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
+++ b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
@@ -18,8 +18,8 @@
%% and version 1.3 or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
%%
-\def\myfileversion{5.3}
-\def\myfiledate{2020/09/03}
+\def\myfileversion{5.4}
+\def\myfiledate{2020/10/06}
\RequirePackage{pgfcore}
\usepgfmodule{shapes}
@@ -32,6 +32,18 @@
\RequirePackage { array }
\RequirePackage { amsmath }
\RequirePackage { xparse }
+\cs_set_eq:NN \box_use_drop_i:N \box_use_drop:N
+\cs_set_eq:NN \box_use_drop_ii:N \box_use_drop:N
+\cs_set_eq:NN \box_use_drop_iii:N \box_use_drop:N
+\cs_set_eq:NN \box_use_drop_iv:N \box_use_drop:N
+\cs_set_eq:NN \box_use_drop_v:N \box_use_drop:N
+\cs_set_eq:NN \box_use_drop_vi:N \box_use_drop:N
+\cs_set_eq:NN \box_use_drop_vii:N \box_use_drop:N
+\cs_set_eq:NN \box_use_drop_viii:N \box_use_drop:N
+\cs_set_eq:NN \box_use_drop_ix:N \box_use_drop:N
+\cs_set_eq:NN \box_use_drop_x:N \box_use_drop:N
+\cs_set_eq:NN \box_use_drop_xi:N \box_use_drop:N
+\cs_set_eq:NN \box_use_drop_xii:N \box_use_drop:N
\cs_new_protected:Npn \__nicematrix_error:n { \msg_error:nn { nicematrix } }
\cs_new_protected:Npn \__nicematrix_error:nn { \msg_error:nnn { nicematrix } }
\cs_new_protected:Npn \__nicematrix_error:nnn { \msg_error:nnnn { nicematrix } }
@@ -177,8 +189,6 @@
{ \cs_set:Npn \CT@arc@ { \color [ #1 ] { #2 } } }
\cs_new_protected:Npn \__nicematrix_set_CT@arc@_ii: #1 \q_stop
{ \cs_set:Npn \CT@arc@ { \color { #1 } } }
-\cs_new:Npn \__nicematrix_tab_or_array_colsep:
- { \bool_if:NTF \l__nicematrix_NiceTabular_bool \tabcolsep \arraycolsep }
\bool_new:N \c__nicematrix_siunitx_loaded_bool
\AtBeginDocument
{
@@ -252,12 +262,16 @@
{ \pgfpointanchor { \__nicematrix_env: - #1 } { center } }
\int_new:N \g__nicematrix_NiceMatrixBlock_int
\dim_new:N \l__nicematrix_columns_width_dim
+\tl_new:N \l__nicematrix_cell_type_tl
+\tl_set:Nn \l__nicematrix_cell_type_tl { c }
+\dim_new:N \g__nicematrix_blocks_width_dim
\seq_new:N \g__nicematrix_names_seq
\bool_new:N \l__nicematrix_in_env_bool
\bool_new:N \l__nicematrix_NiceArray_bool
\bool_new:N \l__nicematrix_NiceTabular_bool
\dim_new:N \l__nicematrix_tabular_width_dim
\bool_new:N \l__nicematrix_Matrix_bool
+\bool_new:N \g__nicematrix_rotate_bool
\cs_new_protected:Npn \__nicematrix_test_if_math_mode:
{
\if_mode_math: \else:
@@ -300,6 +314,7 @@
\tl_new:N \l__nicematrix_pos_of_block_tl
\tl_set:Nn \l__nicematrix_pos_of_block_tl { c }
\bool_new:N \l__nicematrix_draw_first_bool
+\int_new:N \g__nicematrix_block_box_int
\int_new:N \l__nicematrix_first_row_int
\int_set:Nn \l__nicematrix_first_row_int 1
\int_new:N \l__nicematrix_first_col_int
@@ -313,6 +328,7 @@
\bool_new:N \g__nicematrix_last_col_found_bool
\newcounter { tabularnote }
\seq_new:N \g__nicematrix_tabularnotes_seq
+\tl_new:N \l__nicematrix_tabularnote_tl
\int_new:N \l__nicematrix_number_of_notes_int
\cs_new:Npn \__nicematrix_notes_style:n #1 { \textit { \alph { #1 } } }
\cs_new:Npn \__nicematrix_notes_label_in_tabular:n #1 { \textsuperscript { #1 } }
@@ -329,7 +345,11 @@
\newlist { tabularnotes } { enumerate } { 1 }
\setlist [ tabularnotes ]
{
- noitemsep , leftmargin = * , align = left , labelsep = 0pt ,
+ topsep = 0pt ,
+ noitemsep ,
+ leftmargin = * ,
+ align = left ,
+ labelsep = 0pt ,
label =
\__nicematrix_notes_label_in_list:n { \__nicematrix_notes_style:n { tabularnotesi } } ,
}
@@ -347,7 +367,7 @@
{ \__nicematrix_error:n { tabularnote~forbidden } }
{
\int_incr:N \l__nicematrix_number_of_notes_int
- \seq_gput_right:Nx \g__nicematrix_tabularnotes_seq { #1 }
+ \seq_gput_right:Nn \g__nicematrix_tabularnotes_seq { #1 }
\peek_meaning:NF \tabularnote
{
\hbox_set:Nn \l_tmpa_box
@@ -733,6 +753,8 @@
notes / para .default:n = true ,
notes / bottomrule .bool_set:N = \l__nicematrix_notes_bottomrule_bool ,
notes / bottomrule .default:n = true ,
+ tabularnote .tl_set:N = \l__nicematrix_tabularnote_tl ,
+ tabularnote .value_required:n = true ,
unknown .code:n = \__nicematrix_error:n { Unknown~option~for~NiceArray }
}
\keys_define:nn { NiceMatrix / pNiceArray }
@@ -752,6 +774,8 @@
notes / para .default:n = true ,
notes / bottomrule .bool_set:N = \l__nicematrix_notes_bottomrule_bool ,
notes / bottomrule .default:n = true ,
+ tabularnote .tl_set:N = \l__nicematrix_tabularnote_tl ,
+ tabularnote .value_required:n = true ,
last-col .code:n = \tl_if_empty:nF {#1}
{ \__nicematrix_error:n { last-col~non~empty~for~NiceArray } }
\int_zero:N \l__nicematrix_last_col_int ,
@@ -821,10 +845,35 @@
}
}
}
+\cs_new_protected:Npn \__nicematrix_rotate_cell_box:
+ {
+ \box_rotate:Nn \l__nicematrix_cell_box { 90 }
+ \int_compare:nNnT \c@iRow = \l__nicematrix_last_row_int
+ {
+ \vbox_set_top:Nn \l__nicematrix_cell_box
+ {
+ \vbox_to_zero:n { }
+ \skip_vertical:n { - \box_ht:N \@arstrutbox + 0.8 ex }
+ \box_use:N \l__nicematrix_cell_box
+ }
+ }
+ \bool_gset_false:N \g__nicematrix_rotate_bool
+ }
+\cs_new_protected:Npn \__nicematrix_adjust_width_box:
+ {
+ \dim_compare:nNnT \g__nicematrix_blocks_width_dim > \c_zero_dim
+ {
+ \box_set_wd:Nn \l__nicematrix_cell_box
+ { \dim_max:nn { \box_wd:N \l__nicematrix_cell_box } \g__nicematrix_blocks_width_dim }
+ \dim_gzero:N \g__nicematrix_blocks_width_dim
+ }
+ }
\cs_new_protected:Npn \__nicematrix_end_Cell:
{
\__nicematrix_math_toggle_token:
\hbox_set_end:
+ \bool_if:NT \g__nicematrix_rotate_bool \__nicematrix_rotate_cell_box:
+ \__nicematrix_adjust_width_box:
\box_set_ht:Nn \l__nicematrix_cell_box
{ \box_ht:N \l__nicematrix_cell_box + \l__nicematrix_cell_space_top_limit_dim }
\box_set_dp:Nn \l__nicematrix_cell_box
@@ -833,11 +882,11 @@
{ \dim_max:nn \g__nicematrix_max_cell_width_dim { \box_wd:N \l__nicematrix_cell_box } }
\__nicematrix_update_for_first_and_last_row:
\bool_if:NTF \g__nicematrix_empty_cell_bool
- { \box_use_drop:N \l__nicematrix_cell_box }
+ { \box_use_drop_i:N \l__nicematrix_cell_box }
{
\dim_compare:nNnTF { \box_wd:N \l__nicematrix_cell_box } > \c_zero_dim
\__nicematrix_node_for_the_cell:
- { \box_use_drop:N \l__nicematrix_cell_box }
+ { \box_use_drop_ii:N \l__nicematrix_cell_box }
}
\bool_gset_false:N \g__nicematrix_empty_cell_bool
}
@@ -854,7 +903,7 @@
\pgfnode
{ rectangle }
{ base }
- { \box_use_drop:N \l__nicematrix_cell_box }
+ { \box_use_drop_iii:N \l__nicematrix_cell_box }
{ \__nicematrix_env: - \int_use:N \c@iRow - \int_use:N \c@jCol }
{ }
\str_if_empty:NF \l__nicematrix_name_str
@@ -1059,6 +1108,7 @@
\bgroup
\tl_set:Nn \l__nicematrix_left_delim_tl { #1 }
\tl_set:Nn \l__nicematrix_right_delim_tl { #2 }
+ \int_gzero:N \g__nicematrix_block_box_int
\dim_zero:N \g__nicematrix_width_last_col_dim
\dim_zero:N \g__nicematrix_width_first_col_dim
\bool_gset_false:N \g__nicematrix_row_of_col_done_bool
@@ -1073,7 +1123,7 @@
\cs_gset_eq:NN \__nicematrix_old_CT@arc@ \CT@arc@
\cs_if_exist:NT \tikz@library@external@loaded
{
- \tikzset { external / export = false }
+ \tikzexternaldisable
\cs_if_exist:NT \ifstandalone
{ \tikzset { external / optimize = false } }
}
@@ -1257,8 +1307,21 @@
\int_compare:nNnT \l__nicematrix_last_row_int > { -1 } { \int_gdecr:N \c@iRow }
\int_compare:nNnT \l__nicematrix_first_col_int = 0
{
- \skip_horizontal:N \arraycolsep
- \skip_horizontal:N \g__nicematrix_width_first_col_dim
+ \skip_horizontal:N \col@sep
+ \dim_if_exist:cTF { g__nicematrix_ block _ width _col _ 0 _ dim }
+ {
+ \skip_horizontal:n
+ {
+ \dim_max:nn
+ {
+ \dim_use:c { g__nicematrix_ block _ width _col _ 0 _ dim }
+ - 2 \col@sep
+ }
+ \g__nicematrix_width_first_col_dim
+ }
+ \dim_gzero:c { g__nicematrix_ block _ width _col _ 0 _ dim }
+ }
+ { \skip_horizontal:N \g__nicematrix_width_first_col_dim }
}
\bool_if:NTF \l__nicematrix_NiceArray_bool
{
@@ -1312,8 +1375,27 @@
}
\bool_if:NT \g__nicematrix_last_col_found_bool
{
- \skip_horizontal:N \g__nicematrix_width_last_col_dim
- \skip_horizontal:N \arraycolsep
+ \dim_if_exist:cTF
+ { g__nicematrix_ block _ width _col _ \int_use:N \g__nicematrix_col_total_int _ dim }
+ {
+ \skip_horizontal:n
+ {
+ \dim_max:nn
+ {
+ \dim_use:c
+ {
+ g__nicematrix_ block _ width _col _
+ \int_use:N \g__nicematrix_col_total_int
+ _ dim
+ }
+ }
+ { \g__nicematrix_width_first_col_dim + \col@sep }
+ }
+ }
+ {
+ \skip_horizontal:N \g__nicematrix_width_last_col_dim
+ \skip_horizontal:N \col@sep
+ }
}
\__nicematrix_after_array:
\egroup
@@ -1407,7 +1489,12 @@
}
\cs_new_protected:Npn \__nicematrix_patch_preamble_i:n #1
{
- \tl_gput_right:Nn \g__nicematrix_preamble_tl { > \__nicematrix_Cell: #1 < \__nicematrix_end_Cell: }
+ \tl_gput_right:Nn \g__nicematrix_preamble_tl
+ {
+ > { \__nicematrix_Cell: \tl_set:Nn \l__nicematrix_cell_type_tl { #1 } }
+ #1
+ < \__nicematrix_end_Cell:
+ }
\int_gincr:N \c@jCol
\__nicematrix_patch_preamble_viii:n
}
@@ -1469,13 +1556,16 @@
> {
\hbox_set:Nw \l__nicematrix_cell_box
\__nicematrix_Cell:
+ \tl_set:Nn \l__nicematrix_cell_type_tl { #1 }
}
c
< {
\__nicematrix_end_Cell:
#1
\hbox_set_end:
- \makebox [ #4 ] [ #3 ] { \box_use_drop:N \l__nicematrix_cell_box }
+ \bool_if:NT \g__nicematrix_rotate_bool \__nicematrix_rotate_cell_box:
+ \__nicematrix_adjust_width_box:
+ \makebox [ #4 ] [ #3 ] { \box_use_drop_iv:N \l__nicematrix_cell_box }
}
}
\int_gincr:N \c@jCol
@@ -1518,7 +1608,7 @@
\box_set_ht:Nn \l_tmpa_box { \box_ht:N \l_tmpa_box + \l_tmpa_dim }
\box_set_dp:Nn \l_tmpa_box { \box_dp:N \l_tmpa_box + \l_tmpb_dim }
\str_if_eq:VnTF \l__nicematrix_baseline_str { c }
- { \box_use_drop:N \l_tmpa_box }
+ { \box_use_drop_v:N \l_tmpa_box }
\__nicematrix_put_box_in_flow_i:
}
\cs_new_protected:Npn \__nicematrix_put_box_in_flow_i:
@@ -1559,30 +1649,36 @@
}
\dim_gsub:Nn \g_tmpa_dim \pgf@y
\endpgfpicture
- \box_move_up:nn \g_tmpa_dim { \box_use_drop:N \l_tmpa_box }
- \box_use_drop:N \l_tmpa_box
+ \box_move_up:nn \g_tmpa_dim { \box_use_drop_vi:N \l_tmpa_box }
+ \box_use_drop_vii:N \l_tmpa_box
}
\cs_new_protected:Npn \__nicematrix_use_arraybox_with_notes_c:
{
- \int_compare:nNnTF \c@tabularnote = 0
- { \box_use_drop:N \l__nicematrix_the_array_box }
+ \bool_lazy_and:nnTF
+ { \int_compare_p:nNn \c@tabularnote = 0 }
+ { \tl_if_empty_p:V \l__nicematrix_tabularnote_tl }
+ { \box_use_drop_viii:N \l__nicematrix_the_array_box }
{
\begin { minipage } { \box_wd:N \l__nicematrix_the_array_box }
- \box_use_drop:N \l__nicematrix_the_array_box
+ \box_use_drop_ix:N \l__nicematrix_the_array_box
\skip_vertical:N 0.65ex
\group_begin:
\l__nicematrix_notes_code_before_tl
- \bool_if:NTF \l__nicematrix_notes_para_bool
- {
- \begin { tabularnotes* }
- \seq_map_inline:Nn \g__nicematrix_tabularnotes_seq { \item ##1 } \strut
- \end { tabularnotes* }
- \par
- }
+ \tl_if_empty:NF \l__nicematrix_tabularnote_tl { \l__nicematrix_tabularnote_tl \par }
+ \int_compare:nNnF \c@tabularnote = 0
{
- \tabularnotes
- \seq_map_inline:Nn \g__nicematrix_tabularnotes_seq { \item ##1 } \strut
- \endtabularnotes
+ \bool_if:NTF \l__nicematrix_notes_para_bool
+ {
+ \begin { tabularnotes* }
+ \seq_map_inline:Nn \g__nicematrix_tabularnotes_seq { \item ##1 } \strut
+ \end { tabularnotes* }
+ \par
+ }
+ {
+ \tabularnotes
+ \seq_map_inline:Nn \g__nicematrix_tabularnotes_seq { \item ##1 } \strut
+ \endtabularnotes
+ }
}
\unskip
\group_end:
@@ -1621,18 +1717,31 @@
{
\str_if_eq:VnT \l__nicematrix_baseline_str { t }
{ \tl_set:Nn \l__nicematrix_baseline_str { 1 } }
- \int_set:Nn \l_tmpa_int \l__nicematrix_baseline_str
- \bool_lazy_or:nnT
- { \int_compare_p:nNn \l_tmpa_int < \l__nicematrix_first_row_int }
- { \int_compare_p:nNn \l_tmpa_int > \g__nicematrix_row_total_int }
- {
- \__nicematrix_error:n { bad~value~for~baseline }
- \int_set:Nn \l_tmpa_int 1
- }
\pgfpicture
\__nicematrix_qpoint:n { row - 1 }
\dim_gset_eq:NN \g_tmpa_dim \pgf@y
- \__nicematrix_qpoint:n { row - \int_use:N \l_tmpa_int - base }
+ \str_if_in:NnTF \l__nicematrix_baseline_str { line- }
+ {
+ \int_set:Nn \l_tmpa_int
+ {
+ \str_range:Nnn
+ \l__nicematrix_baseline_str
+ 6
+ { \str_count:N \l__nicematrix_baseline_str }
+ }
+ \__nicematrix_qpoint:n { row - \int_use:N \l_tmpa_int }
+ }
+ {
+ \int_set:Nn \l_tmpa_int \l__nicematrix_baseline_str
+ \bool_lazy_or:nnT
+ { \int_compare_p:nNn \l_tmpa_int < \l__nicematrix_first_row_int }
+ { \int_compare_p:nNn \l_tmpa_int > \g__nicematrix_row_total_int }
+ {
+ \__nicematrix_error:n { bad~value~for~baseline }
+ \int_set:Nn \l_tmpa_int 1
+ }
+ \__nicematrix_qpoint:n { row - \int_use:N \l_tmpa_int - base }
+ }
\dim_gsub:Nn \g_tmpa_dim \pgf@y
\endpgfpicture
\dim_gadd:Nn \g_tmpa_dim \arrayrulewidth
@@ -1739,15 +1848,19 @@
\int_compare:nNnT \l__nicematrix_first_col_int = 0
{
\omit
- \skip_horizontal:N -2\col@sep
- \bool_if:NT \l__nicematrix_code_before_bool
- { \pgfsys@markposition { \__nicematrix_env: - col - 0 } }
- \pgfpicture
- \pgfrememberpicturepositiononpagetrue
- \pgfcoordinate { \__nicematrix_env: - col - 0 } \pgfpointorigin
- \str_if_empty:NF \l__nicematrix_name_str
- { \pgfnodealias { \l__nicematrix_name_str - col - 0 } { \__nicematrix_env: - col - 0 } }
- \endpgfpicture
+ \hbox_overlap_left:n
+ {
+ \bool_if:NT \l__nicematrix_code_before_bool
+ { \pgfsys@markposition { \__nicematrix_env: - col - 0 } }
+ \pgfpicture
+ \pgfrememberpicturepositiononpagetrue
+ \pgfcoordinate { \__nicematrix_env: - col - 0 } \pgfpointorigin
+ \str_if_empty:NF \l__nicematrix_name_str
+ { \pgfnodealias { \l__nicematrix_name_str - col - 0 } { \__nicematrix_env: - col - 0 } }
+ \endpgfpicture
+ \skip_horizontal:N 2\col@sep
+ \skip_horizontal:N \g__nicematrix_width_first_col_dim
+ }
&
}
\omit
@@ -1852,23 +1965,27 @@
}
\bool_if:NT \g__nicematrix_last_col_found_bool
{
- \bool_if:NT \l__nicematrix_code_before_bool
- {
- \pgfsys@markposition { \__nicematrix_env: - col - \__nicematrix_succ:n \g__nicematrix_col_total_int }
- }
- \skip_horizontal:N 2\col@sep
- \pgfpicture
- \pgfrememberpicturepositiononpagetrue
- \pgfcoordinate { \__nicematrix_env: - col - \__nicematrix_succ:n \g__nicematrix_col_total_int }
- \pgfpointorigin
- \str_if_empty:NF \l__nicematrix_name_str
+ \hbox_overlap_right:n
{
- \pgfnodealias
- { \l__nicematrix_name_str - col - \__nicematrix_succ:n \g__nicematrix_col_total_int }
- { \__nicematrix_env: - col - \__nicematrix_succ:n \g__nicematrix_col_total_int }
+ % \skip_horizontal:N \col@sep
+ \skip_horizontal:N \g__nicematrix_width_last_col_dim
+ \bool_if:NT \l__nicematrix_code_before_bool
+ {
+ \pgfsys@markposition
+ { \__nicematrix_env: - col - \__nicematrix_succ:n \g__nicematrix_col_total_int }
+ }
+ \pgfpicture
+ \pgfrememberpicturepositiononpagetrue
+ \pgfcoordinate { \__nicematrix_env: - col - \__nicematrix_succ:n \g__nicematrix_col_total_int }
+ \pgfpointorigin
+ \str_if_empty:NF \l__nicematrix_name_str
+ {
+ \pgfnodealias
+ { \l__nicematrix_name_str - col - \__nicematrix_succ:n \g__nicematrix_col_total_int }
+ { \__nicematrix_env: - col - \__nicematrix_succ:n \g__nicematrix_col_total_int }
+ }
+ \endpgfpicture
}
- \endpgfpicture
- \skip_horizontal:N -2\col@sep
}
\cr
}
@@ -1897,6 +2014,8 @@
{
\__nicematrix_math_toggle_token:
\hbox_set_end:
+ \bool_if:NT \g__nicematrix_rotate_bool \__nicematrix_rotate_cell_box:
+ \__nicematrix_adjust_width_box:
\__nicematrix_update_for_first_and_last_row:
\dim_gset:Nn \g__nicematrix_width_first_col_dim
{ \dim_max:nn \g__nicematrix_width_first_col_dim { \box_wd:N \l__nicematrix_cell_box } }
@@ -1904,7 +2023,7 @@
{
\dim_compare:nNnTF { \box_wd:N \l__nicematrix_cell_box } > \c_zero_dim
\__nicematrix_node_for_the_cell:
- { \box_use_drop:N \l__nicematrix_cell_box }
+ { \box_use_drop_x:N \l__nicematrix_cell_box }
\skip_horizontal:N \l__nicematrix_left_delim_dim
\skip_horizontal:N \l__nicematrix_left_margin_dim
\skip_horizontal:N \l__nicematrix_extra_left_margin_dim
@@ -1939,6 +2058,8 @@
{
\__nicematrix_math_toggle_token:
\hbox_set_end:
+ \bool_if:NT \g__nicematrix_rotate_bool \__nicematrix_rotate_cell_box:
+ \__nicematrix_adjust_width_box:
\__nicematrix_update_for_first_and_last_row:
\dim_gset:Nn \g__nicematrix_width_last_col_dim
{ \dim_max:nn \g__nicematrix_width_last_col_dim { \box_wd:N \l__nicematrix_cell_box } }
@@ -2135,10 +2256,10 @@
}
\bool_if:NT \l__nicematrix_hlines_bool \__nicematrix_draw_hlines:
\bool_if:NT \l__nicematrix_vlines_bool \__nicematrix_draw_vlines:
- \g__nicematrix_internal_code_after_tl
- \tl_gclear:N \g__nicematrix_internal_code_after_tl
\cs_set_eq:NN \ialign \__nicematrix_old_ialign:
\seq_if_empty:NF \g__nicematrix_blocks_seq \__nicematrix_draw_blocks:
+ \g__nicematrix_internal_code_after_tl
+ \tl_gclear:N \g__nicematrix_internal_code_after_tl
\bool_if:NT \c__nicematrix_tikz_loaded_bool
{
\tikzset
@@ -2406,7 +2527,7 @@
{
\__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_initial_j_int }
\dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf@x
- \dim_add:Nn \l__nicematrix_x_initial_dim \__nicematrix_tab_or_array_colsep:
+ \dim_add:Nn \l__nicematrix_x_initial_dim \col@sep
\__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_initial_i_int - base }
\dim_set_eq:NN \l__nicematrix_y_initial_dim \pgf@y
}
@@ -2415,7 +2536,7 @@
{
\__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l__nicematrix_final_j_int }
\dim_set_eq:NN \l__nicematrix_x_final_dim \pgf@x
- \dim_sub:Nn \l__nicematrix_x_final_dim \__nicematrix_tab_or_array_colsep:
+ \dim_sub:Nn \l__nicematrix_x_final_dim \col@sep
\__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_final_i_int - base }
\dim_set_eq:NN \l__nicematrix_y_final_dim \pgf@y
}
@@ -2448,16 +2569,14 @@
{
\__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_initial_j_int }
\dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf@x
- \dim_add:Nn \l__nicematrix_x_initial_dim
- { \bool_if:NTF \l__nicematrix_NiceTabular_bool \tabcolsep \arraycolsep }
+ \dim_add:Nn \l__nicematrix_x_initial_dim \col@sep
}
{ \__nicematrix_set_initial_coords_from_anchor:n { mid~east } }
\bool_if:NTF \l__nicematrix_final_open_bool
{
\__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l__nicematrix_final_j_int }
\dim_set_eq:NN \l__nicematrix_x_final_dim \pgf@x
- \dim_sub:Nn \l__nicematrix_x_final_dim
- { \bool_if:NTF \l__nicematrix_NiceTabular_bool \tabcolsep \arraycolsep }
+ \dim_sub:Nn \l__nicematrix_x_final_dim \col@sep
}
{ \__nicematrix_set_final_coords_from_anchor:n { mid~west } }
\bool_lazy_and:nnTF
@@ -3154,27 +3273,7 @@
\int_step_inline:nnn { #1 } { #1 + #3 - 1 }
{ \cs_set:cpn { __nicematrix _ dotted _ ##1 - #2 } { } }
}
-\cs_new_protected:Npn \__nicematrix_rotate:
- {
- \bool_if:NTF \l__nicematrix_NiceTabular_bool
- { \group_insert_after:N \__nicematrix_rotate_ii: }
- { \group_insert_after:N \__nicematrix_rotate_i: }
- }
-\cs_new_protected:Npn \__nicematrix_rotate_i: { \group_insert_after:N \__nicematrix_rotate_ii: }
-\cs_new_protected:Npn \__nicematrix_rotate_ii: { \group_insert_after:N \__nicematrix_rotate_iii: }
-\cs_new_protected:Npn \__nicematrix_rotate_iii:
- {
- \box_rotate:Nn \l__nicematrix_cell_box { 90 }
- \int_compare:nNnT \c@iRow = \l__nicematrix_last_row_int
- {
- \vbox_set_top:Nn \l__nicematrix_cell_box
- {
- \vbox_to_zero:n { }
- \skip_vertical:n { - \box_ht:N \@arstrutbox + 0.8 ex }
- \box_use:N \l__nicematrix_cell_box
- }
- }
- }
+\cs_new_protected:Npn \__nicematrix_rotate: { \bool_gset_true:N \g__nicematrix_rotate_bool }
\cs_new:Npn \__nicematrix_double_int_eval:n #1-#2 \q_stop
{ \int_eval:n { #1 } - \int_eval:n { #2 } }
\AtBeginDocument
@@ -3921,14 +4020,14 @@
\dim_set:Nn \l__nicematrix_x_initial_dim
{
\pgf@x +
- \bool_if:NTF \l__nicematrix_NiceTabular_bool \tabcolsep \arraycolsep
+ \bool_if:NTF \l__nicematrix_NiceArray_bool \c_zero_dim \arraycolsep
- \l__nicematrix_left_margin_dim
}
\__nicematrix_qpoint:n { col - \__nicematrix_succ:n \c@jCol }
\dim_set:Nn \l__nicematrix_x_final_dim
{
\pgf@x -
- \bool_if:NTF \l__nicematrix_NiceTabular_bool \tabcolsep \arraycolsep
+ \bool_if:NTF \l__nicematrix_NiceArray_bool \c_zero_dim \arraycolsep
+ \l__nicematrix_right_margin_dim
}
\tl_set:Nn \l_tmpa_tl { ( }
@@ -4191,13 +4290,24 @@
{ \int_use:N \g__nicematrix_env_int - \__nicematrix_i: - \__nicematrix_j: \l__nicematrix_suffix_tl}
}
}
+\keys_define:nn { NiceMatrix / Block / FirstPass }
+ {
+ l .code:n = \tl_set:Nn \l__nicematrix_pos_of_block_tl l ,
+ l .value_forbidden:n = true ,
+ r .code:n = \tl_set:Nn \l__nicematrix_pos_of_block_tl r ,
+ r .value_forbidden:n = true ,
+ c .code:n = \tl_set:Nn \l__nicematrix_pos_of_block_tl c ,
+ c .value_forbidden:n = true ,
+ }
\NewExpandableDocumentCommand \__nicematrix_Block: { O { } m D < > { } m }
{ \__nicematrix_Block_i #2 \q_stop { #1 } { #3 } { #4 } }
\cs_new:Npn \__nicematrix_Block_i #1-#2 \q_stop { \__nicematrix_Block_ii:nnnnn { #1 } { #2 } }
\cs_new_protected:Npn \__nicematrix_Block_ii:nnnnn #1 #2 #3 #4 #5
{
- \bool_if:NT \l__nicematrix_NiceTabular_bool
- { \tl_if_empty:nF { #4 } { \__nicematrix_error:n { angle~option~in~NiceTabular } } }
+ \tl_if_empty:NTF \l__nicematrix_cell_type_tl
+ { \tl_set:Nn \l__nicematrix_pos_of_block_tl c }
+ { \tl_set_eq:NN \l__nicematrix_pos_of_block_tl \l__nicematrix_cell_type_tl }
+ \keys_set_known:nn { NiceMatrix / Block / FirstPass } { #3 }
\tl_set:Nx \l_tmpa_tl
{
{ \int_use:N \c@iRow }
@@ -4206,14 +4316,124 @@
{ \int_eval:n { \c@jCol + #2 - 1 } }
}
\seq_gput_left:NV \g__nicematrix_pos_of_blocks_seq \l_tmpa_tl
- \seq_gput_left:Nx \g__nicematrix_blocks_seq
+ \int_compare:nNnTF { #2 } = 1
+ {
+ \int_gincr:N \g__nicematrix_block_box_int
+ \cs_set_protected_nopar:Npn \diagbox ##1 ##2
+ {
+ \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl
+ {
+ \__nicematrix_actually_diagbox:nnnnnn
+ { \int_use:N \c@iRow }
+ { \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 } }
+ }
+ }
+ \box_gclear_new:c
+ { g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box }
+ \hbox_gset:cn
+ { g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box }
+ {
+ \color_ensure_current:
+ \bool_if:NTF \l__nicematrix_NiceTabular_bool
+ {
+ \group_begin:
+ \cs_set:Npn \arraystretch { 1 }
+ \dim_set_eq:NN \extrarowheight \c_zero_dim
+ #4
+ \bool_if:NT \g__nicematrix_rotate_bool
+ { \tl_set:Nn \l__nicematrix_pos_of_block_tl c }
+ \exp_args:Nnx \begin { tabular }
+ { @ { } \l__nicematrix_pos_of_block_tl @ { } }
+ #5
+ \end { tabular }
+ \group_end:
+ }
+ {
+ \group_begin:
+ \cs_set:Npn \arraystretch { 1 }
+ \dim_set_eq:NN \extrarowheight \c_zero_dim
+ #4
+ \bool_if:NT \g__nicematrix_rotate_bool
+ { \tl_set:Nn \l__nicematrix_pos_of_block_tl c }
+ \c_math_toggle_token
+ \exp_args:Nnx \begin { array }
+ { @ { } \l__nicematrix_pos_of_block_tl @ { } }
+ #5
+ \end { array }
+ \c_math_toggle_token
+ \group_end:
+ }
+ }
+ \bool_if:NT \g__nicematrix_rotate_bool
+ {
+ \box_grotate:cn
+ { g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box }
+ { 90 }
+ \bool_gset_false:N \g__nicematrix_rotate_bool
+ }
+ \dim_gset:Nn \g__nicematrix_blocks_width_dim
+ {
+ \dim_max:nn
+ \g__nicematrix_blocks_width_dim
+ {
+ \box_wd:c
+ { g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box }
+ }
+ }
+ \seq_gput_right:Nx \g__nicematrix_blocks_seq
+ {
+ \l_tmpa_tl
+ { #3 , \l__nicematrix_pos_of_block_tl }
+ {
+ \box_use_drop:c
+ { g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box }
+ }
+ }
+ }
{
- \l_tmpa_tl
- { #3 }
- \exp_not:n { { #4 \__nicematrix_math_toggle_token: #5 \__nicematrix_math_toggle_token: } }
+ \seq_gput_right:Nx \g__nicematrix_blocks_seq
+ {
+ \l_tmpa_tl
+ { #3 }
+ \exp_not:n
+ {
+ {
+ \bool_if:NTF \l__nicematrix_NiceTabular_bool
+ {
+ \group_begin:
+ \cs_set:Npn \arraystretch { 1 }
+ \dim_set_eq:NN \extrarowheight \c_zero_dim
+ #4
+ \bool_if:NT \g__nicematrix_rotate_bool
+ { \tl_set:Nn \l__nicematrix_pos_of_block_tl c }
+ \exp_args:Nnx \begin { tabular }
+ { @ { } \l__nicematrix_pos_of_block_tl @ { } }
+ #5
+ \end { tabular }
+ \group_end:
+ }
+ {
+ \group_begin:
+ \cs_set:Npn \arraystretch { 1 }
+ \dim_set_eq:NN \extrarowheight \c_zero_dim
+ #4
+ \bool_if:NT \g__nicematrix_rotate_bool
+ { \tl_set:Nn \l__nicematrix_pos_of_block_tl c }
+ \c_math_toggle_token
+ \exp_args:Nnx \begin { array }
+ { @ { } \l__nicematrix_pos_of_block_tl @ { } } #5 \end { array }
+ \c_math_toggle_token
+ \group_end:
+ }
+ }
+ }
+ }
}
}
-\keys_define:nn { NiceMatrix / Block }
+\keys_define:nn { NiceMatrix / Block / SecondPass }
{
tikz .tl_set:N = \l__nicematrix_tikz_tl ,
tikz .value_required:n = true ,
@@ -4232,7 +4452,7 @@
\cs_new_protected:Npn \__nicematrix_Block_iii:nnnnnn #1 #2 #3 #4 #5 #6
{
\group_begin:
- \keys_set:nn { NiceMatrix / Block } { #5 }
+ \keys_set:nn { NiceMatrix / Block / SecondPass} { #5 }
\tl_if_empty:NF \l__nicematrix_color_tl
{
\tl_gput_right:Nx \g_nicematrix_code_before_tl
@@ -4258,6 +4478,7 @@
{ \msg_error:nnnn { nicematrix } { Block~too~large } { #1 } { #2 } }
{
\hbox_set:Nn \l__nicematrix_cell_box { #6 }
+ \bool_if:NT \g__nicematrix_rotate_bool \__nicematrix_rotate_cell_box:
\pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgf@relevantforpicturesizefalse
@@ -4352,15 +4573,19 @@
r { base~east }
}
}
- { \box_use_drop:N \l__nicematrix_cell_box } { } { }
+ { \box_use_drop_xi:N \l__nicematrix_cell_box } { } { }
}
{
+ \int_compare:nNnT \c@jCol = 0
+ { \tl_set:Nn \l__nicematrix_pos_of_block_tl r }
+ \int_compare:nNnT \c@jCol = \l__nicematrix_last_col_int
+ { \tl_set:Nn \l__nicematrix_pos_of_block_tl l }
\pgftransformshift
{
\pgfpointanchor
{ \__nicematrix_env: - #1 - #2 - block - short }
{
- \str_case:Vn \l__nicematrix_pos_of_block_tl
+ \str_case:Vn \l__nicematrix_pos_of_block_tl
{
c { center }
l { west }
@@ -4379,7 +4604,7 @@
r { east }
}
}
- { \box_use_drop:N \l__nicematrix_cell_box } { } { }
+ { \box_use_drop_xii:N \l__nicematrix_cell_box } { } { }
}
\endpgfpicture
}
@@ -4781,11 +5006,6 @@
is~unknown. \\
This~error~is~fatal.
}
-\__nicematrix_msg_new:nn { angle~option~in~NiceTabular }
- {
- You~should~not~the~option~between~angle~brackets~(<~and~>)~for~a~command~
- \token_to_str:N \Block\ in~\{NiceTabular\}.~However,~you~can~go~on.
- }
\__nicematrix_msg_new:nn { tabularnote~forbidden }
{
You~can't~use~the~command~\token_to_str:N\tabularnote\
@@ -4833,7 +5053,7 @@
For~a~list~of~the~available~keys,~type~H~<return>.
}
{
- The~available~options~are~(in~alphabetic~order):~c,~
+ The~available~options~are~(in~alphabetic~order):~-,~c,~
color,~l,~and~r.
}
\__nicematrix_msg_new:nnn { Unknown~key~for~notes }
@@ -4926,6 +5146,7 @@
first-row,~
hlines,~
hvlines,~
+ hvlines-except-corners,~
last-col,~
last-row,~
left-margin,~
@@ -4975,6 +5196,7 @@
first-row,~
hlines,~
hvlines,~
+ hvlines-except-corners,~
l,~
last-col,~
last-row,~
@@ -5024,6 +5246,7 @@
first-row,~
hlines,~
hvlines,~
+ hvlines-except-corners,~
last-col,~
last-row,~
left-margin,~