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?
\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 showsx^{2}
for example even thoughx^2
works due to implementation details and lack of error checking.\^([^{\\]|\\[a-zA-Z]*)
^
(and_
) math-active, but they have other disadvantages.