Menu
CTAN
Comprehensive TeX Archive Network
Cover Upload Browse Search

Direc­tory tex-archive/macros/latex/contrib/multiexpand

Variations on the `\expandafter` TeX primitive
==============================================
* E-mail: blflatex@gmail.com
* Released under the LaTeX Project Public License v1.3c or later
  See http://www.latex-project.org/lppl.txt

Every TeX programmer knows `\expandafter`, and how messy it can become
when trying to expand several times a very deeply hidden token. For
example, say we want to expand `\C` four times before `\A` and `\B` in
`\A\B\C`.  The traditional approach would be to insert 15 `\expandafter`
before `\A` and the same number before `\B`. This package allows the two
simpler codes

    \expandafter\A\expandafter\B\romannumeral\multiexpand{4}\C

or

    \expandafter\A\romannumeral\multiexpandafter{4}\B\C

In one step of expansion (triggered by the `\expandafter`'s), the
sequence `\romannumeral\multiexpand{4}` expands the following token 4
times, whereas `\romannumeral\multiexpandafter{4}` expands the token
after that 4 times.

The code behaves with braces as `\expandafter` would. Another example is

    \MultiExpandAfter{2}\a\MultiExpandAfter{3}{%
      \MultiExpandAfter{10}\b\MultiExpandAfter{10}\c\d},

which expands `\d` 10 times, then `\c` 8 times, then `\b` once.
The whole process will only take two steps of expansion.

The package can be built from the file `multiexpand.dtx' by running

    pdflatex multiexpand.dtx
    pdflatex multiexpand.dtx
    pdflatex multiexpand-example.tex

The last step is optional: it runs a series of tests.

Files

Name Size Date Notes
README 1477 2013-01-08 15:08
multiexpand.dtx 11129 2013-01-08 14:53
multiexpand.pdf 284328 2013-01-08 15:09

Down­load the con­tents of this pack­age in one zip archive (280.9k).

mul­ti­ex­pand – Vari­a­tions on the prim­i­tive com­mand \ex­pandafter

The pack­age pro­vides two user com­mands; one that per­forms mul­ti­ple ex­pan­sions, and one that does mul­ti­ple \ex­pandafter op­er­a­tions, in a sin­gle macro call. The pack­age re­quires ε-TeX’s \nu­m­expr com­mand.

The au­thor sug­gests that the same ef­fect could be pro­vided by use of the com­mand vari­ant mech­a­nisms of LaTeX 3 (see, for ex­am­ple, the in­ter­face doc­u­men­ta­tion of the ex­per­i­men­tal LaTeX 3 ker­nel).

Pack­age De­tailsmul­ti­ex­pand
Ver­sion1.1
Li­censeThe LaTeX Project Public Li­cense 1.3
Copy­rightBruno Le Floch 2011-2013
Main­tainerBruno Le Floch
TDS archivemultiexpand.tds.zip
Con­tained inTeXlive as mul­ti­ex­pand
MikTeX as mul­ti­ex­pand
Topics sup­port for de­vel­op­ment of (La)TeX macros
Guest Book Sitemap Contact