Definitions

$\bullet$
A new command (macro) is defined with

\newcommand{\NAME}{DEFINITION}

and used simply by \name.

$\diamond$
With the definition

\newcommand{\gi}{\Gamma_{i}}

you get the mathematical symbol $\Gamma_{i}$ simply by \gi.

$\triangleright$
This definition only works in math mode, so in text mode it has to be enclosed in $ $\ldots$ $. To avoid this, one can use the \ensuremath command. It ensures that its argument is in math mode, doing it explicitly, if necessary:

\newcommand{\gi}{\ensuremath{\Gamma_{i}}}

$\bullet$
A new command with parameters is defined by

\newcommand{\NAME}[NARGS]{DEFINITION}

where NARGS is the number of parameters. They are used in DEFINITION as #1, #2, $\ldots$

$\diamond$
After the definition

\newcommand{\veca}[1]{\ensuremath{#1_1, \ldots, #1_n}}

the text

We consider the series \veca{a} and \veca{b}.

produces:

$\triangleright$
Macro definitions can appear anywhere, but are usually collected in the preamble.

$\triangleright$
Macros are not only used for shortcuts, but are important to describe the logical structure of a document.

$\diamond$
Assume a document contains a lot of term definitions, which are usually displayed with bold face. The macro

\newcommand{\defi}[1]{\textbf{#1}}

makes this logical meaning clearer than using simply \textbf. Moreover, if one decides to use italics instead and put all definitions into an index at the end, this can be done by simply changing the macro.

previous    contents     next

Peter Junglas 15.5.2000