Download The xint bundle
Transcript
23 Commands of the xinttools package
\T\def\sep {\def\sep{, }}\z
(u,x), (u,y), (u,z), (v,x), (v,y), (v,z), (w,x), (w,y), (w,z)
Similarly when the replacement text of \xintFor defines a macro with parameters, the
macro character # must be doubled.
It is licit to use inside an \xintFor a \macro which itself has been defined to use internally some other \xintFor. The same macro parameter #1 can be used with no conflict (as
mentioned above, in the definition of \macro the # used in the \xintFor declaration must
be doubled, as is the general rule in TEX with things defined inside other things).
The iterated commands as well as the list items are allowed to contain explicit \par
tokens. Neither \xintFor nor \xintFor* create groups. The effect is like piling up the
iterated commands with each time #1 (or #2 ...) replaced by an item of the list. However,
contrarily to the completely expandable \xintApplyUnbraced, but similarly to the non
completely expandable \xintApplyInline each iteration is executed first before looking
at the next #152 (and the starred variant \xintFor* keeps on expanding each unbraced
item it finds, gobbling spaces).
23.20 \xintifForFirst, \xintifForLast
nn ⋆
nn ⋆
\xintifForFirst {YES branch}{NO branch} and \xintifForLast {YES branch}{NO
branch} execute the YES or NO branch if the \xintFor or \xintFor* loop is currently in
its first, respectively last, iteration.
Designed to work as expected under nesting. Don’t forget an empty brace pair {} if a
branch is to do nothing. May be used multiple times in the replacement text of the loop.
There is no such thing as an iteration counter provided by the \xintFor loops; the user
is invited to define if needed his own count register or LATEX counter, for example with a
suitable \stepcounter inside the replacement text of the loop to update it.
23.21 \xintBreakFor, \xintBreakForAndDo
One may immediately terminate an \xintFor or \xintFor* loop with \xintBreakFor.
As the criterion for breaking will be decided on a basis of some test, it is recommended to
use for this test the syntax of ifthen53 or etoolbox54 or the xint own conditionals, rather
than one of the various \if...\fi of TEX. Else (and this is without even mentioning all
the various pecularities of the \if...\fi constructs), one has to carefully move the break
after the closing of the conditional, typically with \expandafter\xintBreakFor\fi.55
There is also \xintBreakForAndDo. Both are illustrated by various examples in the next
section which is devoted to “forever” loops.
23.22 \xintintegers, \xintdimensions, \xintrationals
If the list argument to \xintFor (or \xintFor*, both are equivalent in this context) is
\xintintegers (equivalently \xintegers) or more generally \xintintegers[start+
52
to be completely honest, both \xintFor and \xintFor* intially scoop up both the list and the iterated commands; \xintFor scoops up a second time the entire comma separated list in order to feed
it to \xintCSVtoList. The starred variant \xintFor* which does not need this step will thus be a bit
faster on equivalent inputs. 53 http://ctan.org/pkg/ifthen 54 http://ctan.org/pkg/etoolbox
55
the difficulties here are similar to those mentioned in section 10, although less severe, as complete
expandability is not to be maintained; hence the allowed use of ifthen.
62