I want to convert a space separated list of items, given as argument to a function, into a clist variable in order to iterate over them. However, I am not able to create a usable clist variable as the following code example demonstrates. \clist_map_inline:Nn always takes the whole list instead of separating the elements. What am I doing wrong?


    \noindent Name:~#1\par

\def\csv{fred jane albert}
  • 1
    You must use Name:~##1. With #1 you are getting the outer argument. – Ulrike Fischer Dec 2 '11 at 11:41
  • 1
    Unless you need a clist for other reasons, I'd use a sequence and \seq_set_split:Nnn here. – Joseph Wright Dec 2 '11 at 12:43
  • Also, you are slightly mis-behaving here with the arg spec. I'd say your first use of \parselist:n should be either a V or N function (little in it here). – Joseph Wright Dec 2 '11 at 12:44
  • @Joseph Wright: Thanks for mentioning the sequence data type. I like the suggested \seq_set_split:Nnn very much, but is it stable enough to be used in a public package? – AlexG Dec 2 '11 at 13:21
  • @AlexanderGrahn One for LaTeX-L! I'd say that if we add something 'experimental', what will get it made 'non-experimental' is good use cases. So give feedback on what you use and we can move them. I'll alter the status of \seq_set_split:Nnn over the next few days: it's definitely useful. – Joseph Wright Dec 2 '11 at 13:58

I found out the error myself. Using ##1 in the function body of \clist_map_inline:Nn does the trick. Otherwise the original argument as given to \parselist:n is used.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.