I have a series of norm macros that I want to expand to \left\| ...\right\| in display math but remain as \| ... \| in inline math. Each norm has a subscript unique to the macro:
\newcommand {\normbrak} [2] % display/inline -aware norm brackets
{\mathchoice{\left\|#1\right\|_{#2}}{\|#1\|_{#2}}{\|#1\|_{#2}}{\|#1\|_{#2}}}
\newcommand {\inorm} [1] {\normbrak{#1}{1}} % 1-norm (nuclear norm)
\newcommand {\iinorm} [1] {\normbrak{#1}{2}} % 2-norm (operator norm)
\newcommand {\fronorm} [1] {\normbrak{#1}{\text{F}}} % Frobenius norm
\newcommand {\infnorm} [1] {\normbrak{#1}{\infty}} % infinity norm
\newcommand {\Linorm} [1] {\normbrak{#1}{L^1}} % L1 norm
\newcommand {\Liinorm} [1] {\normbrak{#1}{L^2}} % L2 norm
\newcommand {\Linfnorm} [1] {\normbrak{#1}{L^\infty}} % L-infinity norm
In certain places, I wish to write, e.g., \fronorm{\hat H}^{-1} to get a superscript on the norm as well. My problem is that \mathchoice appears to reset the positioning of superscripts and subscripts, yielding
instead of the proper
One possible solution is to rewrite every macro as, e.g.
\newcommand {\normbrak} [3] {%
\mathchoice
{\left\|#1\right\|_{#2}\IfNoValueF {#3} {\sp{#3}}}
{\|#1\|_{#2}\IfNoValueF {#3} {\sp{#3}}}
{\|#1\|_{#2}\IfNoValueF {#3} {\sp{#3}}}
{\|#1\|_{#2}\IfNoValueF {#3} {\sp{#3}}}%
}
\NewDocumentCommand {\fronorm} {me{^}} {%
\normbrak{#1}{\text{F}}{#2}%
}
but this seems messy and redundant.
Is there a way to stop \mathchoice from ratching the bounds of its contents, or a macro other than \mathchoice that would work here?



\newcommand {\normbrak} [3][] {...then\fronorm[-1]{\hat H}– David Carlisle Jan 06 '22 at 20:41\left\| \right\|when it "looks good" and\| \|when it "looks good" except to choose based on whether display math is being used. If I don't have the choice made by the macro itself, then I have to implement at least two versions of each of the seven macros, which smacks of bad design. So I'm at a loss. – COTO Jan 07 '22 at 01:04