Suppose we have
\newcommand{\inv}{-1}
We want to be able to do $A^\inv$ instead of $A^{\inv}$ but that won't work — only the minus sign is superscripted.
Accidentally I stumbled on a possible solution which is to define the macro as
\newcommand{\inv}{\kern0pt\relax -1}
but since I'm clueless as to why this works or whether this is actually a good solution I decided to ask anyway.
\documentclass{article}
\newcommand{\inv}{\kern0pt\relax -1}
\begin{document}
$A^\inv$ $A^{-1}$.
\end{document}
\newcommand{\inv}{\kern0pt\relax -1}does not work: it gives you two errors! If you scroll past them, you obtain the output you were looking for merely because of a lucky coincidence. – GuM Jul 21 '16 at 01:08A^{-1}is as easy to type asA^\inv– egreg Jul 21 '16 at 10:49$A^\inv A$– egreg Jul 21 '16 at 10:53