Next: , Up: Definitions


12.1 \newcommand & \renewcommand

\newcommand and \renewcommand define and redefine a command, respectively. Synopses:

       \newcommand{cmd}[nargs]{defn}
     \renewcommand{cmd}[nargs]{defn}
       \newcommand{cmd}[nargs][default]{defn}
     \renewcommand{cmd}[nargs][default]{defn}
cmd
The command name beginning with \. For \newcommand, it must not be already defined and must not begin with \end; for \renewcommand, it must already be defined.
nargs
An optional integer from 1 to 9 specifying the number of arguments that the command will take. The default is for the command to have no arguments.
default
If this optional parameter is present, it means that the command's first argument is optional. When the new command is called, the default value of the optional argument (i.e., if it is not specified in the call) is the string ‘def’.
defn
The text to be substituted for every occurrence of cmd; a construct of the form #n in defn is replaced by the text of the nth argument.