Open philippewarren opened 12 months ago
An attempt that adds two new span options to row=<selector>
and to col=<selector>
.
For a 4x5 tabular, the three (inner style) settings below are equivalent to each other:
cell{2}{2}={r=2,c=3}{<styles>}
cell{2}{2}={to row=3, to col=4}{<styles>}
cell{2}{2}={to row=Y, to col=Y}{<styles>}
```tex \documentclass[twocolumn]{article} \usepackage{tabularray} \usepackage{xcolor} \makeatletter \ExplSyntaxOn % can be replaced by two temp tl args % (I'm not familiar enough with tabularray implementation.) \tl_new:N \l__tblr_span_to_row_tl \tl_new:N \l__tblr_span_to_col_tl \keys_define:nn { tblr-cell-span } { % both are inclusive to~row .code:n = { \group_begin: \tl_set:Nx \l_tblr_childs_total_tl { \int_use:N \c@rowcount } \__tblr_child_name_to_index:nN {#1} \l__tblr_span_to_row_tl \use:e { \group_end: \int_compare:nNnF {\l__tblr_span_to_row_tl} < {\c@rownum} { \tl_set:Nn \exp_not:N \l__tblr_row_span_num_tl { \int_eval:n { \l__tblr_span_to_row_tl - \c@rownum + 1 } } } } }, to~col .code:n = { % is it safe to alter \l_tblr_childs_total_tl directly (not without an extra group)? \group_begin: \tl_set:Nx \l_tblr_childs_total_tl { \int_use:N \c@colcount } \__tblr_child_name_to_index:nN {#1} \l__tblr_span_to_col_tl \use:e { \group_end: \int_compare:nNnF {\l__tblr_span_to_col_tl} < {\c@colnum} { \tl_set:Nn \exp_not:N \l__tblr_col_span_num_tl { \int_eval:n { \l__tblr_span_to_col_tl - \c@colnum + 1 } } } } } } \ExplSyntaxOff \makeatother \SetTblrInner{ cells={preto={(\therownum, \thecolnum)}}, hline{1,Z}, vline{1,Z}, baseline=T } \begin{document} \newcommand\testSpan[3]{ \noindent\texttt{\detokenize{cell#1={#2}{...}}}\par \begin{tblr}{ cell#1={#2}{m,c,font=\large\bfseries} } #3 \end{tblr} \par\medskip } \testSpan{{2}{2}}{r=2, c=3} {& & & & \\ \\ \\ \\} % size is 4x5 \testSpan{{2}{2}}{to row=3, to col=4}{& & & & \\ \\ \\ \\} \testSpan{{2}{2}}{to row=Y, to col=Y}{& & & & \\ \\ \\ \\} \testSpan{{2}{2}}{to row=Y, to col=Y}{& & & & & \\ \\ \\ \\ \\} % 5x6 \newpage % degenerated cases \testSpan{{2}{3}}{to row=Z, to col=Z}{& & & \\ \\ \\} % 3x4 \testSpan{{2}{3}}{to row=Z, to col=Z}{& & \\ \\ \\} % 3x3 \testSpan{{2}{3}}{to row=Z, to col=Z}{& & & \\ \\} % 2x4 \testSpan{{2}{3}}{to row=Z, to col=Z}{& & \\ \\} % 2x3 \end{document} ```
Another option is to provide a new inner option span{<row range>}{<col range>}={<styles>}
.
If multiple-word key names are needed, I would prefer to use dash characters instead of space characters in the names (like nicematrix
and siunitx
).
Let me clarify: I was thinking about cell spans in the \SetCell
command.
From its syntax\SetCell[<span>]{<styles>}
, \SetCell[to row=<selector>, to col=<selector>]{<styles>}
(or the to-row=..., to-col=...
form) is supported in my (first) attempt in https://github.com/lvjr/tabularray/issues/417#issuecomment-1627829786.
From its syntax
\SetCell[<span>]{<styles>}
,\SetCell[to row=<selector>, to col=<selector>]{<styles>}
(or theto-row=..., to-col=...
form) is supported in my (first) attempt in #417 (comment).
Great! It was just to be sure since you were using a different syntax in your examples.
I think there is no need to add to-row
and to-col
keys, because it is just a simple application of future keyvalue
library (see https://github.com/lvjr/tabularray/issues/270).
Allowing U-Z special values as row selectors for cell span would be useful when you have a cell that sould expand when new rows are added to the table.