Difference between revisions of "Command/groupedcommand"

From Wiki
Jump to navigation Jump to search
(Create entire page)
(No difference)

Revision as of 22:53, 28 June 2012



{...} before
{...} after


\groupedcommand is used for defining commands that might receive a verbatim environment as their argument, or a block wrapped in \bgroup...\egroup.


is a robust implementation of the more naïve pattern

</texcode> \def\dostuff#1{...before...#1..;after...} </texcode>

The first problem with the naïve approach: the tokens that form #1 are fixed the the moment the argument is read in. Normally this is no problem, but e.g. verbatim environments adapt the catcodes of characters and therefore are not always happy with already fixed tokens.

Another problem arises when the argument is grouped not by {} but by \bgroup and \egroup. Such an argument fails, because the \bgroup is seen as the argument (which is quite normal).

If you use \groupedcommand, the argument is identified and processed correctly.


% Don't write this

% Write this, instead.

Another example, where the item to process is a paragraph:


See also

Help from ConTeXt-Mailinglist/Forum

All issues with: