Analysis
Let's see what physics.sty
does. First, the definition of \norm
:
\DeclareDocumentCommand\norm{ l m }{\braces#1{\lVert}{\rVert}{#2}} % Norm
The l
argument type collects everything up to (and excluding) the first {
. Now let's look at \braces
:
\DeclareDocumentCommand\braces{}{{\ifnum\z@=`}\fi\@braces}
I see no reason for this \ifnum
; anyway, it means we need to look at \@braces
:
\DeclareDocumentCommand\@braces{ s t\big t\Big t\bigg t\Bigg m m m }
{ % General braces with automatic and manual sizing
\IfBooleanTF{#1}
{\left#6\smash{#8}\right#7\vphantom{#8}}
{
\IfBooleanTF{#2}{\bigl#6{#8}\bigr#7}{
\IfBooleanTF{#3}{\Bigl#6{#8}\Bigr#7}{
\IfBooleanTF{#4}{\biggl#6{#8}\biggr#7}{
\IfBooleanTF{#5}{\Biggl#6{#8}\Biggr#7}{\left#6{#8}\right#7}
}
}
}
}
\ifnum\z@=`{\fi}
}
Wow! One of the ugliest macro definitions I have ever seen. Anyway, this shows what happens when you call \norm*{A^k}_{2}
: it gets translated into
{% <-- from the \ifnum in \braces
\left\lVert\smash{A^k}\right\rVert\vphantom{A^k}
}% <-- from the \ifnum in \@braces
which is just silly. Some notes, now.
What I said about “no reason” now turns into “it's wrong”.
Where's the problem in saying #6#8#7
instead of using \left
and \right
whose final job is just to add unwanted horizontal space?
Where's the advantage in typing \norm\big{x}
over \norm[\big]{x}
à la mathtools
?
Possible solutions in order of personal preference
- Avoid
physics.sty
.
- Ask the author of
physics.sty
to clean up the package code.
Add
\usepackage{mleftright}
\mleftright
to your preamble.
Comments
I recommend NOT using automatic sizing unless you know precisely that it's OK. Which, as shown by the output of \norm{A^k}_2
, is not this case. Please, note the “not” in boldface italic uppercase.
The physics
package is a prime example of how to abuse xparse
. As far as I can see, it's a collection of macros that can easily be defined in the document preamble as needed, maybe with the help of mathtools
(not with automatic sizing by default, of course).
Finally: your idea of \mathrlap
ping the subscript is not so good. But you're the final judge on it.