Let's say in my preamble I define \DeclareMathOperator\rad{rad} and have the text

Let $f$ be a smooth function and $f^{\rad}$ its radial symmetrization.

It is inconvenient to have to enclose the \rad in curly braces. I could work around it by defining it as \newcommand\rad{{\operatorname{rad}}} instead. But at another place in my document I write

Let $n$ be a positive integer and $2 \rad(n)$ be twice its radical.

If I use \newcommand\rad{{\operatorname{rad}}}, there is no space between 2 and rad. (See newcommand vs. DeclareMathOperator)

So my question is: How can I allow a command to be used directly in superscript or subscript, while preserving the correct spacing when it is appears in the middle of a formula?

Related: Double subscript error with \newcommand?

  • 1
    enclosing \rad in braces shouldn't be seen as inconvenient, it is the (only) documented syntax for ^ in latex, which takes a brace delimited argument. The latex book always shows x^{2} for example even though x^2 works due to implementation details and lack of error checking. – David Carlisle Jun 21 '18 at 18:57
  • there we go...\^([^{\\]|\\[a-zA-Z]*) – Schneider Jun 21 '18 at 19:41

If you just use \rad in exponents and not really as an operator, then defining


will let you type


Note that \DeclareMathOperator is not a shorthand for getting \mathrm.

If you need \rad as an operator in other contexts, then no, you can't, for the same reason that ^\notin will produce an error.

On the other hand, is there a real reason for sparing a couple of braces? Any good TeX editor will supply the braces as soon as you enter ^. Adding them always will save you from head scratching when something goes wrong.

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.