# Vector addition

> The parallelogram rule for adding two vectors, on a light grid. A Geometry example with its complete LaTeX source, ready to copy or open in TeXeR.

A Geometry example in the TeXeR TikZ library: https://texer.org/library/geometry/vector-addition

Package: [Geometry](https://texer.org/library/geometry.md), on CTAN at https://ctan.org/pkg/pgf.

Tags: vectors, parallelogram rule, linear algebra

## Source

```latex
\usetikzlibrary{arrows.meta}

\begin{tikzpicture}[>={Stealth[length=3mm]}, thick]
  \draw[gray!25, thin] (-0.5,-0.5) grid (6,4.5);
  \draw[dashed, gray] (4,1) -- (5.5,4) (1.5,3) -- (5.5,4);
  \draw[->, blue!70!black] (0,0) -- node[below right] {$\mathbf{u}$} (4,1);
  \draw[->, red!70!black] (0,0) -- node[above left] {$\mathbf{v}$} (1.5,3);
  \draw[->, green!50!black] (0,0) -- node[above, sloped] {$\mathbf{u} + \mathbf{v}$} (5.5,4);
  \fill (0,0) circle (1.5pt) node[below left] {$O$};
\end{tikzpicture}
```

## As a complete document

The same example in a document that compiles on its own with pdfLaTeX:

```latex
\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usepackage{xcolor}
\usepackage{amsmath}
\usepackage{amssymb}
\usetikzlibrary{arrows.meta}

\begin{document}

\begin{tikzpicture}[>={Stealth[length=3mm]}, thick]
  \draw[gray!25, thin] (-0.5,-0.5) grid (6,4.5);
  \draw[dashed, gray] (4,1) -- (5.5,4) (1.5,3) -- (5.5,4);
  \draw[->, blue!70!black] (0,0) -- node[below right] {$\mathbf{u}$} (4,1);
  \draw[->, red!70!black] (0,0) -- node[above left] {$\mathbf{v}$} (1.5,3);
  \draw[->, green!50!black] (0,0) -- node[above, sloped] {$\mathbf{u} + \mathbf{v}$} (5.5,4);
  \fill (0,0) circle (1.5pt) node[below left] {$O$};
\end{tikzpicture}
\end{document}
```
