# Label angle with tikz

I am able to draw a nice right triangle with

\begin{tikzpicture}[thick]
\draw (0,0)  -- (4,0) node[midway,below]{$f$} -- (4,2) node[midway,right]{$\frac{x}{2}$}-- cycle;
\end{tikzpicture}


Now I want to label the left angle of the triangle and I am stuck on how to do this.

• The question is "how to label a vertice" and it's more complicated to label an angle ! Commented Jun 15, 2011 at 13:56
• @Altermundus: So something like tpub.com/math1/20.htm57.gif, especially the arrows that point to the start/end of the angle, is not easy doable?
– Flow
Commented Jun 15, 2011 at 16:28
• Yes it's possible but not with the same facility ! :) Commented Jun 15, 2011 at 16:34
• @Altermundus: Could you maybe elaborate this a bite more? I am new to tikz.
– Flow
Commented Jun 15, 2011 at 16:56
• @Flow Without the arrows, it's simple. You can clip the triangle and draw a circle with center A. If you know the angle, it's also simple, you can draw an arc (look at my question tex.stackexchange.com/questions/20833/…) but If you don't know the value of the angle, you need to calculate this value and then you need to draw the arc. Commented Jun 15, 2011 at 18:20

My answer shows how to label the vertex and the angle. The macro tikzAngleOfLineis not optimized

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}

\newcommand{\tikzAngleOfLine}{\tikz@AngleOfLine}
\def\tikz@AngleOfLine(#1)(#2)#3{%
\pgfmathanglebetweenpoints{%
\pgfpointanchor{#1}{center}}{%
\pgfpointanchor{#2}{center}}
\pgfmathsetmacro{#3}{\pgfmathresult}%
}

\begin{tikzpicture}
\coordinate (A) at (1,1);
\coordinate (B) at ($(A)+(25:3)$);
\coordinate (C) at ($(A)+(100:5)$);
\draw (A) node[left]{$A$} -- (B) node[right]{$B$}node[midway,below]{$c$} -- (C)node[above]{$C$}node[midway,above]{$a$} -- (A)node[midway,left]{$b$};

\tikzAngleOfLine(A)(B){\AngleStart}
\tikzAngleOfLine(A)(C){\AngleEnd}
\draw[red,<->] (A)+(\AngleStart:2cm) arc (\AngleStart:\AngleEnd:2 cm);
\node[circle,fill=green] at ($(A)+({(\AngleStart+\AngleEnd)/2}:1 cm)$) {$\alpha$};
\end{tikzpicture}
\end{document}


Here is a solution using TikZ 3.0:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{quotes,angles}
\begin{document}
\begin{tikzpicture}
\draw
(3,-1) coordinate (a) node[right] {a}
-- (0,0) coordinate (b) node[left] {b}
-- (2,2) coordinate (c) node[above right] {c}
pic["$\alpha$",draw=orange,<->,angle eccentricity=1.2,angle radius=1cm] {angle=a--b--c};
\end{tikzpicture}
\end{document}


• Sweet! The future's looking pretty bright!
– Jake
Commented Oct 8, 2013 at 14:23
• This might not work when the language is set to something other than English. (Didn't work for me in Swedish.) Commented Jul 22, 2014 at 11:50
• To fix the language/babel problem, put \usetikzlibrary{babel} in the preamble (See tex.stackexchange.com/questions/166772/…). Commented Jul 22, 2014 at 11:57
• Would it be possible for you to add a line where you set the angle style (color, eccentricity, radius) globally? Commented Aug 28, 2015 at 7:32
• @Eric Here or here. Commented May 4, 2016 at 1:23

I've built on the excellent answer from Alain Matthes above and defined a more direct macro. I've also included an example of its use case.

\newcommand{\tikzAngleOfLine}{\tikz@AngleOfLine}
\def\tikz@AngleOfLine(#1)(#2)#3{%
\pgfmathanglebetweenpoints{%
\pgfpointanchor{#1}{center}}{%
\pgfpointanchor{#2}{center}}
\pgfmathsetmacro{#3}{\pgfmathresult}%
}
\newcommand{\tikzMarkAngle}[3]{
\tikzAngleOfLine#1#2{\AngleStart}
\tikzAngleOfLine#1#3{\AngleEnd}
\draw #1+(\AngleStart:0.15cm) arc (\AngleStart:\AngleEnd:0.15cm);
}

\begin{tikzpicture}[scale=4,line width=1pt]
\coordinate (B) at (0,0);
\coordinate (C) at (1,0);
\coordinate (A) at (0.5,1.5);
\draw (A) -- (B) -- (C) -- cycle;
\node [below left]  at (B) {B};
\node [below right] at (C) {C};
\node [above]       at (A) {A};
\coordinate (D) at (barycentric cs:A=0.5 ,C=0.5);
\node [above right] at (D) {D};
\draw (B) -- (D);

\tikzAngleOfLine(A)(C){\AngleStart}
\tikzAngleOfLine(A)(B){\AngleEnd}
\draw (A)+(\AngleStart:0.15cm) arc (\AngleStart:\AngleEnd:0.15cm);

\tikzMarkAngle{(C)}{(B)}{(A)}
\tikzMarkAngle{(D)}{(A)}{(B)}
\end{tikzpicture}


Here's an example use of the macro.

I've also included a slightly more involved example below.

\newcommand{\tikzAngleOfLine}{\tikz@AngleOfLine}
\def\tikz@AngleOfLine(#1)(#2)#3{%
\pgfmathanglebetweenpoints{%
\pgfpointanchor{#1}{center}}{%
\pgfpointanchor{#2}{center}}
\pgfmathsetmacro{#3}{\pgfmathresult}%
}
\newcommand{\tikzMarkAngle}[4][0.15cm]{
\tikzAngleOfLine#2#3{\AngleStart}
\tikzAngleOfLine#2#4{\AngleEnd}
\draw[<->] #2+(\AngleStart:#1) arc (\AngleStart:\AngleEnd:#1);
}

\begin{tikzpicture}[scale=4,line width=1pt]
\coordinate (B) at (0,0);
\coordinate (C) at (1,0);
\coordinate (A) at (0.5,1.5);
\draw (A) -- (B) -- (C) -- cycle;
\node [below left]  at (B) {B};
\node [below right] at (C) {C};
\node [above]       at (A) {A};
\coordinate (D) at (barycentric cs:A=0.5 ,C=0.5);
\coordinate (E) at (barycentric cs:A=0.40 ,B=0.60);
\node [above right] at (D) {D};
\node [above left] at (E) {E};
\draw (B) -- (D);
\draw (C) -- (E);
\draw (E) -- (D);

\tikzMarkAngle{(A)}{(B)}{(C)}

\node at ($(A)+(-90:0.23)$) {$20^\circ$};
\tikzMarkAngle{(B)}{(D)}{(C)}
\node at ($(B)+(25:0.23)$) {$60^\circ$};
\tikzMarkAngle{(C)}{(B)}{(E)}
\node at ($(C)+(155:0.23)$) {$50^\circ$};

\begin{scope}[color=orange]
\tikzMarkAngle{(D)}{(E)}{(B)}
\node at ($(D)+(-20:0.15)$) {?=$30^\circ$};
\end{scope}

\tikzMarkAngle{(B)}{(A)}{(D)}
\node at ($(B)+(55:0.23)$) {$20^\circ$};
\tikzMarkAngle{(C)}{(E)}{(D)}
\node at ($(C)+(120:0.23)$) {$30^\circ$};

\coordinate (F) at (barycentric cs:A=0.50 ,B=0.50);
\node [above left] at (F) {F};
\draw (F) -- (D);
\draw (C) -- (F);

\coordinate (G) at (intersection of D--B and C--F);
\node [above] at (G) {G};

\draw (E) -- (G);
\begin{scope}[color=blue]
\tikzMarkAngle{(G)}{(F)}{(E)}
\node at ($(G)+(145:0.20)$) {$40^\circ$};
\tikzMarkAngle[0.07cm]{(F)}{(E)}{(G)}
\node at ($(F)+(-175:0.10)$) {$40^\circ$};
\tikzMarkAngle{(D)}{(A)}{(F)}
\node at ($(D)+(135:0.22)$) {$80^\circ$};
\end{scope}
\end{tikzpicture}


I have searched for many solutions. Finally, no one is satisfactory.

Solution 1: as shown in here, use

\tkzMarkAngle and \tkzLabelAngle


Problem: can't draw an arrow on the arc.

Solution 2: as show in the same place, use

\begin{scope}
\path[clip] (A) -- (E) -- (F) -- cycle;
\draw [red, fill=red!20] (A) circle (10pt);
\end{scope}


Problem: can't draw an arrow on the arc.

Solution 3: the solution in the accepted answer might be complicated for a beginner. And I tried the code, it seems the direction of the arc is not what I expected.

==================================================

My solution: Of course there are many other good solutions. Regarding the problem I am interested in, I came up with a simple solution. I believe many people already know about this. Just post it here for a memo.

%Requires \usetikzlibrary{calc} in the preamble
\begin{tikzpicture}
\coordinate (B) at (2.345,-1.234);
\coordinate (A) at (0,0);
\coordinate (C) at (-2.1,3.2);
\draw [densely dotted, thick] (B)--(A)--(C);
\draw (A) node[below] {$A$};
\draw (B) node[below] {$B$};
\draw (C) node[below left] {$C$};
% label the angle subtended at p1 by p2 and p3
% draw the arc
\draw[red,->,thick] let \p1=(A), \p2=(B), \p3=(C),
\n1={atan2(\x2-\x1,\y2-\y1)}, \n2={atan2(\x3-\x1,\y3-\y1)} in
($(\p1)!\angleRadius!(\p2)$) arc (\n1:\n2:\angleRadius);
% draw the label
\draw[red] let \p1=(A), \p2=(B), \p3=(C),
\n1={atan2(\x2-\x1,\y2-\y1)}, \n2={atan2(\x3-\x1,\y3-\y1)} in
(\p1)+(\n1/2+\n2/2:\angleRadius) node[above] {$\alpha$};
\end{tikzpicture}


Result:

We can use the following code to label the angle which is larger than 180.

\def\angleRadius{30pt}
\draw[red,->,thick] let \p1=(A), \p2=(B), \p3=(C), \n1={atan2(\x2-\x1,\y2-\y1)}, \n2={atan2(\x3-\x1,\y3-\y1)} in
($(\p1)!\angleRadius!(\p2)$) arc (\n1:\n2-360:\angleRadius);
\draw[red] let \p1=(A), \p2=(B), \p3=(C), \n1={atan2(\x2-\x1,\y2-\y1)}, \n2={atan2(\x3-\x1,\y3-\y1)} in
(\p1)+(\n1/2+\n2/2+180:\angleRadius) node[below] {$\alpha$};


The result is:

Features of the solution:

1. Simple. Simply input the three points that determine the angle.
2. the arc is generated by arc command. Can set the arrow of the arc and of course other properties.
3. Require \usetikzlibrary{calc}, but no \usepackage{tkz-euclide}.
• You are missing the angle label. Also the problems that you have given are also solvable but still this is also nice. Commented Oct 5, 2012 at 16:22
• @percusse: I have added the label. (I don't know how to integrate the label and arc under one \draw command.) BTW, thanks for editing my answer. Based on your version, I revised it a little bit. I still prefer to introduce \p1,\p2,\p3 instead of only \p1 and \p2 because if I have other three points, I can simply put them in the p1,p2,p3 places, and need not to modify any other things. Commented Oct 6, 2012 at 3:35
• Although this topic is quite old, but I want to correct wrong comment in the answer by Shiyu. More precisely, in Solution 1 he said \tkzMarkAngle can't draw an arrow on the arc. However, tkz-euclide can draw an arrow on the arc, for example, \tkzMarkAngle[size=.5,arrows=->](A,B,C) Commented Feb 4, 2018 at 20:04
• \tkzMarkAngle CAN draw an arrow on the arc! (See: https://tex.stackexchange.com/a/134617/101831) Commented Jul 19, 2019 at 10:59

You can insert a node at the start of the triangle, at (0,0), and put a label to the left of it with node[left]{$A$}. A full example:

\documentclass{article}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[thick]
\draw (0,0) node[left]{$A$}  -- (4,0) node[midway,below]{$f$} -- (4,2) node[midway,right]{$\frac{x}{2}$}-- cycle;
\end{tikzpicture}

\end{document}

• This doesn't draw the arc that the other answers do, but that wasn't really necessary in my case. Commented Sep 23, 2022 at 16:51

With tzplot:

\documentclass[tikz]{standalone}

\usepackage{tzplot}

\begin{document}

\begin{tikzpicture}[font=\scriptsize]
% triangle
\tzcoors(0,0)(A){$A$}[180](4,0)(B){$B$}[-45](4,2)(C){$C$}[45];
\tzpolygon(A){$f$}[b](B){$\frac x2$}[r](C){\scshape hypotenuse}[sloped,a](A);
% angle marks
\tzrightanglemark(A)(B)(C){90\textdegree}
\tzanglemark(A)(C)(B){$\theta$}
\tzanglemark(C)(A)(B){$\alpha$}
\tzanglemark'[->,red](C)(A)(B){$\beta$}[pos=1.2](20pt)
\end{tikzpicture}

\end{document}

• Thanks. Since tzplot package contains \AddToHook, which was added in the LaTeX version 2020-10-01, I have to update my Tex in order to make it compile. Commented Sep 16, 2022 at 6:40

Here is a 'basic' tikz solution with calc library also:

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}
\coordinate (A) at (1,1);
\coordinate (B) at ($(A)+(25:3)$);
\coordinate (C) at ($(A)+(100:5)$);
\draw (A) node[left]{$A$} -- (B) node[right]{$B$}node[midway,below]{$c$} -- (C)node[above]{$C$}node[midway,above]{$a$} -- (A)node[midway,left]{$b$};
\draw[red,<->] ($(A)+(25:1)$) arc(25:100:1) node[midway,circle,fill=green] () {$\alpha$};
\end{tikzpicture}
\end{document}


His output:

• Thanks for your answer, much appreciated. However, I wonder why is there a () in node[midway,circle,fill=green] ()?
– Flow
Commented Feb 7 at 10:05
• @Flow No problem. You can avoid the (). I published my solution because is a lot simpler with reference to others. For drawing the angle and its label. Commented Feb 7 at 10:15