I'm trying to get this "timeline" thing going for a document I'm writing. Follows the code I've got so far:
\documentclass{article}
\usepackage{etoolbox}
\newcommand{\addTimeline}[3][]{%
\ifcsname timeLine#2\endcsname
\expandafter\appto\csname timeLine#2\endcsname{ #3 #1\\}
\else
\expandafter\csdef{timeLine#2}{{\bf #2} #3 #1\\}
\fi
}
\newcommand{\gentimeLine}[2]{
\newcount\tmpc
\def\tabledata{}
\tmpc=#1
\loop \ifnum \tmpc<#2
\expandafter\csuse{timeLine\the\tmpc}
\advance \tmpc 1
\repeat
}
\begin{document}
\addTimeline{10}{Test1}
\addTimeline{20}{Test2}
\addTimeline{13}{Test3}
\addTimeline{25}{Test4}
\def\tabData{\gentimeLine{1}{26}}
\tabData
-
\begin{tabular}{c}\hline
\tabData
\end{tabular}
\end{document}
Naturally, in \addTimeline
command I intend to have #2 & #3 & #1
and {c c c}
in tabular instead, but for testing purposes I am keeping it in one column one.
The expected output was
10 Test1
13 Test3
20 Test2
25 Test4
followed by the table with those entries, each in a respective row.
But instead I get a table with only one row, containing the first entry 10 Test1
. The 4 items are correctly printed in normal text, however.
Any suggestions on how to fix?
\documentclass
and anything else that would be needed for it to be compiled for experimentation. otherwise, we'd have to guess, and if we make the wrong choice, that's effort wasted.