On Wed, 3 Sep 2008, Thomas A. Schmitz wrote:
Hi all,
I'm trying to define a macro \Command which can either have four or five arguments. If it has five, I want to define them as
\Command1[#1][#2][#3][#4]{#5}
if it has four, as
\Command2[#1][#2][#3]{4#}
I thought this would be the way to go:
\def\Command{% \doquadrupleempty\doCommand}
You need something with possibly five arguments so you should use quint rather than quad: \def\Command% {\doquintupleargument\doCommand}
\def\doCommand{% \iffifthargument% \doquadrupleargument\Command1% \else% \dotripleargument\Command2% \fi}
The usual way is \def\doCommand[#1][#2][#3][#4][#5]% {\doifelsenothing{#5}%See below {\Command1[#1][#2][#3][#4][#5]} {\Command2[#1][#2][#3][#4]}} I use \doifelsenothing rather than \doiffirthargument. If I give \Command[...][...][...][...][] with \doifelsenothing \Commnad2 will be called while with \iffifthargument \Command1 will be called. Use whichever is more appropriate for your problem.
but that gives me errors about "too many }s". So I'm wondering: am I on the wrong track? Can this be done at all?
The above code is untested, but I am pretty sure that it will work. Aditya