[comp.text.tex] Writing a macro with variable number of parameters...

spencer@cgrg.ohio-state.edu (Stephen N. Spencer) (12/14/90)

I am writing a macro and would like to ask a question of the net TeXnicians.

Is there a way to write a macro which can have a variable number of 
parameters to it?  I understand that there can be up to nine parameters
(from the TeXbook) but the macro, as I plan to write it, will have a maximum
of eight parameters and a minimum of two parameters.

I have looked at 'latex.tex', thinking that '\documentstyle[]{}' has an
optional parameter, but that's only one parameter, not multiple.

Has anyone come up with something like this?  Thanks for the help and advice.

Stephen N. Spencer     |"Supreme executive power derives from a mandate from 
ACCAD   (614) 292-3416 | the masses, not from some farcical aquatic ceremony!
The Ohio State Univ.   | I mean, if I went 'round saying I was Emperor just
1224 Kinnear Road      | just because some moistened bint had lobbed a scimitar
Columbus, OH 43212-1163| at me, they'd put me away!"  -- MPFC
spencer@cgrg.ohio-state.edu||71160.3141@compuserve.com||stephen_spencer@osu.edu

eijkhout@s41.csrd.uiuc.edu (Victor Eijkhout) (12/14/90)

spencer@cgrg.ohio-state.edu (Stephen N. Spencer) writes:

>Is there a way to write a macro which can have a variable number of 
>parameters to it?  I understand that there can be up to nine parameters
>(from the TeXbook) but the macro, as I plan to write it, will have a maximum
>of eight parameters and a minimum of two parameters.

>I have looked at 'latex.tex', thinking that '\documentstyle[]{}' has an
>optional parameter, but that's only one parameter, not multiple.

>Has anyone come up with something like this?  Thanks for the help and advice.

Well, \documentstyle does look like it has an optional
parameter, so what's the difference with actually having one?

I would take me more than a few lines to sketch how to
implement optional parameters, but you may find a very
instructive article on this subject in TUGboat vol9 nr3,
Stephan von Bechtolsheim's `tutorial on \futurelet'
explains this all quite well.


Victor.