diff options
Diffstat (limited to 'Master/texmf-doc/doc/english/FAQ-en/html/FAQ-moren9.html')
-rw-r--r-- | Master/texmf-doc/doc/english/FAQ-en/html/FAQ-moren9.html | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/Master/texmf-doc/doc/english/FAQ-en/html/FAQ-moren9.html b/Master/texmf-doc/doc/english/FAQ-en/html/FAQ-moren9.html new file mode 100644 index 00000000000..5c4b441e021 --- /dev/null +++ b/Master/texmf-doc/doc/english/FAQ-en/html/FAQ-moren9.html @@ -0,0 +1,64 @@ +<head> +<title>UK TeX FAQ -- question label moren9</title> +</head><body> +<h3>How to break the 9-argument limit</h3> +<p>If you think about it, you will realise that Knuth's command +definition syntax: +<blockquote> +<pre> +\def\blah#1#2 ... #9{<macro body>} +</pre> +</blockquote> +is intrinsically limited to just 9 arguments. There's no direct way +round this: how would you express a 10th argument? - and ensure that +the syntax didn't gobble some other valid usage? +<p>If you really must have more than 9 arguments, the way to go is: +<blockquote> +<pre> +\def\blah#1#2 ... #9{% + \def\ArgI{{#1}}% + \def\ArgII{{#2}}% + ... + \def\ArgIX{{#9}}% + \BlahRelay +} +\def\BlahRelay#1#2#3{% + % arguments 1-9 are now in + % \ArgI-\ArgIX + % arguments 10-12 are in + % #1-#3 + <macro body>% +} +</pre> +</blockquote> +This technique is easily extendible by concert pianists of the TeX +keyboard, but is really hard to recommend. +<p>LaTeX users have the small convenience of merely giving a number of +arguments in the <code>\</code><code>newcommand</code> that defines each part of the +relaying mechanism: Knuth's restriction applies to <code>\</code><code>newcommand</code> +just as it does to <code>\</code><code>def</code>. However, LaTeX users also have the +way out of such barbarous command syntax: the <i>keyval</i> +package. With <i>keyval</i>, and a bit of programming, one can +write really quite sophisticated commands, whose invocation might look +like: +<blockquote> +<pre> +\flowerinstance{species=Primula veris, + family=Primulaceae, + location=Coldham's Common, + locationtype=Common grazing land, + date=1995/04/24, + numplants=50, + soiltype=alkaline +} +</pre> +</blockquote> +The merit of such verbosity is that it is self-explanatory: the typist +doesn't have to remember that argument twelve is <code>soiltype</code>, and so +on: the commands may be copied from field notes quickly and +accurately. +<dl> +<dt><tt><i>keyval.sty</i></tt><dd>Distributed as part of <a href="ftp://cam.ctan.org/tex-archive/macros/latex/required/graphics.zip">macros/latex/required/graphics</a> (<a href="ftp://cam.ctan.org/tex-archive/macros/latex/required/graphics.tar.gz">gzipped tar</a>, <a href="http://www.tex.ac.uk/tex-archive/macros/latex/required/graphics/">browse</a>) +</dl> +<p><p>This question on the Web: <a href="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=moren9">http://www.tex.ac.uk/cgi-bin/texfaq2html?label=moren9</a> +</body> |