# Tikz label angle between vectors

I'm trying to label the angle between the B vector and the y-axis but I don't know how. Can anybody help me with this? My code is the following

\begin{figure}[h]
\centering
\begin{tikzpicture}
\draw[->] (-1,0)--(4,0) node[right]{$x$};
\draw[->] (0,-1)--(0,4) node[above]{$y$};
\draw[->, ultra thick] (0,0) -- (2,0) node[below]{$\vec{A}$};
\draw[->, ultra thick] (0,0) -- (-1,1.732050808) node[left]{$\vec{B}$};
\end{tikzpicture}
\end{figure}


You can compute its value and then draw and label it (of course, the label can be any other):

\documentclass[tikz,border=1.618mm]{standalone}
\usepackage{siunitx} % only for \ang

\begin{document}
\begin{tikzpicture}
\draw[->] (-1,0)--(4,0) node[right]{$x$};
\draw[->] (0,-1)--(0,4) node[above]{$y$};
\draw[->, ultra thick] (0,0) -- (2,0) node[below]{$\vec{A}$};
\draw[->, ultra thick] (0,0) -- (-1,1.732050808) node[left]{$\vec{B}$};
% computing the angle:
\pgfmathsetmacro\myangle{atan(1/1.732050808)}
\draw (0,0.75) arc (90:90+\myangle:0.75) node[midway,above] {\rotatebox{90}{\ang{\myangle}}};
\end{tikzpicture}
\end{document}


Another option is the angles TikZ library (better with quotes too). If the label is not the angle value you don't need to compute it. For this option you will need to create the coordinates of all the points that define the angle.

\documentclass[tikz,border=1.618mm]{standalone}
\usetikzlibrary{angles,quotes}

\begin{document}
\begin{tikzpicture}
\draw[->] (-1,0)--(4,0) node[right]{$x$};
\draw[->] (0,-1)--(0,4) coordinate (Y) node[above]{$y$};
\draw[->, ultra thick] (0,0) -- (2,0) node[below]{$\vec{A}$};
\draw[->, ultra thick] (0,0) -- (-1,1.732050808) coordinate (B) node[left]{$\vec{B}$};
\coordinate (O) at (0,0);
\pic[draw, angle eccentricity=1.5,"$\alpha$"] {angle=Y--O--B};
\end{tikzpicture}
\end{document}


• Thank you very much :)) Jul 18, 2023 at 15:49