[texhax] sub array within tables

Martin Heller mr_heller at yahoo.dk
Thu Sep 6 23:31:08 CEST 2007


debian skrev:
> Please,
> 
> I am trying to pass data to a predefined table, so that I can say
> "here table, is an array of data, processs it for me.  Thanks."
> 
> Pseudo code:
> 
> \newcommand{\mytable}{
>   \begin{tabular}{ll}		% or maybe something more complex
>      for (\i=o;i <= \mylimit;i++) {
>        \mydata[i] & \myotherdata[i]  \\
>      }
>   \end{tabular}
> }     
> 
> \newcommand{\mydata[1]}{doh}	% an array of data
> \newcommand{\mydata[2]}{ray}
> \newcommand{\mydata[3]}{me}
> .....
> .....
> \newcommand{\mydata[20]}{snark}
> \newcommand{\mylimit}{20}
> 
> \newcommand{\myotherdata[1]}{uncle} % another array
> ....
> \newcommand{\myotherdata[20]{all}
> 
> \mytable{\mydata}
> 
> I find myself needing to do this sort of thing - reusing tables.
> Actually, they are more like forms than tables.
> 
> Perhaps I am just being lazy, or daft.  Or, perhaps it would be better
> to use Perl than Latex ?

Memoir have commands for autogenerating tables.

\documentclass{memoir}

\newcommand\mytable[2]{\autocols{l}{2}{l}{#1,#2}}

\begin{document}

\mytable{%
   foo,bar,baz
}{%
   qux,quux,quuux
}

\end{document}



More information about the texhax mailing list