2

How to make it look better:

enter image description here

Code:

    $$\left|\overrightarrow{a}-\overrightarrow{b}\right|^2=\left|\overrightarrow{a}\right|^2+\left|\overrightarrow{b}\right|^2-2\left|\overrightarrow{a}\right|\left|\overrightarrow{b}\right|\cos(\alpha)$$

The |a| looks awful...

David Carlisle
  • 757,742

3 Answers3

5

Using fixed size | and fixed height arrows, squeezing b so it's not excessively high on a

enter image description here

\documentclass{article}

\usepackage{amsmath} \newcommand\xvec[1]{\vec{\rule{0pt}{1.3ex}\smash{#1}}}

\begin{document}

[ \lvert\xvec{a}-\xvec{b}\rvert1^2=\lvert\xvec{a}\rvert^2+ \lvert\xvec{b}\rvert^2- 2\lvert\xvec{a}\rvert\lvert\xvec{b}\rvert\cos(\alpha) ]

\end{document}

David Carlisle
  • 757,742
4

I suggest you (a) get rid of all \left and \right sizing directives, (b) apply a consistent height for the arrows, and (c) load the old-arrows package for smaller arrowheads.

Before:

enter image description here

After:

enter image description here


\documentclass{article}
\usepackage{amsmath} % for \lvert and \rvert macros
\usepackage{old-arrows}  % uncomment for smaller arrowheads
\newcommand\ab{a\vphantom{b}}
\begin{document}

%[ % \left|\overrightarrow{a}-\overrightarrow{b}\right|^2 % =\left|\overrightarrow{a}\right|^2 % +\left|\overrightarrow{b}\right|^2 %-2\left|\overrightarrow{a}\right| % \left|\overrightarrow{b}\right| \cos(\alpha) %]

[ \lvert \overrightarrow{\ab}-\overrightarrow{b}\rvert^2 =\lvert \overrightarrow{\ab}\rvert^2 +\lvert \overrightarrow{b}\rvert^2 -2\lvert \overrightarrow{\ab}\rvert \lvert \overrightarrow{b}\rvert \cos(\alpha) ] \end{document}

Mico
  • 506,678
4

In my opinion it's hopeless to get “good looking” expressions involving \vec.

First of all, you should never use $$ and very sparingly \left and \right, which in this case produce oversized delimiters.

\documentclass{article}
\usepackage{amsmath}

\newcommand{\vcc}{\mspace{1mu}}% vector correction

\begin{document}

\begin{gather} \left|\overrightarrow{a}-\overrightarrow{b}\right|^2= \left|\overrightarrow{a}\right|^2+\left|\overrightarrow{b}\right|^2 -2\left|\overrightarrow{a}\right|\left|\overrightarrow{b}\right|\cos(\alpha) \ \left|\vec{a}-\vec{b}\right|^2= \left|\vec{a}\right|^2+\left|\vec{b}\right|^2 -2\left|\vec{a}\right|\left|\vec{b}\right|\cos(\alpha) \ \lvert\vec{a}-\vec{b}\rvert^2= \lvert\vec{a}\rvert^2+\lvert\vec{b}\rvert^2 -2\lvert\vec{a}\rvert,\lvert\vec{b}\rvert\cos(\alpha) \ \lvert\vec{a}-\vec{b}\vcc\rvert^2= \lvert\vec{a}\vcc\rvert^2+\lvert\vec{b}\vcc\rvert^2 -2\lvert\vec{a}\vcc\rvert,\lvert\vec{b}\vcc\rvert\cos(\alpha) \end{gather}

\end{document}

(1) is your input.

(2) is the same, but with \vec instead of \overrightarrow.

(3) uses \lvert and \rvert (which are recommended over the bare |).

(4) adds a tiny space before the closing delimiter; this space is not generally needed after \vec{<letter>}, but it's better when a fence follows, to avoid clashes. See later.

In (3) and (4) I also added \, between the consecutive \rvert and \lvert, so the reader doesn't mistake the symbol for \Vert.

enter image description here

Compare the output of (\vec{a}+\vec{b}) and (\vec{a}+\vec{b}\vcc)

enter image description here

egreg
  • 1,121,712