I would like to define kind of an own index, that collects certain information and one counter value - in the following small example the \addstuff-command that may get the value of a counter as its first argument and a description as its second. The first entry might also be text itself or even empty.
I want to collect all these value-text entries and create an output at the end. In the following example the description always reflects, what i want the counter value to be in that entry.
\documentclass[a4paper]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\newcommand{\collect}{}
\newcounter{mycounter}\setcounter{mycounter}{1}
\makeatletter
\newcommand{\addstuff}[2]{\g@addto@macro\collect{#1 & #2\\}}
\makeatother
\newcommand{\generateOutput}{%
Output of collection\par%
\begin{tabular}{rl}\collect\end{tabular}%
}
\begin{document}
\addstuff{normal}{Entry}
\addstuff{\themycounter}{save the 1 it should have here}
\refstepcounter{mycounter} %incement -> 2
\addstuff{\arabic{mycounter}}{<-save the 2 of the counter}
\refstepcounter{mycounter} %incement -> 3
% Print all saved data
\generateOutput
\end{document}
So my question is, how can i evaluate the first parameter to obtain the actual value of the counter at the moment, \addstuff is called? Because in this code, both lines that i save in my collection end up having the value 3 instead of 1 or 2 respectively.
\eapptofrom theetoolboxpackage. I will post an answer in a while if no one else posted one. – Martin Scharrer Jan 04 '12 at 09:23edefor withnewtoks. – Marco Daniel Jan 04 '12 at 09:48edefandnewtoksi would also be interested in a version using theetoolbox, just because I tried your ideas and didn't have any success in using\eappto. – Ronny Jan 05 '12 at 07:30