# How can I type formula cosine of two vectors nice?

I want to find cosine of two vectors, I define the command \cross for cross product of two vectors. I tried

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{fourier}
\usepackage{esvect}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\newcommand{\cross}[2]{\biggl[\vv{#1},\vv{#2} \biggr]}
\begin{document}
$\cos \varphi =\dfrac{\cross{CA'}{CB} \cdot \cross{CA'}{CD}}{\left \vert \cross{CA'}{CB} \right\vert \cdot \left \vert \cross{CA'}{CD} \right\vert}.$
\end{document}


I feel the brackets in command \cross is not good. How can I repair them?

-

The square brackets seem to be needlessly tall. Specifically, I don't think it's necessary to make the square brackets sufficiently tall to have them enclose the arrows. Nobody should be confused by the arrows "sticking out" above the brackets. Hence, using \big instead of \bigg for the size of the brackets should be fine.

Where I also see room for improvement, typographically speaking, is in the uneven heights of the arrows that are produced by \vv. Since the uneven heights are caused by the presence of the "primes" in the first argument of the \cross macro, one way to address this issue is to automatically add a "vertical phantom" (composed of #1...) to the second argument of the \cross macro.

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}
\DeclarePairedDelimiter{\abs}{\lvert}{\rvert}
\usepackage{fourier,esvect}
\usepackage[margin=2cm]{geometry}
\newcommand{\cross}[2]{\bigl[ \vv{#1},\vv{#2\vphantom{#1}} \bigr]}
\newcommand\z{\vphantom{{}'}} % insert a vertical phantom as tall as a superscript prime
\begin{document}
$\cos \varphi =\dfrac{\cross{CA'}{CB} \cdot \cross{CA'}{CD}} {\abs*{\cross{CA'}{CB}} \cdot \abs*{\cross{CA'}{CD}} }\,.$
\end{document}

-

Another option is to use bold letters for vectors. I have also changed the backets to parenthesis, hoping that won't change the meaning in your subject. physics package is used for making vectors bold with \vb* macro. If you want upright letters for vectors, use \vb without star. Since \cross is defined by defined by physcis, I have changed it to \Cross.

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{fourier}
\usepackage{physics}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\newcommand{\Cross}[2]{(\vb*{#1},\vb*{#2})}
\begin{document}
$\cos \varphi =\dfrac{\Cross{CA'}{CB} \cdot \Cross{CA'}{CD}}{\vert \Cross{CA'}{CB} \vert \cdot \vert \Cross{CA'}{CD} \vert}$
\end{document}


I have also removed \left and \right from \vert.

-

One possible solution (since you haven't told us how you would like it to be, it's a guess):

\documentclass{article}

\usepackage{mathtools}
\usepackage{fourier}

\DeclarePairedDelimiter{\abs}{\lvert}{\rvert}
\newcommand*\cross[2]{\left[\overrightarrow{#1},\overrightarrow{#2}\right]}

\begin{document}

$$\cos\varphi = \frac{\cross{CA'}{CB} \cdot \cross{CA'}{CD}}{\abs*{\cross{CA'}{CB}} \cdot \abs*{\cross{CA'}{CD}}}.$$

\end{document}


In this way the brackets will automatically scale relative to the material.

Note that I have used \overrightarrow instead of \vv to avoid loading the esvect package. (I don't think it's a 'bad' package but I just prefer to load as few packages as possible.)

Update

In case you always have vectors like in the example, you can make the code simpler:

\documentclass{article}

\usepackage{mathtools}
\usepackage{fourier}

\DeclarePairedDelimiter{\abs}{\lvert}{\rvert}
\newcommand*\cross[2]{\left[\overrightarrow{#1},\overrightarrow{#2}\right]}
\newcommand*\crossProduct[3]{
\frac{\cross{#1}{#2} \cdot \cross{#1}{#3}}% nominator
{\abs*{\cross{#1}{#2}} \cdot \abs*{\cross{#1}{#3}}}% denominator
}

\begin{document}

$$\cos\varphi = \crossProduct{CA'}{CB}{CD}$$

\end{document}

-

One must be careful when disregarding the math axis, but it seems from your question that you are unhappy with the extra space below the vectors, about which the braces enclose. That extra space is there to give symmetry to the over-arrow vector notation.

Many would say that should not be disturbed, even if it looks odd. However, since you were looking for alternatives, here is one such solution that removes that space below the braces. But see what it does: it keeps the \cdot centered on the letters and therefore asymmetrical with respect to the height of the brace.

So, this is an option, but many would not say it is an improvement.

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{fourier}
\usepackage{esvect}
\usepackage{scalerel}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\newcommand{\cross}[2]{{\stretchleftright{[}{\vv{#1},\vv{#2}}{]}}}
\begin{document}
$\cos \varphi =\dfrac{\cross{CA'}{CB} \cdot \cross{CA'}{CD}} {\stretchleftright{\vert}{\protect\cross{CA'}{CB}}{\vert} \cdot \stretchleftright{ \vert}{\cross{CA'}{CD}}{\vert}}.$
\end{document}


-
"many would not say it is an improvement" I'm one of them. :) – Svend Tveskæg Mar 2 '14 at 17:04
@SvendTveskæg Having received "the heat of the flame" when disturbing the math axis in the past, I have grown more sensitive to the sanctity of the notion 8^O. If nothing else, the answer can visualize, for the OP, the negatives associated with a notional "fix". – Steven B. Segletes Mar 2 '14 at 17:14
I'm not saying your answer is bad at all! You are simply coming up with one way of doing it, so I think it's absolute fine. (I'm just saying that I'm not fond of the solution ... just as you aren't, if I'm not totally mistaken.) – Svend Tveskæg Mar 2 '14 at 17:18
@SvendTveskæg As with all things, there are tradeoffs. On this particular one, I really have no preference, and would myself therefore stick with the conventional solution. All to often, one gets an idea of the advantages that arise from a different approach only to find, upon implementation, that there are significant negatives, too. Only then does the wisdom of the original approach become truly manifest. – Steven B. Segletes Mar 2 '14 at 17:28
I know exactly what you mean. :) – Svend Tveskæg Mar 2 '14 at 17:35