# How to write norm which adjusts its size? [duplicate]

I need to write norm of sum, but the sum symbol is larger than tho norm symbol (||) and it doesn't look good. Is there any symbol for norm which will adjust its size?

\documentclass[12pt,a4paper]{article}
\begin{document}
$$||\left(\sum_{n=1}^N \bf P_{\rm n}\rm\right) ||^2 = \left(\sum_n \frac{E_n}{c}\right)^2 - \left(\sum_n \bf p_{\rm n}\rm \right)^2$$
\end{document}

• Please, use \mathbf{P}_{n} and don't use \rm or \bf any more: they have been obsolete for more than ten years in LaTeX. – egreg Apr 6 '13 at 10:22

Either of the following methods should work:

• You could load the amsmath package and define a \norm macro as follows:

\newcommand{\norm}[1]{\left\lVert#1\right\rVert}


and then write

\norm{ \biggl(\sum_{n=1}^N \mathbf{P}_{n}\biggr) }


in the equation of interest. Note that the round parentheses will be too big if you write \left( and \right); I recommend you write \biggl( and \biggr) instead.

Your example code may therefore be written as

\documentclass[12pt,a4paper]{article}
\usepackage{amsmath}
\newcommand\norm[1]{\left\lVert#1\right\rVert}
\begin{document}
$$\norm{ \biggl(\sum_{n=1}^N \mathbf{P}_{n}\biggr) }^2 = \biggl(\sum_n \frac{E_n}{c}\biggr)^2 - \biggl(\sum_n \mathbf{p}_{n} \biggr)^2$$
\end{document}


• Some might say that the resulting norm "fences" in the example above are a bit too large and thus threaten to dominate visually the rest of the math stuff. (This happens, of course, because the macro uses \left and \right directives to size the fences.) To fix this issue, you could load the mathtools package and insert the following instruction in the preamble:

\DeclarePairedDelimiterX{\norm}[1]{\lVert}{\rVert}{#1}


and use the \norm macro with an explicit size instruction (here: \bigg, i.e., the same size as for the parentheses):

\documentclass[12pt,a4paper]{article}
\usepackage{mathtools}
\DeclarePairedDelimiterX{\norm}[1]{\lVert}{\rVert}{#1}
\begin{document}
$$\norm[\bigg]{\biggl(\sum_{n=1}^N \mathbf{P}_{n}\biggr) }^2 = \biggl(\sum_n \frac{E_n}{c}\biggr)^2 - \biggl(\sum_n \mathbf{p}_{n} \biggr)^2$$
\end{document}


• Is there a reason why \lvert and \rvert should be preferred over \|? – Vincent Nivoliers Apr 6 '13 at 10:21
• take a look here – Peater de Xel Apr 6 '13 at 10:22
• @VincentNivoliers - Note that \Vert is equivalent to \|. The l and r prefixes inform TeX that the commands \lVert and \rVert should be given math codes mathopen and mathclose, respectively. (TeX has no way of knowing how to modify the default math code of \Vert.) – Mico Apr 6 '13 at 10:44
• Any reason why \norm is not pre-defined in amsmath or some other package? It is a quite common operation. – juliohm Jan 23 '19 at 14:49
• @juliohm - Questions about why some feature may be present or absent from any particular LaTeX package should be addressed to the package's maintainer(s). – Mico Mar 8 '19 at 10:57

Use \Vert instead of ||. You can prefix \Vert with any brace-sizing-command, like \left, \right, \big, ..

\documentclass[12pt,a4paper]{article}
\begin{document}
$$\left\Vert\left(\sum_{n=1}^N \bf P_{\rm n}\rm\right) \right\Vert^2 = \left(\sum_n \frac{E_n}{c}\right)^2 - \left(\sum_n \bf p_{\rm n}\rm \right)^2$$
\end{document}


• If you want a more 'polished' look for a special case, just look around and search for absolute value. There are many questions here (like this one) which provide additional information, if you want to know more ;) – Peater de Xel Apr 6 '13 at 10:15
• All the \rm commands used are wrong: besides being an obsolete command, the n should be in italics. Also \bf is obsolete, use \mathbf{P} and \mathbf{p}. – egreg Apr 6 '13 at 10:16
• @egreg: Suzie wrote the n in E_n in italics, so I think it was a choice to typeset the n in P_n in an upright shape. – Peater de Xel Apr 6 '13 at 10:18
• @ralfix According to mathematical conventions, an italic and an upright "n" don't necessarily denote the same object. My feeling is that \rm has been used in order to countermand \bf, but it's wrong to begin with. – egreg Apr 6 '13 at 10:20
• @egreg Thank you, the \mathbf{} is really great. Now my work looks much better :) – Suzie Apr 6 '13 at 18:09