I have a particular problem which I am trying to solve using etoolbox
, but I can't figure out how. What I'm trying to do is to auto-generate a table based on information from a previous table. This is best explained with an example:
\newcounter{numc}
\setcounter{numc}{0}
\newcolumntype{n}{>{\thenumc.}r<{\addtocounter{numc}{1}}}
% This is simply a column displaying the row number.
\newrobustcmd{\push}[1]{\listadd{\numcount}{\thenumc} \listadd{\ncom}{#1}}
% This command may have to be defined differently, depending on the missing code below.
\begin{xtabular}{ n l l }
& row1,col2 & row1,col3 \\
& row2,col2 & row2,col3 \\ \push{Comment for row 2.}
& row3,col2 & row3,col3 \\
& row4,col2 & row4,col3 \\ \push{Comment for row 4.}
& row5,col2 & row5,col3 \\ \push{Comment for row 5.}
\end{xtabular}
\begin{xtabular}{ r l }
% The code for auto-generating the second table goes here.
% The first column is supposed to be the values in the numcount list, minus 1.
% The second column is supposed to be the text in the ncom list.
\end{xtabular}
So the output is intended to be as follows:
Table 1:
1. row1,col2 row1,col3
2. row2,col2 row2,col3
3. row3,col2 row3,col3
4. row4,col2 row4,col3
5. row5,col2 row5,col3
Table 2:
2. Comment for row 2.
4. Comment for row 4.
5. Comment for row 5.
However, I can't find a good solution for the missing code in the second table. The code should generate the first column from the first list (numcount
), and the second column from the second list (ncom
).
Do you have any suggestions to how I can solve this?