Closed qinglee closed 2 years ago
- \__tblr_save_counters:n { cell }
- \vbox_set_top:Nn \l_tmpa_box { \__tblr_make_vcell_text:NN #1 #2 }
- \__tblr_restore_counters:n { cell }
\vbox_set:Nn \l_tmpb_box { \__tblr_make_vcell_text:NN #1 #2 }
+ \vbox_set_top:Nn \l_tmpa_box { \vbox_unpack:N \l_tmpb_box }
Thank you! it is a great idea to use \vbox_unpack:N
. I didn't know I can use it before. And the change will make the table building process run faster.
I am wondering maybe we can step further by directly setting the heights and depths of rows instead of cells. That is to say, we may change the initial values of several internal data for rows:
@row-height
from 0pt
to stretch * \baselinskip
@row-upper
from 0pt
to stretch * 0.7\baselinskip
@row-lower
from 0pt
to stretch * 0.3\baselinskip
In fact we need to use the larger value between \baselinskip
and the row height (which is actually minimal total height) set by an user.
I think this would make tabularray
run even faster since we don't need to adjust dimensions of all cells several times.
- \__tblr_save_counters:n { cell } - \vbox_set_top:Nn \l_tmpa_box { \__tblr_make_vcell_text:NN #1 #2 } - \__tblr_restore_counters:n { cell } \vbox_set:Nn \l_tmpb_box { \__tblr_make_vcell_text:NN #1 #2 } + \vbox_set_top:Nn \l_tmpa_box { \vbox_unpack:N \l_tmpb_box }
Thank you! it is a great idea to use
\vbox_unpack:N
. I didn't know I can use it before. And the change will make the table building process run faster.
I took a quick look at the code and it would improve some performance if we could use \hbox_unpack:N
and \vbox_unpack:N
flexibly where appropriate. The ultimate goal is to actually typeset each cell only once. This will completely fix issues as #231. Obviously, it is a big challenge.
I am wondering maybe we can step further by directly setting the heights and depths of rows instead of cells. That is to say, we may change the initial values of several internal data for rows:
- change
@row-height
from0pt
tostretch * \baselinskip
- change
@row-upper
from0pt
tostretch * 0.7\baselinskip
- change
@row-lower
from0pt
tostretch * 0.3\baselinskip
In fact we need to use the larger value between
\baselinskip
and the row height (which is actually minimal total height) set by an user.I think this would make
tabularray
run even faster since we don't need to adjust dimensions of all cells several times.
Indeed, your solution is more efficient and natural. I do not fully grasp the internal mechanism of tabularray, so I can only provide a preliminary reference.
I took a quick look at the code and it would improve some performance if we could use
\hbox_unpack:N
and\vbox_unpack:N
flexibly where appropriate. The ultimate goal is to actually typeset each cell only once. This will completely fix issues as #231. Obviously, it is a big challenge.
For multicolumn cells and X-column cells, we need to change their widths. So I assume it would be quite difficult to typeset them only once.
That is to say, we may change the initial values of several internal data for rows:
- change
@row-height
from0pt
tostretch * \baselinskip
- change
@row-upper
from0pt
tostretch * 0.7\baselinskip
- change
@row-lower
from0pt
tostretch * 0.3\baselinskip
In fact we need to use the larger value between
\baselinskip
and the row height (which is actually minimal total height) set by an user.
Oh sorry, if user-set-total-height
is greater than stretch*\baselineskip
, only @row-height
need to be enlarged, @row-upper
and @row-lower
remain the same as the above values.
I tried to implement my proposal but found it is not enough to set row dimensions only:
\documentclass{article}
\usepackage{tabularray}
\SetTblrInner{rowsep=0pt}
\usepackage{array}
\begin{document}
\begin{tabular}{p{4cm}}
\hline
The quick brown fox jumps over the lazy dog abcd.\\
\hline
\end{tabular}
\begin{tblr}{p{4cm}}
\hline
The quick brown fox jumps over the lazy dog abcd.\\
\hline
\end{tblr}
\bigskip
\begin{tabular}{b{4cm}}
\hline
pgrs pgrs pgrs pgrs pgrs pgrs pgrs The quick brown fox jumps over the lazy dog abcd.\\
\hline
\end{tabular}
\begin{tblr}{b{4cm}}
\hline
pgrs pgrs pgrs pgrs pgrs pgrs pgrs The quick brown fox jumps over the lazy dog abcd.\\
\hline
\end{tblr}
\end{document}
And your patch generated the expected result with the same code:
Instead of adding struts, we can directly set the height and depth of the cell box.
There is a slight difference from the original behavior, which is to be expected, and I have updated the relevant test files.