Which commands are there that one can use to define new commands in (La)TeX?
\DeclareRobustCommand[*], and ...?
(And I've seen things like
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.Sign up to join this community
The LaTeX "official" interface provides
\newcommand \renewcommand \providecommand \newlength \newsavebox \newenvironment \renewenvironment \newtheorem \newcounter
All these commands define one or more commands (some only for internal usage) and provide tests for avoiding clobbering of existing commands. There's also
\newfont, but its usage is deprecated.
The kernel has many other command-defining macros:
\DeclareRobustCommand \DeclareTextCommand \DeclareTextCommandDefault \DeclareTextSymbol \DeclareTextSymbolDefault \DeclareTextAccent \DeclareTextComposite \DeclareTextCompositeCommand \DeclareMathSymbol \DeclareMathAccent \DeclareMathDelimiter \protected@edef
Of these, only the first one is commonly used in LaTeX programming (it shouldn't be used indiscriminately as a replacement of
\newcommand, though). The last is very useful in core LaTeX programming.
Some additional packages provide new functions:
\DeclareMathOperator (amsmath) \DeclarePairedDelimiter (mathtools)
are commonly found, but there are scores of other command-defining functions in the hundreds of packages around.
Another commonly used utility for defining commands is the primitive
\let, that "copies" the current meaning of a token into a control sequence, allowing for "redefining a macro in terms of itself". However, for the nonexpert (and also the expert) programmer, the
provided by the
letltxmacro package by H. Oberdiek is a recommended replacement.
etoolbox package provides another set
\newrobustcmd \renewrobustcmd \providerobustcmd
(look at the documentation for a description).
Eventually, all of these command-defining functions boil down to the primitive commands
\def \gdef \edef \xdef \let \futurelet \chardef \mathchardef \countdef \dimendef \skipdef \muskipdef \toksdef \font \read
but a description of these would require writing a chapter of a book; refer to the TeXbook or to TeX by Topic