[texhax] passing arguments as a delimited list

Yo Sato yosato16 at gmail.com
Mon Apr 13 19:19:14 CEST 2009

Hi Joseph,

Thanks for your response, which is very useful. But as it happens it's
not quite what I wanted. I'd rather apply different actions on the
items in a list, or pass them to different commands or different
arguments of a command.

For example, I'd like to execute


which calls different commands

  parse the list argument and

or passes them to a single command

  parse the list argument, assign item1-3 to \first, \second, \third and

Is this a possibility?



2009/4/12 Joseph Wright <joseph.wright at morningstar2.co.uk>:
> Yo Sato wrote:
>> Hi all,
>> I wonder if any of you knows how to implement (if this is possible) a
>> TeX or LaTeX macro that passes multiple (optional) arguments as a
>> single list (with delimiters), i.e. as executable as below
>> \somecommand[item1, item2, item3,...]{...}
>> As I see this style a lot for class specification (e.g.
>> \documentclass[a4paper,draft]{article}), I shouldn't think why this is
>> not possible for macros. So far however I can't find how to do this in
>> a documentation, although there are discussions on how to 'increase'
>> the number of arguments with keyval package etc. What I'd rather is a
>> listed single argument, whether optional or obligatory, as it is
>> cleaner and structurable.
>> Any advice???
> Hello Yo,
> If you simply want to parse a comma-separated list then the internal
> macro \@for should help.
> \documentclass{article}
> \makeatletter
> \newcommand*{\MyMacro}[2][]{%
>  \@for\my at temp:=#1\do{%
>    Option seen: \my at temp \\
>  }%
>  Main argument: #2
> }
> \makeatother
> \begin{document}
> \MyMacro[option1,option2,option3]{Content}
> \end{document}
> You can of course do what you like with the temporary variable (in this
> case \my at temp).
> --
> Joseph Wright

More information about the texhax mailing list