# Redefining Commands Using DeclareRobustCommand

I am trying to create the following commands. I want to replace \exp by a command that takes an input and outputs \exp(#1). Trying to copy something that I was shown before, I tried the following

\let\EXP\relax
\DeclareRobustCommand{\EXP}{\exp}
\rewnewcommand{\exp}[1]{\EXP(#1)}


However, upon compiling, I get a TeX capacity exceeded, sorry error. If I don't redefine exp, but call it something like expm, then there are no issues. I'd prefer to redefine it though. How can I get around this?

• This cannot work: TeX will chase its tail trying to substitute \exp with \exp. – egreg Oct 26 '17 at 14:38
• What should \EXP(1) give you? – Manuel Oct 26 '17 at 14:40
• Yes, so I have discovered. How can I get around this? I don't know the code for the \exp function (I know it has automatic spacing, but I don't know what) – Sam T Oct 26 '17 at 14:40
• @Manuel \EXP(1) is (/should be) just the same as what \exp(1) would normally do – Sam T Oct 26 '17 at 14:41
• \DeclareRobustCommand{\EXP}[1]{\exp(#1)} – Manuel Oct 26 '17 at 14:41

You shouldn't do this: I see no advantage in typing \exp{3} over \exp(3), unless you want to do something more, that is, adding the possibility of sizing the parentheses.

This can be done with mathtools.

\documentclass{article}
\usepackage{mathtools}

\DeclarePairedDelimiter{\paren}{(}{)}
\let\originalexp\exp

\renewcommand\exp{\originalexp\paren}

\begin{document}

\begin{equation*}
\end{equation*}

\end{document}


However, I'd avoid this and rather define \expp:

\documentclass{article}
\usepackage{mathtools}

\DeclarePairedDelimiter{\paren}{(}{)}
\newcommand\expp{\exp\paren}

\begin{document}

\begin{equation*}

Upon calling \exp{1}, TeX will do \EXP(1), which becomes \exp(()1) which becomes \EXP(()1), which becomes \exp(()()(1)
• What I was doing further was defining \expb to be with big brackets, \expB with Big, \expbb with bigg and \expBB with Bigg. Using \paren is interesting though. I don't, however, see the benefit of typing \expp[\big]{x} every time when I can just type \expb{x}... – Sam T Oct 26 '17 at 14:50
• @SamT You can add \newcommand{\expb}{\expp[\big]} if you so prefer. – egreg Oct 26 '17 at 14:53
• @egreg \exp{1}, \EXP(1), \exp(1), \EXP(()1), \exp(()1), \EXP(()()1), etc. – Manuel Oct 26 '17 at 18:54