[Tex/LaTex] How to get a vertical bar which is the exact size of the object

amsmathfractionsmath-modemathtoolssymbols

I wish to use two vertical bars to sandwich a whole object:

enter image description here

What I found is that

(Failure 1) if I use usual \mid or \rvert or |, it is too small.

enter image description here

(Failure 2) if I use usual \left| or \right|, it is too big (due to that the unequal sizes of the numerator and the denominator).

enter image description here

(Failure 3) if I use usual \left| or \right| on the numerator and the denominator separately, even though the size is correct, the the | is not connected. I wish to have | | sandwich from the outside. I wish to have the whole bar connected from the numerator to the denominator.

enter image description here

Here is my code:

    \documentclass[aps]{revtex4} 
    \usepackage{amsmath,amssymb}
    \begin{document}
    $${\frac{  S }{  \overset{N}{\underset{{a=1}}{  \sum}}  T_a  } } $$

    $$\left|  {\frac{  S }{  \overset{N}{\underset{{a=1}}{  \sum}} T_a   } } \right| $$

$$\lvert \mid |  {\frac{  S }{  \overset{N}{\underset{{a=1}}{  \sum}}  T_a  } } | \mid \rvert$$

$${\frac{  \left|  S  \right| }{ \left|   \overset{N}{\underset{{a=1}}{  \sum}} T_a \right|   } }$$

    \end{document}

Is there a better way to fix this problem? Many thanks. Comments are welcome.

Best Answer

You can try with \vline

MWE:

\documentclass[aps]{revtex4}
\usepackage{amsmath,amssymb}
\begin{document}
Your attempt

\[\left|\frac{S}{\sum\limits^{N}_{a=1}T_{a}}\right|\]

With \verb|\vline|

\[\vline\,\frac{S}{\sum\limits^{N}_{a=1}T_{a}}\,\vline\]

\end{document} 

Output:

enter image description here

Some remarks:

  1. Use \[...\]\ instead of $$. See Why is \[ ... \] preferable to $$ ... $$?
  2. Use \limits instead of \overset and \underset to obtain subscripts and superscrips as in \displaystyle.