At http://meyer.fys.ku.dk/~tex/TeXcrazy.html (the TeX Crazy web page), there is
a macro for implementing commands in LaTeX that can access more than 9
parameters (the normal limit). The implementation in this macro is less than
invisible and a bit clumsy.
I am wondering if anyone has a method or means to allow LaTeX commands to have
more than 9 parameters, but make the implementation completely (or almost)
invisible, so that when one uses it, it seems like they are just using LaTeX
regularly, i.e.:
% implementation of a new command:
\newcommand{bigcommand}[50]{#1 #2 #3 #4 #5 #6 #7 #8 #9 #10 #11 ...}
% calling that new command:
\bigcommand{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}...
If anyone has any input, I'd appreciate hearing about it! Thanks!
--
``I don't practice what I preach because I'm not the kind of person I'm
preaching TO.''
-- ``Bob'' in NEWSWEEK
\command{aaa}{bbb}{ccc}{sjdhb}{hjgkjre}{knbjchsdk}{kjhcbcajhbc}
{lkjh}{iuyt}
are you sure I haven't missed out an argument?
\command{
something=aaa,
other=sjdhb,
this=bbb,
foo=ccc,
that=iuyt,
bar=lkjh,
else=kjhcbcajhbc,
those=knbjchsdk,
others=hjgkjre}
Using such a syntax allows arguments to be given in any order, and/or
omitted with defaults being supplied. (See for example keyval.sty for
one possible implementation)
David
That would break existing applications, for
\newcommand \bigcommand [1] {#100}
\bigcommand {XX}
should yield XX00 in the output.
For a _smart_ tabular substitute, I have written a
lengthy macro that recursively passes through all
arguments until a special \endtoken is found. Parameter
values are returned as macros, e.g. \argi, \argii, \argiii
etc. Modification to a fixed number of parameters is simple.
If there is interest, I'll post the code.
Gernot
GK> For a _smart_ tabular substitute, I have written a lengthy macro
GK> that recursively passes through all arguments until a special
GK> \endtoken is found. Parameter values are returned as macros,
GK> e.g. \argi, \argii, \argiii etc. Modification to a fixed number of
GK> parameters is simple.
That reminds me about an important point about the macro I'm defining. I want
to define a \deriv macro which will expand to produce a derivative. Here's
what I'd like to see:
Optional param: "partial" or "standard" (the default), which would denote a
partial or "standard" derivative.
1st param: the variables to be differentiated with respect to, in a string
(e.g., "xyz"). This is where I ran into trouble. I couldn't
figure out how to take apart a string into constituent tokens,
hence the large number of parameters.
2nd param: the expression to be differentiated (e.g., "3x^2").
The parser needs to take apart the "respective" variables by their *tokens*, so
if I pass "x{(3y^2)}z", it will output something like this (the "d"s will be,
of course, partial derivative symbols):
d^3
---------------
dx\,d(3y^2)\,dz
So, basically all I'm asking for is a string parser that recognizes braces. :-)
--
``Some life forms have IRONIC sex lives...''
-- Pope Meyer III
You stated the problem somewhat simple, because you do not require
the parser to recognize the _paranthesis_ (which would be somewhat
more complicated), but only the _braces_. That's simple.
My Syntax is simple: \diff xyz f(x,y,z). The blank between z and f
is important; the list of variables must not contain any blanks
unless within a braced group.
\newcounter {diffcount}
\def\diff #1 {\setcounter{diffcount}{0}\def\@difflist{\@gobble}
\let\@diffparse=\@Diffparse\@diffparse #1\endofdiffparse
\frac {\partial\ifnum
\c@diffcount>1
^{\arabic{diffcount}}\fi}
{\@difflist}
}
\def\@Diffparse#1{\ifx \endofdiffparse #1 \let\@diffparse\relax \else
\addtocounter{diffcount}{1}
\edef\@difflist{\@difflist \, \partial #1}
\fi
\@diffparse
}
Examples:
$\diff x f(x)$
$\diff xyz f(x,y,z)$
$\diff x{(3y^2)}z f(x,y,z)$
$\diff r{\sin\vartheta}{\cos\varphi} \psi(r,\vartheta,\varphi)$
$\diff qwertyuiopasdfghjkl f(\dots)$
$\diff {xyz\alpha} f(x,y,z,\alpha)$
Note that because blanks are ignored by TeX after command words,
I have used braces in the last example.
The incorporation of the optional argument to substitute \partial by d
is left to the reader as an exercise. :-)
Gernot
: That reminds me about an important point about the macro I'm
defining. I want : to define a \deriv macro which will expand to
produce a derivative. Here's : what I'd like to see:
: Optional param: "partial" or "standard" (the default), which would
denote a : partial or "standard" derivative.
: 1st param: the variables to be differentiated with respect to, in a string
: (e.g., "xyz"). This is where I ran into trouble. I couldn't
: figure out how to take apart a string into constituent tokens,
: hence the large number of parameters.
: 2nd param: the expression to be differentiated (e.g., "3x^2").
: The parser needs to take apart the "respective" variables by their
*tokens*, so : if I pass "x{(3y^2)}z", it will output something like
this (the "d"s will be, : of course, partial derivative symbols):
: d^3
: ---------------
: dx\,d(3y^2)\,dz
: So, basically all I'm asking for is a string parser that recognizes
braces. :-)
The basic trick is delimited arguments:
(assuming a macro called like \derivative{x{y_2}z}
take the argument apart with
\makeatletter % to be able to use \@empty and \@gobble
\derivative#1{\doderivative #1\endofarguments
\dosomethingwiththestoredarguments}
\def\doderivative#1#2\endofarguments{%
% now #1 will be the first argument, and #2 the rest
\dosomethingwithargument{#1}% probably store something somewhere
\def\secondargument{#2}
\ifx\secondargument\@empty \let\next=\relax\else
\let\next=\@gobble\fi\next #2\endofarguments}
This will eat the arguments one by one.
--
Jeroen Nijhof J.H.B....@aston.ac.uk
Accordion Links http://www-th.phys.rug.nl/~nijhojhb/accordions.html