# How to avoid using curly braces when placing a \DeclareMathOperator command in subscript or superscript, while preserving spacing?

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.



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?

• 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

\newcommand{\rad}{{\mathrm{rad}}}


will let you type

f^\rad


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.