Changes

Jump to navigation Jump to search
Added the second part of Key_Val_Assignments, fit better here
Actually, this macro is never used in ConTeXt, but it used to be part of constructions like <code>\placeformula</code>.
 
When working with delimited arguments, spaces and lineendings can interfere. The next set of macros uses TeX' internal scanner for grabbing everything between arguments. Forgive me the funny names.
 
<texcode>
\dosingleargument\command = \command[#1]
\dodoubleargument\command = \command[#1][#2]
\dotripleargument\command = \command[#1][#2][#3]
\doquadrupleargument\command = \command[#1][#2][#3][#4]
\doquintupleargument\command = \command[#1][#2][#3][#4][#5]
\dosixtupleargument\command = \command[#1][#2][#3][#4][#5][#6]
\doseventupleargument\command = \command[#1][#2][#3][#4][#5][#6][#7]
</texcode>
 
These macros are used in the following way:
 
<texcode>
\def\docommand[#1][#2]%
{... #1 ... #2 ...}
 
\def\command%
{\dodoubleargument\docommand}
</texcode>
 
So <code>\dodoubleargument</code> leads to:
 
<texcode>
\docommand[#1][#2]
\docommand[#1][]
\docommand[][]
</texcode>
 
The macros above insure that the resulting call always has the correct number of bracket pairs, even if the user did not supply all of the options. In this case, a number of trailing bracket pairs are empty. A set of related <code>\if</code> booleans is initialized to give you access to the number of user supplied parameters.
 
These maybe too mysterious macros enable us to handle more than one setup at once.
 
<texcode>
\dosingleargumentwithset \command[#1]
\dodoubleargumentwithset \command[#1][#2]
\dotripleargumentwithset \command[#1][#2][#3]
\dodoubleemptywithset \command[#1][#2]
\dotripleemptywithset \command[#1][#2][#3]
</texcode>
 
The first macro calls <code>\command[##1]</code> for each string in the set <code>#1</code>. The second one calls for <code>\commando[##1][#2]</code> and the third, well one may guess. These commands support constructions like:
 
<texcode>
\def\dodefinesomething[#1][#2]%
{\getparameters[\??xx#1][#2]}
 
\def\definesomething%
{\dodoubleargumentwithset\dodefinesomething}
</texcode>
 
Which accepts calls like:
 
<texcode>
\definesomething[alfa,beta,...][variable=...,...]
</texcode>
 
Now a whole bunch of variables like <code>\@@xxalfavariable</code> and <code>\@@xxbetavariable</code> is defined.
 
We've already seen some commands that take care of optional arguments between <code>[]</code>.
 
The next two commands handle the ones with <code>{}</code>. They are called as:
 
<texcode>
\dosinglegroupempty \ineedONEargument
\dodoublegroupempty \ineedTWOarguments
\dotriplegroupempty \ineedTHREEarguments
\doquadruplegroupempty \ineedFOURarguments
\doquintuplegroupempty \ineedFIVEarguments
</texcode>
 
where <code>\ineedONEargument</code> takes one and the others two and three arguments, et cetera.
 
These macros were first needed in ppchTeX. At first glance, the functionality sounds trivial. But in fact, it is not. Consider this expanded input:
 
<texcode>
\def\test#1{\message{#1}}
\dosinglegroupempty\test {a}Text
\dosinglegroupempty\test Text
</texcode>
 
In the last line, <code>#1</code> will '''not''' print the letter <code>T</code>, as would be 'normal' TeX behaviour. These macros can explictly take care of spaces, which means that the next definition and calls are valid:
 
<texcode>
\dotriplegroupempty\test {a} {b} {c}
\dotriplegroupempty\test {a} {b}
\dotriplegroupempty\test
{a}
{b}
</texcode>
 
And alike.
 
Just as their <code>[]</code>, they also set the <code>\ifXXXXargument</code> switches.

Navigation menu