I'm having trouble using (the amazing) expl3
package with a tabular environment. Specifically, I'm getting a full extra row in my tabulars when creating rows using \seq_map_inline
. I can avoid this behavior by not including the \cr
in the last row (in the MWE below, this would involve a few more lines of code, but was not a huge deal in the original usage), and then including the \cr verbatim. In the MWE I purposely delete a lot of space “just in case” but it does not change anything (except make it harder to read, sorry). Another fix might be inserting negative spacing as in this question, but I'm confused why the kernel is inserting something into my table (it takes up no horizontal space at least, seen by add a Hi
before the \end{tabular}
).
Broken but should be right
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\DeclareDocumentCommand \myTable {m} {
\seq_set_split:Nnn \l_tmpa_seq {,} {#1}
\begin{tabular}{|c|c|}\seq_map_inline:Nn \l_tmpa_seq {Entry&##1\cr}\end{tabular}
}
\ExplSyntaxOff
\begin{document}
\myTable{A,B,C,D}
\end{document}
Works but more complicated
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\DeclareDocumentCommand \myTable {m} {
\seq_set_split:Nnn \l_tmpa_seq {,} {#1}
\int_zero:N \l_tmpa_int
\begin{tabular}{|c|c|}
\seq_map_inline:Nn \l_tmpa_seq {Entry&##1
\int_gincr:N \l_tmpa_int
\int_compare:nNnTF{\l_tmpa_int}={\seq_count:N\l_tmpa_seq}{}{\cr}
}
\cr
\end{tabular}
}
\ExplSyntaxOff
\begin{document}
\myTable{A,B,C,D}
\end{document}
\cr
is necessary for my usage, though perhaps this is not obvious. The table has a bottom border, and the\hline
needs to be on a new (zero height) row. – Jack Schmidt Sep 6 '12 at 17:38