Next: \makeatletter & \makeatother, Previous: \newcommand & \renewcommand, Up: Definitions [Contents][Index]
\providecommand
Synopses, one of:
\providecommand{cmd}{defn} \providecommand{cmd}[nargs]{defn} \providecommand{cmd}[nargs][optargdefault]{defn} \providecommand*{cmd}{defn} \providecommand*{cmd}[nargs]{defn} \providecommand*{cmd}[nargs][optargdefault]{defn}
Defines a command, as long as no command of this name already exists.
If no command of this name already exists then this has the same effect
as \newcommand
. If a command of this name already exists then
this definition does nothing. This is particularly useful in a file
that may be loaded more than once, such as a style file.
See \newcommand & \renewcommand for the description of the arguments.
This example
\providecommand{\myaffiliation}{Saint Michael's College} \providecommand{\myaffiliation}{Saint Michael's College} From \myaffiliation.
outputs ‘From Saint Michael's College’. Unlike \newcommand
,
the repeated use of \providecommand
does not give an error.