I need to store a csv list for later use in the end code part of an environment. Can somebody explain me what's going wrong in the following example?
\documentclass{article}
\usepackage{etoolbox}
\usepackage{ifthen}
\newcommand*\mycsv{1,2,3}
\newcommand*\printnumbers[1]{
\ifthenelse{\equal{#1}{1}}{one, }{}
\ifthenelse{\equal{#1}{2}}{two, }{}
\ifthenelse{\equal{#1}{3}}{three, }{}
}
\newcommand*\doprint[1]{\forcsvlist\printnumbers{#1}}
\begin{document}
\doprint{1,2,3} % does work
\doprint{\mycsv} % does not work
\end{document}
If the list is stored in the macro, it seems to be no longer a list for \forcsvlist but a single token. Any other solution which solves my problem?
\xforcsvlistmacro:\newcommand{\xforcsvlist}[2]{\expandafter\forcsvlist\expandafter#1\expandafter{#2}}and then\newcommand{\doprint}[1]{\xforcsvlist\printnumbers{#1}}– egreg Feb 05 '13 at 15:26