Is it possible to have a macro like this one:
\documentclass{article}
\usepackage{xparse}
\pagestyle{empty}
\ExplSyntaxOn
\NewDocumentCommand{\HowManyArguments}{ oooooooo }
{
\IfNoValueTF {#1} { 0 }{
\IfNoValueTF {#2} { 1 }{
\IfNoValueTF {#3} { 2 }{
\IfNoValueTF {#4} { 3 }{
\IfNoValueTF {#5} { 4 }{
\IfNoValueTF {#6} { 5 }{
\IfNoValueTF {#7} { 6 }{
\IfNoValueTF {#8} { 7 }{ So many }
}
}
}
}
}
}
}
}
\ExplSyntaxOff
\begin{document}
The amount of arguments in this macro is \HowManyArguments[Cake][Chair][Stool][Bicycle] .
\end{document}
Except one that doesn't have limitations, a bit like the \powertower thread, where the result is embedded in the rest every time: How do I typeset a tenfold powering (a tower-of-powers) with LaTeX?
The idea is then to use the first argument of the macro to define the number of arguments.
The reason why I need the "powertower" approach is because of part 2: I want to rotate between colours based on the number of the argument.
Try compiling this:
\documentclass{article}
\usepackage{xparse}
\usepackage{xcolor}
\pagestyle{empty}
\ExplSyntaxOn
\NewDocumentCommand{\HowManyArguments}{ oooooooo }
{
\IfNoValueTF {#1} {}{
\IfNoValueTF {#2} {\textcolor{blue}{#1(}...\textcolor{blue}{)}}{
\IfNoValueTF {#3} {\textcolor{blue}{#1(}\textcolor{green}{#2(}...\textcolor{green}{)}\textcolor{blue}{)}}{
\IfNoValueTF {#4} {\textcolor{blue}{#1(}\textcolor{green}{#2(}\textcolor{red}{#3(}...\textcolor{red}{)}\textcolor{green}{)}\textcolor{blue}{)}}{
\IfNoValueTF {#5} {\textcolor{blue}{#1(}\textcolor{green}{#2(}\textcolor{red}{#3(}\textcolor{blue}{#4(}...\textcolor{blue}{)}\textcolor{red}{)}\textcolor{green}{)}\textcolor{blue}{)}}{
\IfNoValueTF {#6} {\textcolor{blue}{#1(}\textcolor{green}{#2(}\textcolor{red}{#3(}\textcolor{blue}{#4(}\textcolor{green}{#5(}...\textcolor{green}{)}\textcolor{blue}{)}\textcolor{red}{)}\textcolor{green}{)}\textcolor{blue}{)}}{
\IfNoValueTF {#7} {\textcolor{blue}{#1(}\textcolor{green}{#2(}\textcolor{red}{#3(}\textcolor{blue}{#4(}\textcolor{green}{#5(}\textcolor{red}{#6(}...\textcolor{red}{)}\textcolor{green}{)}\textcolor{blue}{)}\textcolor{red}{)}\textcolor{green}{)}\textcolor{blue}{)}}{
\IfNoValueTF {#8} {\textcolor{blue}{#1(}\textcolor{green}{#2(}\textcolor{red}{#3(}\textcolor{blue}{#4(}\textcolor{green}{#5(}\textcolor{red}{#6(}\textcolor{blue}{#7(}...\textcolor{blue}{)}\textcolor{red}{)}\textcolor{green}{)}\textcolor{blue}{)}\textcolor{red}{)}\textcolor{green}{)}\textcolor{blue}{)}}{\textcolor{blue}{#1(}\textcolor{green}{#2(}\textcolor{red}{#3(}\textcolor{blue}{#4(}\textcolor{green}{#5(}\textcolor{red}{#6(}\textcolor{blue}{#7(}\textcolor{green}{#8(}...\textcolor{green}{)}\textcolor{blue}{)}\textcolor{red}{)}\textcolor{green}{)}\textcolor{blue}{)}\textcolor{red}{)}\textcolor{green}{)}\textcolor{blue}{)}}
}
}
}
}
}
}
}
}
\ExplSyntaxOff
\begin{document}
Try this one instead: \HowManyArguments[Mandatory][Argument][What][Have][You][Done]
\end{document}
This is the full idea of what I'm trying to build, but without limitations.





\color[named]{red}and\color[rgb]{1,0,0}not\color[rgb]{1}{0}{0}the number of arguments doesn't depend on the colour model even though the logical number of parameters needed does depend on the model. – David Carlisle May 07 '14 at 14:26