1

I use the syntax of expl3 to type a table with increasing number. The usage can be found here: Create tabular depending on counter

\documentclass{article}
\usepackage{array}
\begin{document}
\ExplSyntaxOn
\int_set:Nn \l_tmpa_int {5}
\tl_clear:N \l_tmpa_tl
\int_step_inline:nn{\l_tmpa_int+1}{\tl_put_right:Nn \l_tmpa_tl{|l}}
\tl_put_right:Nn \l_tmpa_tl{|}
\begin{tabular}{\l_tmpa_tl}
  \int_step_inline:nn{\l_tmpa_int}{#1&} others
\end{tabular}
\ExplSyntaxOff
\end{document}

The above codes produce an error:

! Package array Error:  Illegal pream-token (\l_tmpa_tl): `c' used.

Without loading array, the codes work well. The error seems due to array. Is there some methods to deal with this question?

1 Answer 1

2

With array no expansion is performed to the mandatory argument to tabular. You can use \exp_args:NnV \begin{tabular}\l_tmpa_tl, but there are better ways to generate such a table preamble.

\documentclass{article}
\usepackage{array}

\begin{document}

\ExplSyntaxOn

\tl_set:Nx \l_tmpa_tl { \prg_replicate:nn { 6 } { |l } | }
\cs_set:Nn \__jiaopijie_temp:n { #1 & }
\exp_args:NnV \begin{tabular} \l_tmpa_tl
  \int_step_function:nN { 5 } \__jiaopijie_temp:n others
\end{tabular}

\ExplSyntaxOff

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.