\newcommand and
\newcommand* (the former defines a \long version of the
command).
The simple-minded way for a user to write such a command involves use
of the ifthen package:
\newcommand{\mycommand}[1]{\ifthenelse{\equal{#1}{*}}%
{\mycommandStar}%
{\mycommandNoStar{#1}}%
}
\newcommand{\mycommandStar}{starred version}
\newcommand{\mycommandNoStar}[1]{normal version}
This does the trick, for sufficiently simple commands, but it has
various tiresome failure modes, and it requires \mycommandnostar
to take an argument.
\newcommand{\mycommand}{\@ifstar
\mycommandStar%
\mycommandNoStar%
}
\newcommand{\mycommandStar}[2]{starred version}
\newcommand{\mycommandNoStar}[1]{normal version}
(Note that arguments to \mycommandStar and \mycommandNoStar
are independent — either can have their own arguments, unconstrained
by the technique we’re using, unlike the trick described above.)
The \@ifstar trick is all very well, is fast and efficient, but
it requires the definition to be
\makeatletter protected.
\newcommand\mycommand{normal version}
\WithSuffix\newcommand\mycommand*{starred version}
The package needs e-LaTeX, but any new enough
distribution defines LaTeX as e-LaTeX by default. Command
arguments may be specified in the normal way, in both command
definitions (after the “*” in the \WithSuffix
version). You can also use the TeX primitive commands, creating a
definition like:
\WithSuffix\gdef\mycommand*{starred version}
This question on the Web: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=cmdstar