I use the same preamble in several projects. The set of already-defined commands is different between the environments. In one project, \eps is already defined, whereas in another it is not. I wish to define \eps as \varepsilon.
The Latex2e unofficial reference manual says:
If you try to define a command and the name has already been used then you get something like
<error>. If you try to redefine a command and the name has not yet been used then you get something like<different error>.
Therefore, neither can be used in my situation. I can get around the issue like this:
\ifdefined\eps
\renewcommand{\eps}{\varepsilon}
\else
\newcommand{\eps}{\varepsilon}
\fi
but this is quite clunky. I don't understand why \renewcommand should complain if the command does not already exist. Either way, we are supplying our desired definition of the command.
\def\eps{\varepsilon}. This will work whether\epsis predefined or not. – Steven B. Segletes Oct 12 '20 at 02:55\providecommandas explained here. Ifcmdis not defined,providecommanddefines it. – FHZ Oct 12 '20 at 03:22