Repository navigation
Replies: 1 comment 3 replies
|
It is better to define a new environment, because you can do anything you want without modifying private functions in the package: \documentclass{article}
\usepackage{tabularray}
\begin{document}
\ExplSyntaxOn
\tl_new:N \l__mytest_keyval_tl
\keys_define:nn {mytest}
{
colspec .code:n = \__mytest_store_keyval:no { colspec } {#1},
unknown .code:n = \__mytest_store_keyval:Vn \l_keys_key_str {#1},
}
\cs_new_protected:Npn \__mytest_store_keyval:nn #1 #2
{
\tl_if_empty:nTF {#2}
{ \tl_put_right:Nn \l__mytest_keyval_tl {#1,} }
{ \tl_put_right:Nn \l__mytest_keyval_tl {#1 = {#2},} }
}
\cs_generate_variant:Nn \__mytest_store_keyval:nn {no,Vn}
\NewDocumentEnvironment {mytblr} {O{} m +b}
{
\tl_clear:N \l__mytest_keyval_tl
\keys_set:nn {mytest} {#2}
\tl_set:Nx \l_tmpa_tl
{
\exp_not:n {\begin{tblr}[#1]} {\exp_not:V \l__mytest_keyval_tl}
\exp_not:n {#3}
\exp_not:n {\end{tblr}}
}
\tl_use:N \l_tmpa_tl
} {}
\tl_new:N \l_tmp_colspec_tl
\tl_set:Nn \l_tmp_colspec_tl { r|X }
\begin{mytblr}{colspec=\l_tmp_colspec_tl,hlines,rowsep=1pt}
AAAAAA & Lorem\ ipsum\ dolor\ sit\ amet,\ consectetur\ adipisicing\ elit,\ sed\ do\ eiusmod\ tempor \\
AAA & BBB \\
\end{mytblr}
\ExplSyntaxOff
\end{document} |
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment


Uh oh!
There was an error while loading. Please reload this page.
My requirement is how to get colspec to receive variable values. Here is my exploration process.
As shown above, everything is normal.
I found the function
\__tblr_parse_colrow_spec:nn { column } { }by reading the source code, and I tried to configure the column options by calling the function\__tblr_parse_colrow_spec:nn { column } { }directly.But I got the following results. The vertical bar is not displayed correctly. What causes this?
Then, I directly modify the
tabularray.styfile to generate variant function to the function\__tblr_parse_colrow_spec:nnso as to receive variables.And modified the function corresponding to colspec parameter.
Then we run the following example:
We got the expected result.
In conclusion, my purpose is to use variables to configure column options. If the first example works correctly, then I can pass the variable to the variant function without modifying the
.styfile. At present, I can't find a suitable way to meet my needs.All reactions