I need to have several lists with access by index (array-like). My minimum non-working example follows:
\documentclass{minimal} \usepackage{etoolbox} \newcounter{listAcounter} \newcommand\addToList[3]{% \stepcounter{#2}% \csdef{#1\the#2}{#3} } \newcommand\getFromList[2]{% \csuse{#1#2} } \begin{document} \addToList{listA}{listAcounter}{one} \addToList{listA}{listAcounter}{two} \addToList{listA}{listAcounter}{three} This is element 2 from list A: \getFromList{listA}{2}. \end{document} I get from compiling with pdflatex:
! You can't use `the letter l' after \the. <argument> listA\the l istAcounter l.17 \addToList{listA}{listAcounter}{one} How can I fix this code? Why is this wrong?

\csdef{#1\csuse{the#2}}{#3}will work.