[XeTeX] Automate table creation
Bruno Le Floch
blflatex at gmail.com
Fri Mar 2 08:53:49 CET 2012
> I tried runing your code, but I get the following message:
>
> ! Missing number, treated as zero.
> <to be read again>
> *
> l.20 \maketable{c,0}{1,2}
I knew I should've tested that code.
\documentclass{article}
\usepackage{xparse}
\usepackage{array}
\ExplSyntaxOn
\DeclareDocumentCommand{\maketable}{mm}
{
\exp_args:Nnx \begin{tabular}{c*{\clist_length:n{#2}}c}
\clist_map_inline:nn {#2} { & \typeset_two:n {##1} }
\clist_map_inline:nn {#1}
{
\\
\typeset_one:n {##1}
\clist_map_inline:nn {#2}
{ & \typeset_both:nn {##1} {####1} }
}
\end{tabular}
}
\cs_new_protected:Npn \typeset_one:n #1 { [#1] }
\cs_new_protected:Npn \typeset_two:n #1 { (#1) }
\cs_new_protected:Npn \typeset_both:nn #1#2 {#1#2}
\ExplSyntaxOff
\begin{document}
\maketable{0,1}{a,b,c}
\end{document}
works. The previous code was mostly missing \usepackage{array} for the
"*{<number>}c" construction, and had a bunch of other bugs. To
customize that, change the definition of the three functions
\typeset_one:n, \typeset_two:n and \typeset_both:n.
Building diacritics from the base accent and the character seems a bit
tougher than I thought. Others on this thread will know how to do
that.
Cheers,
Bruno
More information about the XeTeX
mailing list