System Macros/Expansion Control

From Wiki
< System Macros
Revision as of 17:23, 1 August 2006 by Mojca Miklavec (talk | contribs) (Basic navigation)
Jump to navigation Jump to search

< Prev: Scratch Variables | Top: System Macros | Next: Handling Arguments >

Expansion control

When in unprotected mode, to be entered with \unprotect, one can use \@EA as equivalent of \expandafter. \@EAEA expands to two expandafters, \@EAEAEA to three, and the last one expands to \@EA\@EAEAEA\@EA.

Sometimes we pass macros as arguments to commands that don't expand them before interpretation. Such commands can be enclosed by \expanded, like:


Such situations occur for instance when \alfa is a commalist or when data stored in macros is fed to index of list commands. If needed, one should use \noexpand inside the argument. Later on we will meet some more clever alternatives to this command.

These two commands make macros more readable by hiding a lot of \expandafter's. They expand the arguments after the first command.

\expandoneargafter \command{\abc}
\fullexpandoneargafter \command{\abc}

These commands expect the arguments to be macros.

When expansion of a macro gives problems we can precede it by \unexpanded, like so:

\unexpanded\def\somecommand{... ... ...}

(if you are not familiar with ConTeXt: this is the same command as \protect in LaTeX). It seems that protection is one of the burdens of developers of packages, so maybe that's why in e-TeX protection is solved in a more robust way. ConTeXt uses that (more robust) solution if it is available, and otherwise tries it's best to emulate it using rather tricky macros.

Expansion problems can get quite complex. There are some other internal macros that can help harnassing it, but it is fairly unlikely that you will need them. If you believe you do, read the syst-gen.tex source code.

< Prev: Scratch Variables | Top: System Macros | Next: Handling Arguments >