Diese Frage wird in der UK-TeX-FAQ behandelt.
Post by Frank KnappeThis [...] is related to the "UK List of TeX Frequently Asked
Questions on the Web", Section "Macro programming", question
"How to break the 9-argument limit"
(http://www.tex.ac.uk/cgi-bin/texfaq2html?label=moren9).
1. \blah (re)defines argument-holding macros from arguments and
then calls \BlahRelay which fetches more arguments and
additionally uses the previously (re)defined argument-holding
macros.
2. keyval-package.
Both suggestions do not work for expandable contexts as with both
approaches assigning takes place.
Post by Frank Knappe1) Within expandable contexts you probably can work around the
9-argument-restriction by "argument-nesting", that means by
actually passing several parameter-values to one macro-argument
\documentclass{minimal}
\newcommand\firstoftwo[2]{#1}
\newcommand\secondoftwo[2]{#2}
\newcommand\internal[9]{%
\noindent
This is value 1: \firstoftwo#1\hfil\break
This is value 2: \secondoftwo#1\hfil\break
This is value 3: \firstoftwo#2\hfil\break
This is value 4: \secondoftwo#2\hfil\break
This is value 5: \firstoftwo#3\hfil\break
This is value 6: \secondoftwo#3\hfil\break
This is value 7: \firstoftwo#4\hfil\break
This is value 8: \secondoftwo#4\hfil\break
This is value 9: \firstoftwo#5\hfil\break
This is value 10: \secondoftwo#5\hfil\break
This is value 11: \firstoftwo#6\hfil\break
This is value 12: \secondoftwo#6\hfil\break
This is value 13: \firstoftwo#7\hfil\break
This is value 14: \secondoftwo#7\hfil\break
This is value 15: \firstoftwo#8\hfil\break
This is value 16: \secondoftwo#8\hfil\break
This is value 17: \firstoftwo#9\hfil\break
This is value 18: \secondoftwo#9\hfil\break
}
\begin{document}
\internal{{one}{two}}%
{{three}{four}}%
{{five}{six}}%
{{seven}{eight}}%
{{nine}{ten}}%
{{eleven}{twelve}}%
{{thirteen}{fourteen}}%
{{fifteen}{sixteen}}%
{{seventeen}{eighteen}}%
\end{document}
If the unbelievable happens and you need more than 18 arguments,
you can define argument-grabber-macros \firstofnine ...
\ninthofnine.
You can also implement more argument-nesting-levels. Then you
have to call a sequence of argument-grabbers. You can do this
in terms of \expandafter or -perhaps less cumbersome- you
define your argument-grabbers to place another argument in
\documentclass{minimal}
\newcommand\callonfirstoftwo[3]{#1#2}
\newcommand\callonsecondoftwo[3]{#1#3}
\newcommand\internal[2]{%
\noindent
\callonfirstoftwo{\callonfirstoftwo\empty}#1\hfil\break
\callonfirstoftwo{\callonsecondoftwo\empty}#1\hfil\break
\callonsecondoftwo{\callonfirstoftwo\empty}#1\hfil\break
\callonsecondoftwo{\callonsecondoftwo\empty}#1\hfil\break
\callonfirstoftwo{\callonfirstoftwo\empty}#2\hfil\break
\callonfirstoftwo{\callonsecondoftwo\empty}#2\hfil\break
\callonsecondoftwo{\callonfirstoftwo\empty}#2\hfil\break
\callonsecondoftwo{\callonsecondoftwo\empty}#2\hfil\break
}
\begin{document}
\internal{{{one}{two}}{{three}{four}}}%
{{{five}{six}}{{seven}{eight}}}%
\end{document}
2) Define \blah
- to fetch arguments
- to define \innerblah
- to call \innerblah
Within \innerblah you can use both the arguments #1..#9 of
\documentclass{minimal}
\newcommand\blah[9]{%
\begingroup
\let\innerblah\relax
\newcommand\innerblah[9]{%
\noindent
This is value 1: #1\hfil\break
This is value 2: #2\hfil\break
This is value 3: #3\hfil\break
This is value 4: #4\hfil\break
This is value 5: #5\hfil\break
This is value 6: #6\hfil\break
This is value 7: #7\hfil\break
This is value 8: #8\hfil\break
This is value 9: #9\hfil\break
This is value 10: ##1\hfil\break
This is value 11: ##2\hfil\break
This is value 12: ##3\hfil\break
This is value 13: ##4\hfil\break
This is value 14: ##5\hfil\break
This is value 15: ##6\hfil\break
This is value 16: ##7\hfil\break
This is value 17: ##8\hfil\break
This is value 18: ##9\hfil\break
}%
\expandafter\endgroup
\innerblah
}%
\begin{document}
\blah{one}{two}{three}{four}{five}{six}{seven}{eight}{nine}%
{ten}{eleven}{twelve}{thirteen}{fourteen}{fifteen}%
{sixteen}{seventeen}{eighteen}
\end{document}
If the unbelievable happens and you need more than 18
\documentclass{minimal}
\newcommand\blah[9]{%
\begingroup
\let\innerblah\relax
\let\innerinnerblah\relax
\newcommand\innerblah[9]{%
\newcommand\innerinnerblah[2]{%
\noindent
This is value 1: #1\hfil\break
This is value 2: #2\hfil\break
This is value 3: #3\hfil\break
This is value 4: #4\hfil\break
This is value 5: #5\hfil\break
This is value 6: #6\hfil\break
This is value 7: #7\hfil\break
This is value 8: #8\hfil\break
This is value 9: #9\hfil\break
This is value 10: ##1\hfil\break
This is value 11: ##2\hfil\break
This is value 12: ##3\hfil\break
This is value 13: ##4\hfil\break
This is value 14: ##5\hfil\break
This is value 15: ##6\hfil\break
This is value 16: ##7\hfil\break
This is value 17: ##8\hfil\break
This is value 18: ##9\hfil\break
This is value 19: ####1\hfil\break
This is value 20: ####2\hfil\break
}%
\expandafter\endgroup
\innerinnerblah
}%
\innerblah
}%
\begin{document}
\blah{one}{two}{three}{four}{five}{six}{seven}{eight}{nine}%
{ten}{eleven}{twelve}{thirteen}{fourteen}{fifteen}%
{sixteen}{seventeen}{eighteen}{nineteen}{twenty}%
\end{document}