= TeX macro
{c}
A \b[TeX macro] associates a <TeX control sequence> with a replacement list of <TeX tokens>, possibly containing parameters. During <TeX expansion>, arguments are substituted into that list. Character tokens retain their <TeX category codes>, so this mechanism has more structure than unrestricted replacement of raw text strings.<TeX by Topic by Victor Eijkhout>[§§11.2,11.5 and12.1: definitions, parameters and token-stream expansion]{ref}
For a simple example, `\def\dup#1{#1+#1}` defines a macro with one parameter. In mathematics, `$\dup{x}$` yields the token sequence for $x+x$. With `$\dup{u+v}$`, the expansion gives $u+v+u+v$. The replacement duplicates the supplied tokens; it does not evaluate or simplify the mathematical expression.
This makes <TeX macros> useful for reusable notation. A document can express an intention through one command and change the associated presentation centrally. The actual printed result still depends on subsequent execution, <computer fonts> and <mathematical typesetting>.
Back to article page