1

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?

  • 1
    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
2

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*}
\exp{x}\quad\exp[\big]{x}\quad\exp*{\frac{\pi}{2}}
\end{equation*}

\end{document}

enter image description here

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

\documentclass{article}
\usepackage{mathtools}

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

\begin{document}

\begin{equation*}
\expp{x}\quad\expp[\big]{x}\quad\expp*{\frac{\pi}{2}}
\end{equation*}

\end{document}

What's going wrong with your definition?

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
  • Yeah, very true. Is that then any more beneficial than Manuel's suggestion? (tex.stackexchange.com/questions/398175/…) – Sam T Oct 26 '17 at 14:55
  • @egreg \exp{1}, \EXP(1), \exp(1), \EXP(()1), \exp(()1), \EXP(()()1), etc. – Manuel Oct 26 '17 at 18:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.