[Tex/LaTex] Super and subscripts with \DeclarePairedDelimiter

math-modemathtoolssuperscripts

I defined a macro for the supremum norm by

\DeclarePairedDelimiter{\supnorm}{\|}{\|_\infty}

which works nicely. However, as soon as I want to place a superscript like

\supnorm{f}^2

things look funny, as the 2 appears after the infty-sign. However, I would like to look things more like what you get by

\|f\|_\infty^2

Of course, one can achieve this by using

\newcommand{\supnorm}[1]{\|#1\|_\infty}

but then one looses the nice functionality of \DeclarePairedDelimiter, which I really started to like a lot. Any ideas how one can combine the benefits of both?

Best Answer

Update:

Now with all the options provided by \DeclarePairedDelimiter! See the new definition (without using xparse):

\DeclarePairedDelimiter{\norm}{\lVert}{\rVert}
\makeatletter
\newcommand{\@supnormstar}[1]{\norm*{#1}_\infty}
\newcommand{\@supnormnostar}[2][]{\norm[#1]{#2}_\infty}
\newcommand{\supnorm}{\@ifstar\@supnormstar\@supnormnostar}
\makeatother

For example, the following code:

\[\supnorm{\frac{\sqrt5-1}{2}}^2\]
\[\supnorm*{\frac{\sqrt5-1}{2}}^2\]
\[\supnorm[\big]{\frac{\sqrt5-1}{2}}^2\]

will give you:

enter image description here

Related Question