4

I'm trying to write a macro that converts a sequence to a table.

The following code works fine:

\documentclass{article}
\usepackage{expl3}
\begin{document}
\noindent
\ExplSyntaxOn
\seq_new:N \l_my_a_seq
\seq_set_split:Nnn \l_my_a_seq { ; } { (a, b); (b, c); (c, a) }
\tl_new:N \l_my_b_tl
\cs_new:Npn \printsequence:N #1 {
  \seq_pop_left:NNTF #1 \l_my_b_tl {
    \tl_use:N \l_my_b_tl \\
    \printsequence:N #1
  } {
  }
}
\printsequence:N \l_my_a_seq
\ExplSyntaxOff
\end{document}

and outputs this:

enter image description here

But when I try to place it inside a table, it stops working. The following code results in "TeX capacity exceeded":

\documentclass{article}
\usepackage{expl3}
\usepackage{tabularx}
\begin{document}
\noindent
\ExplSyntaxOn
\seq_new:N \l_my_a_seq
\seq_set_split:Nnn \l_my_a_seq { ; } { (a, b); (b, c); (c, a) }
\tl_new:N \l_my_b_tl
\cs_new:Npn \printsequence:N #1 {
  \seq_pop_left:NNTF #1 \l_my_b_tl {
    \tl_use:N \l_my_b_tl \\
    \printsequence:N #1
  } {
  }
}
\begin{tabular}{|c|}
\printsequence:N \l_my_a_seq
\end{tabular}
\ExplSyntaxOff
\end{document}

What is the problem here? I haven't used macros before, so I don't know a lot about them.

  • Possibly related: http://tex.stackexchange.com/a/70475/21344 – Paul Gessler Mar 01 '14 at 15:48
  • @PaulGessler thanks for that. Replaced my code with \seq_map_inline:Nn and it's working! – hatsuyuki Mar 01 '14 at 16:00
  • 1
    Great! By the way: Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. I think a self-answer could be good here since you've solved the problem and it seems to be different enough compared to the answer I've linked. – Paul Gessler Mar 01 '14 at 16:43

0 Answers0