Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It failed to use \seq_use:Nn or \clist_use:Nn inside tblr environment #201

Closed
xkwxdyy opened this issue Feb 16, 2022 · 3 comments
Closed

Comments

@xkwxdyy
Copy link

xkwxdyy commented Feb 16, 2022

Here are two MWE:

\documentclass{article}
\usepackage{tabularray}

\ExplSyntaxOn
\NewDocumentCommand{ \test }{ m }
  {
    \seq_set_from_clist:Nn \l_tmpa_seq {#1}
    \begin{tblr}{|c|c|c|c|c|c|c|c|c|c|c|c|}
    % \begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|}
      \hline
      1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12\\ \hline
      \seq_use:Nn \l_tmpa_seq {&} \\
      \hline
    \end{tblr}
    % \end{tabular}
  }
\ExplSyntaxOff
\begin{document}
\test{C,B,B,A,B,D,B,D,ABC,BD,CD,AB}

\end{document}
\documentclass{article}
\usepackage{tabularray}
\begin{document}
\ExplSyntaxOn
\NewDocumentCommand{ \test }{ m }
  {
    \clist_set:Nn \l_tmpa_clist {#1}   
    % \begin{tblr}{|c|c|c|c|c|c|c|c|c|c|c|c|}
    \begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|}
      \hline
      1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12\\ \hline
      \clist_use:Nn \l_tmpa_clist {&} \\
      \hline
    % \end{tblr}
    \end{tabular}
  }
\ExplSyntaxOff
\test{A, B, B, F, D, C, A, D, D, A, C, B}

\end{document}

I was trying to define a command to calculate the points of the paper. I want to use seq or clist module to help me with it. But I found that it failed when I put that inside tblr environment while it worked inside tabular environment.

@lvjr
Copy link
Owner

lvjr commented Feb 16, 2022

See issue #18 and #23. You need to collect table body to a macro and use expand option to expand the macro.

@lvjr
Copy link
Owner

lvjr commented Feb 16, 2022

\documentclass{article}

\usepackage{tabularray}

\ExplSyntaxOn

\NewDocumentCommand{ \test }{ m }
  {
    \seq_set_from_clist:Nn \l_tmpa_seq {#1}
    \tl_set:Nx \tblrbody { \seq_use:Nn \l_tmpa_seq {&} }
    \begin{tblr}[expand=\tblrbody]{|c|c|c|c|c|c|c|c|c|c|c|c|}
      \hline
        1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12\\ \hline
        \tblrbody \\
      \hline
    \end{tblr}
  }

\NewDocumentCommand{ \testb }{ m }
  {
    \clist_set:Nn \l_tmpa_clist {#1}
    \tl_set:Nx \tblrbody { \clist_use:Nn \l_tmpa_clist {&} } 
    \begin{tblr}[expand=\tblrbody]{|c|c|c|c|c|c|c|c|c|c|c|c|}
      \hline
      1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12\\ \hline
      \tblrbody \\
      \hline
    \end{tblr}
  }

\ExplSyntaxOff

\begin{document}

\test{C,B,B,A,B,D,B,D,ABC,BD,CD,AB}

\testb{C,B,B,A,B,D,B,D,ABC,BD,CD,AB}

\end{document}

@xkwxdyy
Copy link
Author

xkwxdyy commented Feb 16, 2022

@lvjr Thanks so much for your answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants