[Tex/LaTex] How to write norm which adjusts its size?

math-modesymbols

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}  
    \begin{equation}
     ||\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{equation}
   \end{document}  

Best Answer

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}  
      \begin{equation}
        \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{equation}
    \end{document} 
    

enter image description here

  • 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} 
      \begin{equation}
        \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{equation}
    \end{document}
    

enter image description here