diff options
author | Karl Berry <karl@freefriends.org> | 2021-05-25 20:50:13 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-05-25 20:50:13 +0000 |
commit | 03a92032945834131e8e52057361813f373a3f8c (patch) | |
tree | a91323830279f3b09e25cc4723d15323d05cf60e | |
parent | 075b67cb856341214b6f335528a93b8b2a766f41 (diff) |
tabularray (25may21)
git-svn-id: svn://tug.org/texlive/trunk@59349 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/latex/tabularray/tabularray.pdf | bin | 379316 -> 399433 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/tabularray/tabularray.tex | 16 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/tabularray/tabularray.sty | 545 |
3 files changed, 444 insertions, 117 deletions
diff --git a/Master/texmf-dist/doc/latex/tabularray/tabularray.pdf b/Master/texmf-dist/doc/latex/tabularray/tabularray.pdf Binary files differindex f367583b1b4..7b00466957f 100644 --- a/Master/texmf-dist/doc/latex/tabularray/tabularray.pdf +++ b/Master/texmf-dist/doc/latex/tabularray/tabularray.pdf diff --git a/Master/texmf-dist/doc/latex/tabularray/tabularray.tex b/Master/texmf-dist/doc/latex/tabularray/tabularray.tex index 41aa2ab9f6b..03a2835a5ec 100644 --- a/Master/texmf-dist/doc/latex/tabularray/tabularray.tex +++ b/Master/texmf-dist/doc/latex/tabularray/tabularray.tex @@ -1,9 +1,9 @@ -% -*- coding: utf-8 -*- +% -*- coding: utf-8 -*- +% !TEX program = lualatex \documentclass[oneside]{book} \usepackage[a4paper,margin=2.5cm]{geometry} -\usepackage{codehigh} % https://github.com/lvjr/codehigh -%\usepackage{arev} +\usepackage{codehigh} % https://ctan.org/pkg/codehigh \usepackage{tabularray} \usepackage{array,multirow,amsmath} @@ -15,7 +15,7 @@ } \renewcommand*{\thefootnote}{*} -\newcommand*{\myversion}{2021H} +\newcommand*{\myversion}{2021J} \newcommand*{\mydate}{Version \myversion\ (\the\year-\mylpad\month-\mylpad\day)\\\myrepo} \newcommand*{\myrepo}{\url{https://github.com/lvjr/tabularray}} \newcommand*{\mylpad}[1]{\ifnum#1<10 0\the#1\else\the#1\fi} @@ -716,7 +716,7 @@ Counters \verb!rownum!, \verb!colnum!, \verb!rowcount!, \verb!colcount! can be u \section{Experimental Interface} Everything described in this section is in \underline{\textcolor{red3}{\textbf{experimental}}} status. -Don’t use it in important documents, unless you have time +Don’t use them in important documents, unless you have time to update them for the newer versions of \verb!tabularray! package in the future. By default \verb!tabularray! package will compute column widths from span widths. @@ -743,6 +743,12 @@ The following two examples show this difference: \end{tblr} \end{demohigh} +To trace internal data behind \verb!tblr! environment, you can use \verb!\SetTblrTracing! command. +For example, \verb!\SetTblrTracing{all}! will turn on all tracings, +and \verb!\SetTblrTracing{none}! will turn off all tracings. +\verb!\SetTblrTracing{+row,+column}! will only tracing row and column data. +All tracing messages will be written to the log files. + \chapter{Source Code} %\CodeHigh{lite} diff --git a/Master/texmf-dist/tex/latex/tabularray/tabularray.sty b/Master/texmf-dist/tex/latex/tabularray/tabularray.sty index dbd07ddc8e2..90ddaadd342 100644 --- a/Master/texmf-dist/tex/latex/tabularray/tabularray.sty +++ b/Master/texmf-dist/tex/latex/tabularray/tabularray.sty @@ -7,33 +7,51 @@ %%% ---------------------------------------------------------------------------- %%% -------------------------------------------------------- -%% \section{Scratch Variables and Data Structures} +%% \section{Scratch Variables and Function Variants} %%% -------------------------------------------------------- \NeedsTeXFormat{LaTeX2e} \RequirePackage{expl3} -\ProvidesExplPackage{tabularray}{2021-05-13}{2021H} +\ProvidesExplPackage{tabularray}{2021-05-25}{2021J} {Typeset tabulars and arrays with LaTeX3} -%\RequirePackage{xparse} +\RequirePackage{xparse} \AtBeginDocument{\@ifpackageloaded{xcolor}{\RequirePackage{ninecolors}}{}} \ExplSyntaxOn -\cs_if_exist:NF \vbox_set_top_to_ht:Nnn +%% Backport \tl_if_eq:NnTF for old texlive 2020 +\cs_if_exist:NF \tl_if_eq:NnTF { - \cs_new_protected:Npn \vbox_set_top_to_ht:Nnn #1 #2 #3 + \tl_new:N \l__tblr_backport_b_tl + \prg_new_protected_conditional:Npnn \tl_if_eq:Nn #1 #2 { T, F, TF } { - \tex_setbox:D #1 \tex_vtop:D to \dim_eval:n { #2 } - { \color_group_begin: #3 \par \color_group_end: } + \group_begin: + \tl_set:Nn \l__tblr_backport_b_tl {#2} + \exp_after:wN + \group_end: + \if_meaning:w #1 \l__tblr_backport_b_tl + \prg_return_true: + \else: + \prg_return_false: + \fi: } - } + \prg_generate_conditional_variant:Nnn \tl_if_eq:Nn { c } { TF, T, F } + } + +%% Compatible with texlive 2020 +\cs_if_exist:NF \seq_map_indexed_function:NN + { + \cs_set_eq:NN \seq_map_indexed_function:NN \seq_indexed_map_function:NN + } \cs_generate_variant:Nn \msg_error:nnnn { nnVn } \cs_generate_variant:Nn \prop_item:Nn { Ne, NV } \cs_generate_variant:Nn \prop_put:Nnn { Nxn, Nxx, NxV } \cs_generate_variant:Nn \regex_replace_all:NnN { NVN } \cs_generate_variant:Nn \seq_map_indexed_inline:Nn { cn } +\cs_generate_variant:Nn \tl_const:Nn { ce } +\cs_generate_variant:Nn \tl_log:n { x } \cs_generate_variant:Nn \tl_gput_right:Nn { Nf } \prg_generate_conditional_variant:Nnn \clist_if_in:Nn { Nx } { TF } \prg_generate_conditional_variant:Nnn \prop_if_in:Nn { c } { T } @@ -79,6 +97,10 @@ \box_new:N \l__tblr_c_box % for cell box \box_new:N \l__tblr_d_box +%%% -------------------------------------------------------- +%% \section{Data Structures Based on Property Lists} +%%% -------------------------------------------------------- + \int_new:N \g_tblr_level_int % store table nesting level \cs_new_protected:Npn \__tblr_prop_gput:nnn #1 #2 #3 @@ -178,6 +200,234 @@ \newcounter{colcount} %%% -------------------------------------------------------- +%% \section{Data Structures Based on Integer Arrays} +%%% -------------------------------------------------------- + +\int_new:N \g__tblr_array_int + +\cs_new_protected:Npn \__tblr_initial_table_data: + { + \int_gincr:N \g__tblr_array_int + \intarray_new:cn { g__tblr_row_ \int_use:N \g__tblr_array_int _intarray } + { \g__tblr_data_row_key_count_int * \c@rowcount } + \cs_set_eq:cc { g__tblr_row_ \int_use:N \g_tblr_level_int _intarray } + { g__tblr_row_ \int_use:N \g__tblr_array_int _intarray } + %\intarray_log:c { g__tblr_row_ \int_use:N \g_tblr_level_int _intarray } + } + +%% #1: data name; #2: key name; #3: value type +\cs_new_protected:Npn \__tblr_data_new_key:nnn #1 #2 #3 + { + \int_gincr:c { g__tblr_data_#1_key_count_int } + \tl_const:ce + { + g__tblr_data_#1_key_name_ + \int_use:c { g__tblr_data_#1_key_count_int } _tl + } + { #2 } + \tl_const:ce { g__tblr_data_#1_key_number_#2_tl } + { \int_use:c { g__tblr_data_#1_key_count_int } } + \tl_const:cn { g__tblr_data_#1_key_type_#2_tl } {#3} + } + +\int_new:N \g__tblr_data_row_key_count_int + +\__tblr_data_new_key:nnn { row } { height } { dim } +\__tblr_data_new_key:nnn { row } { coefficient } { dec } +\__tblr_data_new_key:nnn { row } { abovesep } { dim } +\__tblr_data_new_key:nnn { row } { belowsep } { dim } +\__tblr_data_new_key:nnn { row } { @row-height } { dim } +\__tblr_data_new_key:nnn { row } { @row-head } { dim } +\__tblr_data_new_key:nnn { row } { @row-foot } { dim } +\__tblr_data_new_key:nnn { row } { @row-upper } { dim } +\__tblr_data_new_key:nnn { row } { @row-lower } { dim } + +%% #1: data name; #2: data index; #3: key name +\cs_new:Npn \__tblr_data_key_to_int:nnn #1 #2 #3 + { + ( #2 - 1 ) * \int_use:c { g__tblr_data_#1_key_count_int } + + \tl_use:c { g__tblr_data_#1_key_number_#3_tl } + } + +\int_new:N \l__tblr_key_count_int +\int_new:N \l__tblr_key_quotient_int +\int_new:N \l__tblr_key_remainder_int + +%% #1: data name; #2: array position; +%% #3: returning tl with index; #4: returning tl with key name +\cs_new:Npn \__tblr_data_int_to_key:nnNN #1 #2 #3 #4 + { + \int_set_eq:Nc \l__tblr_key_count_int { g__tblr_data_#1_key_count_int } + \int_set:Nn \l__tblr_key_quotient_int + { + \int_div_truncate:nn + { #2 + \l__tblr_key_count_int - 1 } { \l__tblr_key_count_int } + } + \int_set:Nn \l__tblr_key_remainder_int + { + #2 + \l__tblr_key_count_int + - \l__tblr_key_quotient_int * \l__tblr_key_count_int + } + \int_compare:nNnT { \l__tblr_key_remainder_int } = { 0 } + { \int_set_eq:NN \l__tblr_key_remainder_int \l__tblr_key_count_int } + \tl_set:Nx #3 { \int_use:N \l__tblr_key_quotient_int } + \tl_set_eq:Nc #4 + { g__tblr_data_#1_key_name_ \int_use:N \l__tblr_key_remainder_int _tl } + } + +%% #1: data name; #2: key name; #3: value +\cs_new:Npn \__tblr_data_value_to_int:nnn #1 #2 #3 + { + \cs:w + __tblr_data_ \tl_use:c { g__tblr_data_#1_key_type_#2_tl } _to_int:n + \cs_end: + {#3} + } + +%% #1: data name; #2: key name; #3: int +\cs_new:Npn \__tblr_data_int_to_value:nnn #1 #2 #3 + { + \cs:w + __tblr_data_int_to_ \tl_use:c { g__tblr_data_#1_key_type_#2_tl } :n + \cs_end: + {#3} + } +\cs_generate_variant:Nn \__tblr_data_int_to_value:nnn { nne, nVe } + +\cs_new:Npn \__tblr_data_dim_to_int:n #1 + { + \dim_to_decimal_in_sp:n {#1} + } + +%% Return a dimension in pt so that it's easier to understand in tracing messages +\cs_new:Npn \__tblr_data_int_to_dim:n #1 + { + %#1 sp + %\dim_eval:n { #1 sp } + \dim_to_decimal:n { #1 sp } pt + } + +\cs_new:Npn \__tblr_data_dec_to_int:n #1 + { + \dim_to_decimal_in_sp:n {#1 pt} + } + +\cs_new:Npn \__tblr_data_int_to_dec:n #1 + { + \dim_to_decimal:n {#1 sp} + } + +%% #1: data name; #2: data index; #3: key; #4: value +\cs_new_protected:Npn \__tblr_data_gput:nnnn #1 #2 #3 #4 + { + \intarray_gset:cnn + { g__tblr_#1_ \int_use:N \g_tblr_level_int _intarray } + { \__tblr_data_key_to_int:nnn {#1} {#2} {#3} } + { \__tblr_data_value_to_int:nnn {#1} {#3} {#4} } + } +\cs_generate_variant:Nn \__tblr_data_gput:nnnn + { nnne, nnnV, nenn, nene, nenV, nVnn } + +%% #1: data name; #2: data index; #3: key +\cs_new:Npn \__tblr_data_item:nnn #1 #2 #3 + { + \__tblr_data_int_to_value:nne {#1} {#3} + { + \intarray_item:cn { g__tblr_#1_ \int_use:N \g_tblr_level_int _intarray } + { \__tblr_data_key_to_int:nnn {#1} {#2} {#3} } + } + } +\cs_generate_variant:Nn \__tblr_data_item:nnn { nen } + +\tl_new:N \l__tblr_data_key_tl +\tl_new:N \l__tblr_data_index_tl + +\cs_new_protected:Npn \__tblr_data_log:n #1 + { + %\intarray_log:c { g__tblr_#1_ \int_use:N \g_tblr_level_int _intarray } + \tl_set:Nx \l_tmpa_tl { g__tblr_#1_ \int_use:N \g_tblr_level_int _intarray } + \int_step_inline:nn + { \intarray_count:c { \l_tmpa_tl } } + { + \__tblr_data_int_to_key:nnNN {#1} {##1} + \l__tblr_data_index_tl \l__tblr_data_key_tl + \tl_log:x + { + { #1 [\l__tblr_data_index_tl] / \l__tblr_data_key_tl } + \space = \space + { + \__tblr_data_int_to_value:nVe {#1} \l__tblr_data_key_tl + { \intarray_item:cn { \l_tmpa_tl } {##1} } + } + } + } + \__tblr_prop_log:n {#1} + } + +%% #1: data name; #2: row index; #3: key; #4: value +\cs_new_protected:Npn \__tblr_data_gput_if_larger:nnnn #1 #2 #3 #4 + { + \__tblr_array_gput_if_larger:cnn + { g__tblr_#1_ \int_use:N \g_tblr_level_int _intarray } + { \__tblr_data_key_to_int:nnn {#1} {#2} {#3} } + { \__tblr_data_value_to_int:nnn {#1} {#3} {#4} } + } +\cs_generate_variant:Nn \__tblr_data_gput_if_larger:nnnn { nnne, nnnV, nene, nenV } + +\cs_new_protected:Npn \__tblr_array_gput_if_larger:Nnn #1 #2 #3 + { + \int_compare:nNnT {#3} > { \intarray_item:Nn #1 {#2} } + { \intarray_gset:Nnn #1 {#2} {#3} } + } +\cs_generate_variant:Nn \__tblr_array_gput_if_larger:Nnn { cnn } + +%% #1: data name; #2: data index; #3: key; #4: value +\cs_new_protected:Npn \__tblr_data_gadd_dimen_value:nnnn #1 #2 #3 #4 + { + \__tblr_array_gadd_value:cnn + { g__tblr_#1_ \int_use:N \g_tblr_level_int _intarray } + { \__tblr_data_key_to_int:nnn {#1} {#2} {#3} } + { \__tblr_data_value_to_int:nnn {#1} {#3} {#4} } + } +\cs_generate_variant:Nn \__tblr_data_gadd_dimen_value:nnnn { nnne, nnnV, nene } + +\cs_new_protected:Npn \__tblr_array_gadd_value:Nnn #1 #2 #3 + { + \intarray_gset:Nnn #1 {#2} { \intarray_item:Nn #1 {#2} + #3 } + } +\cs_generate_variant:Nn \__tblr_array_gadd_value:Nnn { cnn } + +\bool_new:N \g__tblr_use_intarray_bool +%\bool_set_true:N \g__tblr_use_intarray_bool + +\AtBeginDocument + { + \bool_if:NF \g__tblr_use_intarray_bool + { + \cs_set_protected:Npn \__tblr_data_gput:nnnn #1 #2 #3 #4 + { + \__tblr_prop_gput:nnn {#1} { [#2] / #3 } {#4} + } + \cs_set:Npn \__tblr_data_item:nnn #1 #2 #3 + { + \__tblr_prop_item:nn {#1} { [#2] / #3 } + } + \cs_set_protected:Npn \__tblr_data_log:n #1 + { + \__tblr_prop_log:n {#1} + } + \cs_set_protected:Npn \__tblr_data_gput_if_larger:nnnn #1 #2 #3 #4 + { + \__tblr_prop_gput_if_larger:nnn {#1} { [#2] / #3 } {#4} + } + \cs_set_protected:Npn \__tblr_data_gadd_dimen_value:nnnn #1 #2 #3 #4 + { + \__tblr_prop_gadd_dimen_value:nnn {#1} { [#2] / #3 } {#4} + } + } + } + +%%% -------------------------------------------------------- %% \section{Child Selectors} %%% -------------------------------------------------------- @@ -1257,19 +1507,19 @@ { \int_use:N \c@rownum } { valign } {f}, bg .code:n = \__tblr_set_key_for_every_row_cell:nnn { \int_use:N \c@rownum } { background } {#1}, - ht .code:n = \__tblr_prop_gput:nxx { row } - { [\int_use:N \c@rownum] / height } { \dim_eval:n {#1} }, - co .code:n = \__tblr_prop_gput:nxx { row } - { [\int_use:N \c@rownum] / coefficient } {#1}, - abovesep .code:n = \__tblr_prop_gput:nxx { row } - { [\int_use:N \c@rownum] / abovesep } { \dim_eval:n {#1} }, - belowsep .code:n = \__tblr_prop_gput:nxx { row } - { [\int_use:N \c@rownum] / belowsep } { \dim_eval:n {#1} }, + ht .code:n = \__tblr_data_gput:nene { row } { \int_use:N \c@rownum } + { height } { \dim_eval:n {#1} }, + co .code:n = \__tblr_data_gput:nene { row } { \int_use:N \c@rownum } + { coefficient } {#1}, + abovesep .code:n = \__tblr_data_gput:nene { row } { \int_use:N \c@rownum } + { abovesep } { \dim_eval:n {#1} }, + belowsep .code:n = \__tblr_data_gput:nene { row } { \int_use:N \c@rownum } + { belowsep } { \dim_eval:n {#1} }, rowsep .meta:n = { abovesep = #1, belowsep = #1}, - abovesep+ .code:n = \__tblr_prop_gadd_dimen_value:nxx { row } - { [\int_use:N \c@rownum] / abovesep } { \dim_eval:n {#1} }, - belowsep+ .code:n = \__tblr_prop_gadd_dimen_value:nxx { row } - { [\int_use:N \c@rownum] / belowsep } { \dim_eval:n {#1} }, + abovesep+ .code:n = \__tblr_data_gadd_dimen_value:nene { row } + { \int_use:N \c@rownum } { abovesep } { \dim_eval:n {#1} }, + belowsep+ .code:n = \__tblr_data_gadd_dimen_value:nene { row } + { \int_use:N \c@rownum } { belowsep } { \dim_eval:n {#1} }, rowsep+ .meta:n = { abovesep+ = #1, belowsep+ = #1}, nobreak .code:n = \__tblr_prop_gput:nxx { row } { [\int_eval:n {\c@rownum - 1}] / nobreak } { true }, @@ -1289,8 +1539,8 @@ { \regex_match:NnTF \c__tblr_is_number_key_regex {#1} { - \__tblr_prop_gput:nxx { row } - { [\int_use:N \c@rownum] / coefficient } {#1} + \__tblr_data_gput:nene { row } { \int_use:N \c@rownum } + { coefficient } {#1} } { \regex_match:NnTF \c__tblr_is_color_key_regex {#1} @@ -1300,8 +1550,8 @@ } { \tl_set_rescan:Nnn \l__tblr_v_tl {} {#1} - \__tblr_prop_gput:nxx { row } - { [\int_use:N \c@rownum] / height } { \dim_eval:n { \l__tblr_v_tl } } + \__tblr_data_gput:nene { row } { \int_use:N \c@rownum } + { height } { \dim_eval:n { \l__tblr_v_tl } } } } } @@ -1397,10 +1647,8 @@ { \tl_if_blank:nF { #1 } { - \__tblr_prop_gput:nxx - { row } - { [\int_use:N \c@rownum] / abovesep } - { \dim_eval:n { #1 } } + \__tblr_data_gput:nene { row } { \int_use:N \c@rownum } + { abovesep } { \dim_eval:n { #1 } } } \tl_if_blank:nF { #2 } { @@ -1459,10 +1707,8 @@ { \tl_if_blank:nF { #1 } { - \__tblr_prop_gput:nxx - { row } - { [\int_eval:n {\c@rownum - 1}] / belowsep } - { \dim_eval:n { #1 } } + \__tblr_data_gput:nene { row } { \int_eval:n {\c@rownum - 1} } + { belowsep } { \dim_eval:n {#1} } } \tl_if_blank:nF { #2 } { @@ -1659,6 +1905,7 @@ \__tblr_enable_table_commands: \__tblr_split_table:n { #3 } \LogTblrTracing { command } + \bool_if:NT \g__tblr_use_intarray_bool { \__tblr_initial_table_data: } \__tblr_initial_table_spec: \LogTblrTracing { table } \__tblr_parse_table_spec:n { #2 } @@ -1761,8 +2008,8 @@ { \IfValueT { #1 } { - \__tblr_prop_gadd_dimen_value:nxx { row } - { [\int_eval:n {\c@rownum - 1}] / belowsep } { #1 } + \__tblr_data_gadd_dimen_value:nene { row } + { \int_eval:n {\c@rownum - 1} } { belowsep } {#1} } } @@ -1974,7 +2221,7 @@ { \prop_map_inline:cn { g__tblr_default_ \l__tblr_env_name_tl _rows_prop } { - \__tblr_prop_gput:nxn { row } { [\l__tblr_i_tl] / ##1 } {##2} + \__tblr_data_gput:nVnn { row } \l__tblr_i_tl {##1} {##2} } \prop_map_inline:cn { g__tblr_default_ \l__tblr_env_name_tl _hlines_prop } { @@ -2030,13 +2277,16 @@ \clist_new:N \g__tblr_table_known_keys_clist \clist_gset:Nn \g__tblr_table_known_keys_clist { - colspec, rowspec, width, hspan, stretch, + long, colspec, rowspec, width, hspan, stretch, column, row, cell, vline, hline, columns, rows, cells, vlines, hlines, leftsep, rightsep, colsep, abovesep, belowsep, rowsep, } +\bool_new:N \l__tblr_long_table_bool + \keys_define:nn { tblr } { + long .bool_set:N = \l__tblr_long_table_bool, colspec .code:n = \__tblr_parse_colrow_spec:nn { column } {#1}, rowspec .code:n = \__tblr_parse_colrow_spec:nn { row } {#1}, width .code:n = \__tblr_keys_gput:nx { width } { \dim_eval:n {#1} }, @@ -2322,11 +2572,11 @@ \int_incr:N \c@rownum \int_zero:N \c@colnum \tl_set:Nx \l__tblr_h_tl - { \__tblr_prop_item:ne { row } { [\int_use:N \c@rownum] / height } } + { \__tblr_data_item:nen { row } { \int_use:N \c@rownum } { height } } \tl_if_empty:NF \l__tblr_h_tl { - \__tblr_prop_gput:nxV { row } - { [\int_use:N \c@rownum] / @row-height } \l__tblr_h_tl + \__tblr_data_gput:nenV { row } { \int_use:N \c@rownum } + { @row-height } \l__tblr_h_tl } \int_step_inline:nn { \c@colcount } { @@ -2524,16 +2774,18 @@ \tl_set:Nx \l__tblr_u_tl { \dim_use:N #5 } \tl_set:Nx \l__tblr_v_tl { \dim_eval:n { #4 - #5 } } %% Update the head size of the first span row here - \__tblr_prop_gput_if_larger:nxx { row } - { [#1] / @row-head } { \dim_use:N #5 } + \__tblr_data_gput_if_larger:nene + { row } {#1} { @row-head } { \dim_use:N #5 } } \c__tblr_valign_f_tl { \tl_set:Nx \l__tblr_u_tl { \dim_eval:n { #4 - #6 } } \tl_set:Nx \l__tblr_v_tl { \dim_use:N #6 } %% Update the foot size of the last span row here - \__tblr_prop_gput_if_larger:nxx { row } - { [\int_eval:n { #1 + \l__tblr_r_tl - 1 }] / @row-foot } + \__tblr_data_gput_if_larger:nene + { row } + { \int_eval:n { #1 + \l__tblr_r_tl - 1 } } + { @row-foot } { \dim_use:N #6 } } \c__tblr_valign_m_tl @@ -2560,53 +2812,51 @@ \group_begin: %% Note that \l__tblr_h_tl may be empty \tl_set:Nx \l__tblr_h_tl - { \__tblr_prop_item:ne { row } { [#1] / @row-height } } + { \__tblr_data_item:nen { row } {#1} { @row-height } } \tl_if_eq:NNTF \g__tblr_cell_valign_tl \c__tblr_valign_m_tl { \tl_set:Nx \l__tblr_a_tl - { \__tblr_prop_item:ne { row } { [#1] / @row-upper } } + { \__tblr_data_item:nen { row } {#1} { @row-upper } } \tl_set:Nx \l__tblr_b_tl - { \__tblr_prop_item:ne { row } { [#1] / @row-lower } } + { \__tblr_data_item:nen { row } {#1} { @row-lower } } \__tblr_get_middle_cell_upper_lower:NNNNN #3 #4 #5 \l__tblr_u_tl \l__tblr_v_tl \dim_compare:nNnT { \l__tblr_u_tl } > { \l__tblr_a_tl } { \tl_set_eq:NN \l__tblr_a_tl \l__tblr_u_tl - \__tblr_prop_gput:nxV { row } - { [#1] / @row-upper } \l__tblr_a_tl + \__tblr_data_gput:nenV { row } {#1} { @row-upper } \l__tblr_a_tl } \dim_compare:nNnT { \l__tblr_v_tl } > { \l__tblr_b_tl } { \tl_set_eq:NN \l__tblr_b_tl \l__tblr_v_tl - \__tblr_prop_gput:nxV { row } - { [#1] / @row-lower } \l__tblr_b_tl + \__tblr_data_gput:nenV { row } {#1} { @row-lower } \l__tblr_b_tl } \dim_compare:nNnT { \l__tblr_a_tl + \l__tblr_b_tl } > { \l__tblr_h_tl + 0pt } { - \__tblr_prop_gput:nxx { row } { [#1] / @row-height } + \__tblr_data_gput:nene { row } {#1} { @row-height } { \dim_eval:n { \l__tblr_a_tl + \l__tblr_b_tl } } } } { \tl_set:Nx \l__tblr_e_tl - { \__tblr_prop_item:ne { row } { [#1] / @row-head } } + { \__tblr_data_item:nen { row } {#1} { @row-head } } \tl_set:Nx \l__tblr_f_tl - { \__tblr_prop_item:ne { row } { [#1] / @row-foot } } + { \__tblr_data_item:nen { row } {#1} { @row-foot } } \dim_compare:nNnT {#4} > {\l__tblr_e_tl} { - \__tblr_prop_gput:nxx { row } { [#1] / @row-head } { \dim_use:N #4 } + \__tblr_data_gput:nene { row } {#1} { @row-head } { \dim_use:N #4 } } \dim_compare:nNnT {#5} > {\l__tblr_f_tl} { - \__tblr_prop_gput:nxx { row } { [#1] / @row-foot } { \dim_use:N #5 } + \__tblr_data_gput:nene { row } {#1} { @row-foot } { \dim_use:N #5 } } \tl_set:Nx \l__tblr_x_tl { \dim_max:nn {#4} { \l__tblr_e_tl } } \tl_set:Nx \l__tblr_y_tl { \dim_max:nn {#5} { \l__tblr_f_tl } } \dim_compare:nNnT { #3 - #4 - #5 } > { \l__tblr_h_tl - \l__tblr_x_tl - \l__tblr_y_tl } { - \__tblr_prop_gput:nxx { row } { [#1] / @row-height } + \__tblr_data_gput:nene { row } {#1} { @row-height } { \dim_eval:n { @@ -2647,20 +2897,20 @@ \prop_new:N \l__column_computed_width_prop \msg_new:nnn { tabularray } { table-width-too-small } - { Table ~ width ~ is ~ too ~ small, need ~ #1 ~ more! } + { Table ~ width ~ is ~ too ~ small, ~ need ~ #1 ~ more! } \cs_new_protected:Npn \__tblr_compute_extendable_column_width: { \__tblr_collect_extendable_column_width: - \dim_compare:nNnTF { \l__column_target_dim } > { 0pt } - { - \prop_if_empty:NF \l__column_coefficient_prop - { \__tblr_adjust_extendable_column_width: } - } + \dim_compare:nNnTF { \l__column_target_dim } < { 0pt } { \msg_warning:nnx { tabularray } { table-width-too-small } { \dim_abs:n { \l__column_target_dim } } } + { + \prop_if_empty:NF \l__column_coefficient_prop + { \__tblr_adjust_extendable_column_width: } + } } \cs_new_protected:Npn \__tblr_collect_extendable_column_width: @@ -2878,14 +3128,13 @@ { \dim_eval:n { - \__tblr_prop_item:ne {row} - { [\int_eval:n {\l__tblr_i_tl - 1}] / belowsep } + \__tblr_data_item:nen { row } + { \int_eval:n {\l__tblr_i_tl - 1} } { belowsep } + \__tblr_prop_item:ne {hline} { [\l__tblr_i_tl] / @hline-height } + - \__tblr_prop_item:ne {row} - { [\l__tblr_i_tl] / abovesep } + \__tblr_data_item:nen { row } { \l__tblr_i_tl } { abovesep } } } } @@ -2904,7 +3153,7 @@ %% #1: row number; #2: tl with result \cs_new_protected:Npn \__tblr_collect_one_row_height:NN #1 #2 { - \tl_set:Nx #2 { \__tblr_prop_item:ne { row } { [#1] / @row-height } } + \tl_set:Nx #2 { \__tblr_data_item:nen { row } {#1} { @row-height } } } \cs_new_protected:Npn \__tblr_collect_span_widths: @@ -2963,8 +3212,8 @@ { \tl_set:Nx \l__tblr_h_tl { - \__tblr_prop_item:ne {row} - { [\l__tblr_i_tl] / @row-head } + \__tblr_data_item:nen { row } + { \l__tblr_i_tl } { @row-head } } \__tblr_prop_gput:nxV {cell} { [\l__tblr_i_tl][\l__tblr_j_tl] / @cell-height } @@ -2974,11 +3223,10 @@ { \tl_set:Nx \l__tblr_d_tl { - \__tblr_prop_item:ne {row} - { - [\int_eval:n {\l__tblr_i_tl + \l__tblr_a_tl - 1}] - / @row-foot - } + \__tblr_data_item:nen + { row } + { \int_eval:n { \l__tblr_i_tl + \l__tblr_a_tl - 1 } } + { @row-foot } } \__tblr_prop_gput:nxV {cell} { [\l__tblr_i_tl][\l__tblr_j_tl] / @cell-depth } @@ -3104,19 +3352,19 @@ { \tl_set:Nx \l__tblr_h_tl { - \__tblr_prop_item:ne {row} { [\l__tblr_i_tl] / @row-head } + \__tblr_data_item:nen { row } { \l__tblr_i_tl } { @row-head } } \tl_set:Nx \l__tblr_d_tl { - \__tblr_prop_item:ne {row} { [\l__tblr_i_tl] / @row-foot } + \__tblr_data_item:nen { row } { \l__tblr_i_tl } { @row-foot } } \tl_set:Nx \l__tblr_a_tl { \prop_item:Ne \l__tblr_row_item_skip_size_prop { item[\l__tblr_i_tl] } } \__tblr_collect_one_row_height:NN \l__tblr_i_tl \l__tblr_t_tl - \__tblr_prop_gput:nxx {row} - { [\l__tblr_i_tl] / @row-height } { \l__tblr_a_tl } + \__tblr_data_gput:nene { row } + { \l__tblr_i_tl } { @row-height } { \l__tblr_a_tl } } } @@ -3179,20 +3427,95 @@ \box_new:N \l__tblr_table_box +%% #1: table alignment \cs_new_protected:Npn \__tblr_build_whole:n #1 { + \bool_if:NTF \l__tblr_long_table_bool + { \__tblr_build_long_table:n {#1} } + { \__tblr_build_short_table:n {#1} } + } + +\dim_new:N \l__tblr_remain_height_dim +\tl_new:N \l__tblr_long_from_tl + +\cs_new_protected:Npn \__tblr_build_long_table:n #1 + { + %\dim_log:N \pagegoal + %\dim_log:N \pagetotal + \dim_set:Nn \l__tblr_remain_height_dim { \pagegoal - \pagetotal } + \tl_set:Nn \l__tblr_long_from_tl {1} + \int_step_variable:nNn { \c@rowcount } \l__tblr_i_tl + { + \dim_set:Nn \l_tmpa_dim + { + \__tblr_prop_item:ne { hline } { [\l__tblr_i_tl] / @hline-height } + + + \__tblr_data_item:nen { row } { \l__tblr_i_tl } { abovesep } + + + \__tblr_data_item:nen { row } { \l__tblr_i_tl } { @row-height } + + + \__tblr_data_item:nen { row } { \l__tblr_i_tl } { belowsep } + } + \dim_compare:nNnTF + { \l_tmpa_dim } > { \l__tblr_remain_height_dim } + { + \tl_log:N \l__tblr_i_tl + \__tblr_build_page_table:nnx {#1} + { \l__tblr_long_from_tl } { \int_eval:n { \l__tblr_i_tl - 1 } } + \newpage + \hbox{}\kern-\topskip\nobreak + \leavevmode + %\dim_log:N \pagegoal + %\dim_log:N \pagetotal + \dim_set:Nn \l__tblr_remain_height_dim + { \pagegoal - \pagetotal - \l_tmpa_dim } + \tl_set_eq:NN \l__tblr_long_from_tl \l__tblr_i_tl + } + { + \dim_add:Nn \l__tblr_remain_height_dim { -\l_tmpa_dim } + } + } + \__tblr_build_page_table:nnn {#1} { \l__tblr_long_from_tl } { \c@rowcount } + } + +\cs_new_protected:Npn \__tblr_build_page_table:nnn #1 #2 #3 + { + \__tblr_build_one_table:nn {#2} {#3} + \__tblr_halign_whole:Nn \l__tblr_table_box #1 + } +\cs_generate_variant:Nn \__tblr_build_page_table:nnn { nnx } + +\cs_new_protected:Npn \__tblr_halign_whole:Nn #1 #2 + { + \noindent + \hbox_to_wd:nn { \linewidth } + { + \tl_if_eq:nnF {#2} {l} { \hfil } + \box_use:N #1 + \tl_if_eq:nnF {#2} {r} { \hfil } + } + } + +\cs_new_protected:Npn \__tblr_build_short_table:n #1 + { + \__tblr_build_one_table:nn {1} {\c@rowcount} + \__tblr_valign_whole:Nn \l__tblr_table_box #1 + } + +%% #1: row from; #2: row to +\cs_new_protected:Npn \__tblr_build_one_table:nn #1 #2 + { \vbox_set:Nn \l__tblr_table_box { - \int_step_variable:nNn { \c@rowcount } \l__tblr_i_tl + \int_step_variable:nnNn {#1} {#2} \l__tblr_i_tl { \hbox:n { \__tblr_build_hline:V \l__tblr_i_tl } \hrule height ~ 0pt % remove lineskip between hlines and rows \hbox:n { \__tblr_build_row:N \l__tblr_i_tl } \hrule height ~ 0pt } - \hbox:n { \__tblr_build_hline:n { \int_eval:n {\c@rowcount + 1} } } + \hbox:n { \__tblr_build_hline:n { \int_eval:n {#2 + 1} } } } - \__tblr_valign_whole:Nn \l__tblr_table_box #1 } \cs_new_protected:Npn \__tblr_valign_whole:Nn #1 #2 @@ -3233,13 +3556,13 @@ { \dim_set:Nn \l__tblr_h_dim { - \__tblr_prop_item:ne { row } { [1] / abovesep } + \__tblr_data_item:nnn { row } {1} { abovesep } + - ( \__tblr_prop_item:ne { row } { [1] / @row-height } + ( \__tblr_data_item:nnn { row } {1} { @row-height } + - \__tblr_prop_item:ne { row } { [1] / @row-upper } + \__tblr_data_item:nnn { row } {1} { @row-upper } - - \__tblr_prop_item:ne { row } { [1] / @row-lower } + \__tblr_data_item:nnn { row } {1} { @row-lower } ) / 2 } \dim_set:Nn \l__tblr_d_dim { \l__tblr_t_dim - \l__tblr_h_dim } @@ -3269,17 +3592,17 @@ { \dim_set:Nn \l__tblr_d_dim { - ( \__tblr_prop_item:ne { row } - { [\int_use:N \c@rowcount] / @row-height } + ( \__tblr_data_item:nen { row } + { \int_use:N \c@rowcount } { @row-height } - - \__tblr_prop_item:ne { row } - { [\int_use:N \c@rowcount] / @row-upper } + \__tblr_data_item:nen { row } + { \int_use:N \c@rowcount } { @row-upper } + - \__tblr_prop_item:ne { row } - { [\int_use:N \c@rowcount] / @row-lower } + \__tblr_data_item:nen { row } + { \int_use:N \c@rowcount } { @row-lower } ) / 2 + - \__tblr_prop_item:ne { row } { [1] / belowsep } + \__tblr_data_item:nnn { row } {1} { belowsep } } \dim_set:Nn \l__tblr_h_dim { \l__tblr_t_dim - \l__tblr_d_dim } } @@ -3412,16 +3735,16 @@ \cs_new_protected:Npn \__tblr_get_row_inner_height_depth:nNNNN #1 #2 #3 #4 #5 { \dim_set:Nn #4 - { \__tblr_prop_item:ne { row } { [#1] / abovesep } } + { \__tblr_data_item:nen { row } {#1} { abovesep } } \dim_set:Nn #5 - { \__tblr_prop_item:ne { row } { [#1] / belowsep } } + { \__tblr_data_item:nen { row } {#1} { belowsep } } \dim_set:Nn \l__row_upper_dim - { \__tblr_prop_item:ne { row } { [#1] / @row-upper } } + { \__tblr_data_item:nen { row } {#1} { @row-upper } } \dim_set:Nn \l__row_lower_dim - { \__tblr_prop_item:ne { row } { [#1] / @row-lower } } + { \__tblr_data_item:nen { row } {#1} { @row-lower } } \dim_set:Nn \l__row_vpace_dim { - ( \__tblr_prop_item:ne { row } { [#1] / @row-height } + ( \__tblr_data_item:nen { row } {#1} { @row-height } - \l__row_upper_dim - \l__row_lower_dim ) / 2 } \dim_set:Nn #2 { #4 + \l__row_vpace_dim + \l__row_upper_dim } @@ -3507,7 +3830,7 @@ \tl_set:Nx \l__tblr_w_tl { \__tblr_prop_item:ne { column } { [#2] / @col-width } } \tl_set:Nx \l__tblr_h_tl - { \__tblr_prop_item:ne { row } { [#1] / @row-height } } + { \__tblr_data_item:nen { row } {#1} { @row-height } } \tl_set:Nx \l__tblr_x_tl { \__tblr_prop_item:ne { column } { [#2] / leftsep} } \tl_set:Nx \l__tblr_y_tl @@ -3552,9 +3875,9 @@ \tl_if_empty:NT \l__tblr_cell_rowspan_tl { \box_set_ht:Nn \l__tblr_a_box - { \__tblr_prop_item:ne { row } { [#1] / @row-upper } } + { \__tblr_data_item:nen { row } {#1} { @row-upper } } \box_set_dp:Nn \l__tblr_a_box - { \__tblr_prop_item:ne { row } { [#1] / @row-lower } } + { \__tblr_data_item:nen { row } {#1} { @row-lower } } } \box_use:N \l__tblr_a_box \vfil @@ -3562,7 +3885,7 @@ \c__tblr_valign_h_tl { \box_set_ht:Nn \l__tblr_a_box - { \__tblr_prop_item:ne { row } { [#1] / @row-head } } + { \__tblr_data_item:nen { row } {#1} { @row-head } } \box_use:N \l__tblr_a_box \vfil } @@ -3572,16 +3895,15 @@ \tl_if_empty:NTF \l__tblr_cell_rowspan_tl { \box_set_dp:Nn \l__tblr_a_box - { \__tblr_prop_item:ne { row } { [#1] / @row-foot } } + { \__tblr_data_item:nen { row } {#1} { @row-foot } } } { \box_set_dp:Nn \l__tblr_a_box { - \__tblr_prop_item:ne { row } - { - [\int_eval:n {#1 + \l__tblr_cell_rowspan_tl - 1}] - / @row-foot - } + \__tblr_data_item:nen + { row } + { \int_eval:n { #1 + \l__tblr_cell_rowspan_tl - 1 } } + { @row-foot } } } \box_use:N \l__tblr_a_box @@ -3664,7 +3986,7 @@ \cs_new_protected:Npn \__tblr_get_span_vertical_sizes:NNNNN #1 #2 #3 #4 #5 { \dim_set:Nn #3 - { \__tblr_prop_item:ne { row } { [#1] / abovesep } } + { \__tblr_data_item:nen { row } {#1} { abovesep } } \dim_zero:N #4 \int_step_inline:nnn { #1 } { #1 + \l__tblr_cell_rowspan_tl - 2 } { @@ -3678,8 +4000,8 @@ } \dim_set:Nn #5 { - \__tblr_prop_item:ne { row } - { [\int_eval:n {#1 + \l__tblr_cell_rowspan_tl - 1}] / belowsep } + \__tblr_data_item:nen { row } + { \int_eval:n { #1 + \l__tblr_cell_rowspan_tl - 1 } } { belowsep } } %\tl_log:x { cell[#1][#2] ~:~ \dim_use:N #3, \dim_use:N #4, \dim_use:N #5 } } @@ -3841,7 +4163,7 @@ \cs_new_protected:Npn \__tblr_log_tracing_row: { - \__tblr_prop_log:n { row } + \__tblr_data_log:n { row } } \cs_new_protected:Npn \__tblr_log_tracing_cell: @@ -3894,4 +4216,3 @@ } \ExplSyntaxOff - |