# Too much space below norm of vector

I'm trying to find the right definition for the norm of a vector. I used this macro before :

\newcommand{\norme}[2][]{\ensuremath{\left\lVert #2 \right\rVert_{#1}}}


(optionnal argument is to specify some special norms).

But it sometimes give bad result. Just look at this :

\documentclass{article}
\usepackage{amsmath}
\usepackage{esvect}

\newcommand{\norme}[2][]{\ensuremath{\left\lVert #2 \right\rVert_{#1}}}

\begin{document}
\begin{equation*}
\norme[p]{u}^2, \norme[p]{\vv{u}}^2, \norme[p]{AB}^2, \norme[p]{\vv{AB}}^2.
\end{equation*}
\end{document}


Problem is, when there is an arrow above the vector (i.e. when there is a asymmetry between the height and the depth of the argument of norme), the result looks a bit ugly.

I found this new definition on a french forum :

\newcommand\norme[2][]{%
\begingroup\setbox0 \hbox{\ensuremath{#2}}%
\edef\drule{\vrule height\the\dimexpr\ht0+.25ex\relax
depth\the\dimexpr\dp0+.25ex\relax width.6pt }%
\quitvmode
\hbox{\drule\kern.16667em\drule\kern.16667em \box0
\kern.16667em\drule\kern.16667em\drule}\endgroup_{#1}
}


Problem now is that the vertical bars do not seem to behave like delimiters, so the square and the p on the right of the norm looks a bit too close :

\documentclass{article}
\usepackage{amsmath}
\usepackage{esvect}

\newcommand\norme[2][]{%
\begingroup\setbox0 \hbox{\ensuremath{#2}}%
\edef\drule{\vrule height\the\dimexpr\ht0+.25ex\relax
depth\the\dimexpr\dp0+.25ex\relax width.6pt }%
\quitvmode
\hbox{\drule\kern.16667em\drule\kern.16667em \box0
\kern.16667em\drule\kern.16667em\drule}\endgroup_{#1}
}

\begin{document}

\begin{equation*}
\norme[p]{u}^2, \norme[p]{\vv{u}}^2, \norme[p]{AB}^2, \norme[p]{\vv{AB}}^2.
\end{equation*}

\end{document}


What could I add to recover the proper behavior of my delimiters ?

Thanks for any help.

 I think what I need is put a "\mathopen" and a "\mathclose" somewhere in my macro definition, but I don't know where...

• BTW: you should never use automatic \left...\right for this very reason. IMO there is no need to scale the norm on \vv{u}, as you have already seen they often get too big. May 25 '21 at 15:30
• For the \newcommand{\norme}[2][]{\ensuremath{\left\lVert #2 \right\rVert_{#1}}} I suggest to see dynbrackets package. May 25 '21 at 15:51

Maybe you can use \adjustbox to manually set the height and vertical offset.

\documentclass{article}
\usepackage{amsmath}
\usepackage{esvect}

\newcommand{\norme}[2][]{\ensuremath{\left\lVert #2 \right\rVert_{#1}}}

\begin{document}
\begin{equation*}
\norme[p]{u}^2,
\norme[p]{\vv{u}}^2,
\norme[p]{AB}^2,
\norme[p]{\adjustbox{raise=-0.5ex, set height=2.0ex}{$\vv{AB}$}}^2.
\end{equation*}
\end{document}

• Thanks for the tip. Could be useful for one or two vectors, but I type documents with lots of those norms, so it's not very practical... But I'll remember the trick ;-) May 25 '21 at 15:30
• You can define a macro to automate this. May 25 '21 at 15:55

Using commath package:

\documentclass[12pt]{article}

\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{esvect}

\usepackage{commath}

\begin{document}
$\enVert[0]{u}^{2}_{p}, \enVert[0]{\vv{u}}^{2}_{p}, \enVert[0]{AB}^{2}_{p}, \enVert[0]{\vv{AB}}^{2}_{p}$
$\enVert[1]{u}^{2}_{p}, \enVert[1]{\vv{u}}^{2}_{p}, \enVert[1]{AB}^{2}_{p}, \enVert[1]{\vv{AB}}^{2}_{p}$
\end{document}


• Well, now the norm symbol on the last example is clearly too short :-) Too bad, the other three are quite alright ! May 25 '21 at 15:38
• @NicolasFRANCOIS It is true. In fact I have edited my answer using the factor scale 1. :-) May 25 '21 at 15:39
• +1, but I wonder where and how you find this (to me exotic) packages like commath :-) May 25 '21 at 15:39
• @Zarko LOL :-) ahahahh. And yet I not remember of a new recent package for the brackets that I have not download :-)))))))))))))))))))). May 25 '21 at 15:41
• The package indeed seems very interesting ;-) I found at least one or two constructions that I had hard time setting correctly ! May 25 '21 at 15:46

You can use the \DeclarePairedDelimiterXPP from math tools to define norme. It defines a star version, which is equivalent to a pair of implicit \left … \right in front of the delimiters, or use an optional argument among \big, \Big, \bigg, \Bigg, which is equivalent to a pair of \bigl … \bigr, &c.

\documentclass{article}
\usepackage{mathtools}
\usepackage{esvect}

\DeclarePairedDelimiterXPP\norme[1]{}\lVert\rVert{_p}{#1}

\begin{document}

\begin{equation*}
\norme*{u}^2, \norme*{\vv{u}}^2, \norme*{AB}^2, \norme*{\vv{AB}}^2.
\end{equation*}

\begin{equation*}
\norme*{u}^2, \norme*{\vv{u}}^2, \norme*{AB}^2, \norme[\big]{\vv{AB}}^2.
\end{equation*}

\end{document}


• This isn't really as flexible as the one the OP is using, in the version generated by DeclareP... the p is fixed. One cannot easily switch to q. That said, I'd used this one as well. May 25 '21 at 18:14
• @daleif: Maybe it might be done using xparse, but I didn't have time to test. Anyway, I think most of the time, only a small set of indices it used, so it is as simple to define a \pnorm, a\qnorm, and so on. May 25 '21 at 18:21
• I agree, it isn't really worth using an extra optional argument for May 25 '21 at 18:22