Open lvjr opened 1 year ago
Also raised in
Row/Column type @
is implemented using text
row/column option, so they indeed reported the same bug.
https://github.com/lvjr/tabularray/blob/9f5b008556c6feea2c39b005cacd7f3a1da76f1c/tabularray.sty#L2543
Currently (version 2024A) the value passed to text
column option is first stored in \l__tblr_vline_dash_tl
with prefix \exp_not:N \@tblr@text
, then that tl
is fully expanded by \__tblr_spec_gput:nee
used in \__tblr_set_vline_cmd:n
(see lines 1589 to 1591 in second snippet below). If the passed text
value is not fully expandable, error is raised.
https://github.com/lvjr/tabularray/blob/9f5b008556c6feea2c39b005cacd7f3a1da76f1c/tabularray.sty#L1559-L1560 https://github.com/lvjr/tabularray/blob/9f5b008556c6feea2c39b005cacd7f3a1da76f1c/tabularray.sty#L1569-L1581
Value passed to text
row option is treated similarly, stored in \l__tblr_hline_dash_tl
with prefix and fully expanded by \__tblr_spec_gput:nee
used in \__tblr_set_hline_option:nnn
, which is used in \__tblr_set_hline_cmd:n
.
text
row optionhttps://github.com/lvjr/tabularray/blob/9f5b008556c6feea2c39b005cacd7f3a1da76f1c/tabularray.sty#L1317-L1318 https://github.com/lvjr/tabularray/blob/9f5b008556c6feea2c39b005cacd7f3a1da76f1c/tabularray.sty#L1349-L1354 https://github.com/lvjr/tabularray/blob/9f5b008556c6feea2c39b005cacd7f3a1da76f1c/tabularray.sty#L1400-L1405
One solution is to store \exp_not:N \@tblr@text \exp_not:n {<text value>}
in \l__tblr_(h|v)line_dash_tl
.
```diff
From 9ae91b77b66374606bb920e224496dc3c32c56d1 Mon Sep 17 00:00:00 2001
From: Yukai Chou
```tex \documentclass{article} \usepackage{tabularray} \makeatletter \ExplSyntaxOn \keys_define:nn { tblr-hline } { text .code:n = \tl_set:Nn \l__tblr_hline_dash_tl { \exp_not:N \@tblr@text \exp_not:n {#1} }, } \keys_define:nn { tblr-vline } { text .code:n = \tl_set:Nn \l__tblr_vline_dash_tl { \exp_not:N \@tblr@text \exp_not:n {#1} }, } \cs_undefine:N \tblr_set_hline:nnn \cs_new_protected:Npn \tblr_set_hline:nnn #1 #2 #3 { \group_begin: \keys_set_groups:nnn { tblr-hline } { text } {#3} \tl_if_eq:NnF \l__tblr_hline_dash_tl { \exp_not:N \@tblr@text \exp_not:n {} } { \__tblr_set_hline_num:n {#1} \tl_clear:N \l__tblr_hline_dash_tl \keys_set:nn { tblr-hline } { dash = solid, #3 } \__tblr_set_hline_cmd:n {#2} } \group_end: } \cs_undefine:N \tblr_set_vline:nnn \cs_new_protected:Npn \tblr_set_vline:nnn #1 #2 #3 { \group_begin: \keys_set_groups:nnn { tblr-vline } { text } {#3} \tl_if_eq:NnF \l__tblr_vline_dash_tl { \exp_not:N \@tblr@text \exp_not:n {} } { \__tblr_set_vline_num:n {#1} \tl_clear:N \l__tblr_vline_dash_tl \keys_set:nn { tblr-vline } { dash = solid, #3 } \__tblr_set_vline_cmd:n {#2} } \group_end: } \ExplSyntaxOff \makeatother \begin{document} \SetTblrInner{cells = {preto={\small (\therownum, \thecolnum)}}} \begin{tblr}{hlines, vlines} & & \\ \\ \\ \end{tblr} \qquad % \begin{tblr}{ hlines = {text = {\bfseries ---h---}}, vlines = {text = {\fontfamily{pcr}\selectfont v}} } & & \\ \\ \\ \end{tblr} \qquad % % empty text \begin{tblr}{ hlines = {text = }, vlines = {text = } } & & \\ \\ \\ \end{tblr} \end{document} ``` ![image](https://github.com/lvjr/tabularray/assets/6376638/6a5cc552-cc63-4f2d-b44e-6f65fc29f1fa)
Another solution is to do \__tblr_spec_gput:neV { ... } { ... } \l__tblr_(h|v)line_dash_tl
but then the logic detecting and skipping \@tblr@dash
and/or \@tblr@text
need adaption.
Perhaps \@tblr@dash
and \@tblr@text
can be replaced with expl3 quark or scan mark variables.
@wwojciech As workarounds, apart from hiding text
value in commands that can survive full expansion (https://github.com/lvjr/tabularray/discussions/484#discussioncomment-8846612), wrapping text
value in \unexpanded{...}
also works.
\documentclass{article}
\usepackage{tabularray}
\begin{document}
\begin{tblr}{hlines, vlines}
& & \\
\\
\\
\end{tblr}
\qquad
%
% workaround: use only protected commands in text
\protected\def\myHlineTextStyle{\bfseries}
\protected\def\myVlineTextStyle{\fontfamily{pcr}\selectfont}
\begin{tblr}{
hlines = {text={\myHlineTextStyle ---h---}},
vlines = {text={\myVlineTextStyle v}}
}
& & \\
\\
\\
\end{tblr}
\qquad
%
% workaround: wrap text in \unexpanded{...}
\begin{tblr}{
hlines = {text = {\unexpanded{\bfseries ---h---}}},
vlines = {text = {\unexpanded{\fontfamily{pcr}\selectfont v}}}
}
& & \\
\\
\\
\end{tblr}
\end{document}
From https://tex.stackexchange.com/questions/648880/settblrinnertblrcells-bg-cant-change-the-background-color-in-tabularr
The above code produces the following error: