I suspect I'm asking for magic, but I'll go ahead anyway. Suppose I have a command
that accepts an arbitrary-sized list of comma-separated terms. One that we're
all familiar with is \usepackage although of course we could all come up with
dozens more. In the case of \usepackage, we can write:
\usepackage[opta,optb,optc]{pkgx,pkgy,pkgz}
I.e.,
\usepackage[ <comma-separated-options> ]{ <comma-separated-pkg-names> }
More generally, we might be given a command to be used like this:
\command{ <comma-separated-list> }
My question is, is there any TeX\LaTeX wizardry for constructing commands such as:
\newcommand\mylist{
... possible wizardry ...
a,b,c
... possibly more wizardry ...
}
so that the effect of writing
\command{\mylist} and \command{a,b,c}
or
\command{ ...code... \mylist ...code... } and \command{a,b,c}
would be the same?
In other words, is it possible to construct a TeX\LaTeX command that can stand, be expanded and accepted in the compile where <comma-separated-list> would normally be accepted?
Motivation: (apart from the immense pleasure of learning new TeX-related things :) ) On multiple occasions, I have to pass a large non-fixed-sized list to several places, some being to packaged commands that, due to their complexity and the maintenance burden it would impose, I'm rather reluctant to dive into and redefine.
Edit:
While some very good ideas have been suggested (thanks esp. TH and Will!), these solutions don't
completely fit the bill. So, to ground my question somewhat, here are the specifics of the
case I'm trying to solve. As background, my code consumes the same long list of values in
multiple locations. While I could hard-code the list literally in all the places that consume it,
for good and practical reasons, the idea of doing so is not at all appealing. I would really like to pass it as an argument,
as I can for any other normal value. One of the (let's say) two places
consuming the list is a command, \command, for which TH's and then Will's repeat, perfectly
solve the problem. The other case where I'm struggling, however, is in my reusing the list in
xkeyval command \define@choicekey, although the same problem would exist in the case of any other
commands sharing the same type template. (FYI, I've tried hacking TH's nice solution to fit,
but got nowhere particularly fast.) Here's an example list of values and the situations where I access them:
\newcommand*\mylist{a,b,c,...,l,m,n}
\define@choicekey{myfamily}{mykey}[]
\mylist% <-- how can I consume \mylist here?
[a]
{\renewcommand*\mynewkey{#1}}
\newcommand\anothercmd{
...
\command{\mylist}% <-- this problem is easily fixed with TH's nice solution
...
}
