Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!usc!jarthur!nntp-server.caltech.edu!news From: marcel@cs.caltech.edu (Marcel van der Goot) Newsgroups: comp.text.tex Subject: Re: A macro question (about variable number of args) Message-ID: <1990Sep6.014900.11216@laguna.ccsf.caltech.edu> Date: 6 Sep 90 01:49:00 GMT References: <8208@jarthur.Claremont.EDU> <1990Aug29.002146.24426@agate.berkeley.edu> Sender: news@laguna.ccsf.caltech.edu Reply-To: marcel@vlsi.caltech.edu Organization: California Institute of Technology Lines: 28 In <1990Aug29.002146.24426@agate.berkeley.edu> Carl Cotner (cotner@math.berkeley.edu) asks for a way to write macros that take an arbitrary number of arguments. Here's how I usually do it (I don't remember whether this can be found somewhere in the TeX-book; the idea was described to me several years ago by Prof. R. Backhouse). I assume that the technique is pretty well-known. \def\callmymacro[#1+#2]% {\mymacro{#1}% \def\more{#2}% \ifx\more\empty{}\else\callmymacro[#2]\fi } \def\mynewmacro[#1]% {\callmymacro[#1+]% } % The separator is '+'. You can call % \mynewmacro[input1+input2+input3] % Try with, e.g., \def\mymacro#1{\immediate\write16{--- #1}} Marcel van der Goot marcel@vlsi.caltech.edu