TeX/edef
Appearance
< TeX
Synopsis
[edit | edit source]\edef <command> {<replacement-text>}
Description
[edit | edit source]\edef
is similar to \def in that it allows you to define new macros or replace an existing macro. The significant defining difference between \edef
and \def is that \edef
expands macros at definition time, rather than saving them for later. This difference allows \edef
to be used to append new information to a macro, for example:
\edef\@test{A}
\edef\@test{\@test B}
\edef\@test{\@test C}
\@test
results in the output "ABC". Attempting to do this example with \def instead will result in the error "TeX capacity exceeded, sorry". This behavior can be useful in loops that compile a string of information, but do not end up outputting the information directly.