I need to split comma-separed string from variable (actually data file) for further procesing.

There is MWE:



\NewDocumentCommand{\myfunc}{ >{\SplitList{,}} m }{\ProcessList{#1}{\func}}



(1) \myfunc{a,b,c}\\  % OK
(2) \myfunc{\textA}\\ % Wrong
(3) \expandafter\myfunc\expandafter{\textA}\\ % OK

head to column names,
(4) \expandafter\myfunc\expandafter{\colA} % Wrong (how to correct?)

What is the correct way to expand argument in case (4) in the same way as (1) or (3)??

Thank you very much in advance for any help or suggestion!

Best regards,


1 Answer 1


This has not much to do with xparse, rather with the fact that \csvreader sets \colA to a macro containing what you're after, so it needs to be expanded twice. One way is to do


instead of only two \expandafter.

  • You are exactly right, thats work as expected! Thanks for explanation (and sorry for possible confusion). BTW: (just curious) any way to use any "shotcut" commands (and again sorry, I love TeX but I'm not Tex guru...)? Aug 9, 2016 at 13:56
  • I would probably use expl3: for instance (between \ExplSyntaxOn and \ExplSyntaxOff) one could do (4) ~ \exp_args:Nf \myfunc { \colA } to fully expand \colA on the left. (Note I used ~ for the space after (4).) Aug 9, 2016 at 18:05
  • @LubošKejzlar You have already asked several questions here, and most of them seem to have reasonable answers. Please consider to accept answers if they worked for you (you can accept at most one answer per question) and/or to upvote them (you can upvote all answers that you appreciate). Maybe spare two minutes to take the tour.
    – gernot
    Mar 30, 2017 at 12:30

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.