You are here: Home / Przedsięwzięcia/Projects / TeX Pearls / 2008 Pearls / javier-mugica / src / defining.txt

defining.txt

This may not qualify as a pearl, but is interesting nonetheless. It is also from fenixtok.
The problem is to define a macro what the texts that comes between the name of the macro
and the left brace in the definition (was that called parameter text?) is long,
includes #1 and ##1 and needs \csnames. Crazy! We may try to reach evrything with chains
of unscrutable \expandafters mixed with the ##1's, \csnames and the like.
In order to avoid this I _defined_ the parameter text as a macro itself!! This may sound
double-crazy, but I found it more inteligible. Here it is:

%Two auxiliary macros
\def\exp@noex{\expandafter\noexpand}
\def\noexp@name#1{\exp@noex\csname#1\endcsname}

\def\NewTypeoftok#1#2#3{%
%
% A good piece of code for the definition of this macro
% that is now omitted,
%
% and at the end:
%
\edef\tempa{\noexp@name{strip@#1/#2}####1\noexp@name{the@#1/#2}}%
\expandafter\def\tempa##2\mark@end@fenixtok{{##1##2}}%
}

Document Actions