As another quick reference I have used Tralics extensively. Although some of the commands do not appear in TeX it is of great help. Mainly due to its many low-level examples.
There are many examples. For instance for the \edef
command:
\edef
You can say \edef\foo{bar}
. The syntax is the same as \def
, but the token list in the body is fully expanded (tokens that come from
\the
are not expanded).
You can put the prefix \global
before \edef
, note that \xdef
is the same as \global\edef
. In the example that follows, the \ifx
is
true.
{\catcode`\A=12 \catcode`\B=12\catcode`\R=12\gdef\fooval{ABAR}}
{\escapechar=`\A \edef\foo{\string\BAR}\ifx\foo\fooval\else \uerror\fi}
Another example is the following. The \meaning
command returns a token list, of the form macro:#1#2->OK OK
, and \strip@prefix
removes
everything before the >
sign. What we put in \Bar
is a list of five
tokens, a space, and four letters of catcode 12.
\makeatletter
\def\strip@prefix#1>{}
\def\foo#1#2{OK OK}
\edef\Bar{\expandafter\strip@prefix\meaning\foo}
For a non-trivial example, see \aftergroup
.