4

I want to put a double vertical line among some formulas in order to separate them, but the size is not the same. I used \left\| and \right\| for double vertical line. The size should follow the vertical line that encloses the WMi formula.

    {\textbf{cos(W_M, V_M)}\overset{\Delta}{=}\frac{W_{M_i}.V_{M_j}}{(\left\|W_{M_i} \right\|\left\|V_{M_j}\right\|)}}

enter image description here

3 Answers 3

2

With use of the mathtools and amssymb packages:

\documentclass{article}
\usepackage{mathtools, amssymb} 
\DeclarePairedDelimiter{\norm}{\lVert}{\rVert}

\begin{document}

\[
  \cos(W_M, V_M) \triangleq
    \frac{W_{M_i} \, V_{M_j}}
         {\bigl(\norm{W_{M_i}} \norm{V_{M_j}}\bigr)}
\]
or 
\[
  \cos(W_M, V_M) \triangleq
    \frac{W_{M_i} \, V_{M_j}}
         {\bigl(\norm*{W_{M_{i\vphantom{j}}}} \norm*{V_{M_j}}\bigr)}
\]
\end{document}

enter image description here

0
4

Let's look at your input:

{\textbf{cos(W_M, V_M)}\overset{\Delta}{=}\frac{W_{M_i}.V_{M_j}}{(\left\|W_{M_i} \right\|\left\|V_{M_j}\right\|)}}
  1. The outer braces do nothing at all, so it's best to remove them
  2. \textbf just produces a warning and does nothing
  3. “cos” should be \cos
  4. \overset{\Delta}{=} is good, but probably you want \triangleq
  5. The inner (or scalar) product should not be denoted by a (low) period, but rather with a centered dot
  6. The parentheses (...) are not needed in the denominator and make for harder reading1
  7. \left and \right in your code do harm, rather than being helpful

Points 1–4 and 6 can be addressed very easily. For point 5, use \cdot.

Let's come to the main point of your question. For the norm of vectors, use

\lVert <vector> \rVert

It's generally not needed (nor advisable) to use \left\lVert and \right\rVert, because the automatically sized fences might be of different size or too tall anyway.2

Note, instead, \, between the two norms to help readers in distinguishing between them.3

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}

\begin{document}

\begin{equation*}
\cos(W_M, V_M)
\triangleq
\frac{W_{M_i} \cdot V_{M_j}}{\lVert W_{M_i} \rVert\,\lVert V_{M_j}\rVert}
\end{equation*}

\end{document}

enter image description here

Footnotes

1 With parentheses in the denominator, a reader might think that there's something missing. Avoid redundant parentheses.

2 Here's what you get from adding \left and \right in front of \lVert and \rVert

enter image description here

Can you see the difference, which is caused by the fact that “j” descends below the baseline? There is no need that the fences completely cover what's between them, particularly if it's just a descender or an accent that's not covered.

3 Without \, the output would be

enter image description here

which requires the reader to count the bars.

3

Don't use \left...\right unless it's really necessary. Use fixed-height adjustments like \bigl...\bigr. If you must, you can use \vphantom to adjust the \left...\right delimiters to be equal (\left\| \vphantom{V_{M_j}} W_{M_i} \right\|). Below I suggest dropping the sizing you used.

enter image description here

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\[
  \cos(W_M, V_M) \overset{\Delta}{=}
    \frac{W_{M_i} \, V_{M_j}}{\bigl( \| W_{M_i} \| \, \| V_{M_j} \| \bigr)}
\]

\end{document}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .