# Best way to denote an angle in TikZ?

What is the best and simplest way to denote an angle, with an arc and a label telling its name? I wish to be able to control (obviously) the vertices on which the angle lays, the name of the angle and also control the radius of the little arc and whether it should fill the whole part-of-a-circle shape in color.

-
Related question: tex.stackexchange.com/questions/34640/… –  Torbjørn T. Dec 19 '11 at 20:45
I just had a look, and all solutions seem so difficult to tweak with ... Is there no other way? –  Dave Dec 19 '11 at 21:20
I wouldn't say tkz-euclides way is difficult to change ... All the parameters you mention are easy to modify. –  Torbjørn T. Dec 19 '11 at 21:39
I didn't want to use that because as it is said there, the documentation is in French ... Anyway looks like I have no choice. Thanks! –  Dave Dec 19 '11 at 22:21
It would be helpful to see how you are drawing the angles, and perhaps a way you would like to be able to specify them in the form of a a fully compilable MWE. If the syntax you want to label the angles is not compilable you can comment that out. Otherwise it is difficult to see what parts you think are difficult to tweak. –  Peter Grill Dec 19 '11 at 23:35
show 3 more comments

## 5 Answers

Another example with TikZ only . The line important is \draw [color=black](a)+(10:1.2) node[rotate=0] {$\beta$}; the label for the angle is placed with the help of the center and this center is translated (a)+(10:1.2) .

\documentclass[11pt]{scrartcl}
\usepackage{tikz}
\usetikzlibrary{through,calc}

\begin{document}
\begin{tikzpicture}[scale=.8]
\coordinate (o) at (3,0);
\coordinate [label=150:$A$](a) at (0,0);
\coordinate [label=0:$B$](b) at (6,0);
\coordinate[label=90:$C$] (c) at (4,5);
\draw (a) -- (b) -- (c) -- cycle;
\node(c1) at (o)[draw,circle through=(a)] {};
\coordinate[label=90:$D$] (d) at (intersection 1 of c1 and a--c);
\coordinate[label=80:$E$] (e) at (intersection 1 of c1 and b--c);
\coordinate[label=60:$F$] (f) at (intersection  of a--e and b--d);
\coordinate[label=-90:$H$] (h) at ($(a)!(c)!(b)$);
\fill[red] let \p1=(f),\p2=(h) in (\x2,\y1) circle (2pt);
\draw[blue] (c) -- ($(a)!(c)!(b)$);
\draw [blue,very thick](b) +(142:.8cm) arc (142:180:.8cm);
\draw [color=black](b)+(160:1) node[rotate=0] {$\alpha$};
\draw [green!50!black,very thick](a) +(0:.8cm) arc (0:21:.8cm);
\draw [color=black](a)+(10:1.2) node[rotate=0] {$\beta$};
\draw [red!50!black,very thick](a) +(21:.8cm) arc (21:53:.8cm);
\draw [color=black](a)+(32:1.1) node[rotate=0] {$\gamma$};
\draw [red!50!black,very thick](b) +(110:.8cm) arc (110:142:.8cm);
\draw [color=black](b)+(128:1) node[rotate=0] {$\gamma$};
\draw [orange,very thick](c) +(-70:.8cm) arc (-70:-127:.8cm);
\draw [color=black](c)+(-100:1.2) node[rotate=0] {$\delta$};
\draw [orange,very thick](f) +(143:.8cm) arc (143:203:.8cm);
\draw [orange,very thick](f) +(24:.6cm) arc (24:-38:.6cm);
\draw (a) -- (e);
\draw (d) -- (b);
\draw[anchor=base,color=blue] (h.center)  ++(.3,0)  -- ++(0,0.3) -- ++(-0.3,0);
\end{tikzpicture}
\end{document}


-
Thanks! But that means I have to know the angles, don't I? Isn't it possible to define a macro or something which gets five parameters - F,A,H, some radius and \beta, and it would draw the angle? Maybe it is possible using trigonometry? I'll be glad for any help, at least syntax-speaking. –  Dave Dec 19 '11 at 21:36
In this case, you can try tkz-euclide or you can find in some answers how to calculate the angle of a line like AF and you can create a personal macro. –  Alain Matthes Dec 19 '11 at 22:15
@Dave did you ever manage this? –  Pureferret Feb 9 '12 at 8:59
how do i change length of the circle? –  Tumendemberel Zolboo Jun 25 at 1:25
add comment

I just have a look to this question and related ones but I don't see anywhere my solution to mark an angle when you don't know its measure (maybe I haven't read all the post about the topic...).

So here it is:

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

\begin{document}
\begin{tikzpicture}
\coordinate[label=below left:$A$] (A) at (0,0);
\coordinate[label=below right:$x$] (X) at (6,1);
\coordinate[label=above left:$y$] (Y) at (3,5);

\draw[thick] (X) -- (A) -- (Y);

% Mark the angle XAY
\begin{scope}
\path[clip] (A) -- (X) -- (Y);
\fill[red, opacity=0.5, draw=black] (A) circle (5mm);
\node at ($(A)+(30:7mm)$) {$\theta$};
\end{scope}

\end{tikzpicture}

\end{document}


I draw a full circle and I hide the bad part of it by clipping with a path built with the three points which define the angle. It seems so easy that it might be a bad way to do it but it works pretty well. Here I put manually the angle measure to place \theta but it could be automated surely.

Please, feel free to comment it if you think there are some situations where it doesn't work!

-
This solution looks smart but it could break in the (perhaps unreasonable) case that the triangle Axy is too small to contain all of the angle mark. –  Ben Alpert May 12 '12 at 1:23
I find it a nice solution! But, I think that because the way clipping works the filling of the (clipped) circle overlaps the edges of the angle. I could not find a way to solve this issue with this approach. –  Dror Dec 19 '13 at 14:37
is there any way to make arc's filling transparent and leaving circle visible –  Tumendemberel Zolboo Jun 24 at 0:54
add comment

I have developped 2 macros that I think can help you:

\newcommand{\Angulo}[7]{
\draw[#1]
let \p1=($(#3) - (#4)$), \p2=($(#5) - (#4)$),
\n{aIni}={atan2(\x1,\y1)},
\n{aFin}={atan2(\x2,\y2)},
\n{aMed}={0.5*\n{aIni}+0.5*\n{aFin}}
in ($(#4)!#2 * \longU!(#3)$) arc (\n{aIni}:\n{aFin}:#2 * \longU)
node at ($(#4) + (\n{aMed}:#2 * \longU)$) [#6] {#7};
}

\newcommand{\AnguloC}[7]{
\draw[#1]
let \p1=($(#3) - (#4)$), \p2=($(#5) - (#4)$),
\n{aIni}={atan2(\x1,\y1)},
\n{aFin}={360+atan2(\x2,\y2)},
\n{aMed}={0.5*\n{aIni}+0.5*\n{aFin}}
in ($(#4)!#2 * \longU!(#3)$) arc (\n{aIni}:\n{aFin}:#2 * \longU)
node at ($(#4) + (\n{aMed}:#2 * \longU)$) [#6] {#7};
}

\begin{tikzpicture}
%      Parameters:
%      \Angulo{drawing style}{radius}{starting point}{center point}{ending point}{text style}{text};
%      You can use coordinates or node names as points.

\coordinate (nodeCenter) at (0,0);
\Angulo{blue,->}{1}{10,0}{nodeCenter}{0,10}{above right}{$\alpha$};
\AnguloC{red,<-}{1}{0,10}{nodeCenter}{10,0}{above right}{$\alpha - 360$};
\end{tikzpicture}


-
what is \longU? –  Alain Matthes May 7 '12 at 6:24
add comment

I took the PolGab's code and changed it a little:

1. Put an optional argument to change the color
2. Change order of points to name the angle (usually in angle ABC, B is the origin...)
3. Automate the position of the label.

Here is the code:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,intersections}

\newcommand\markangle[6][red]{% [color] {X} {origin} {Y} {mark} {radius}
% filled circle: red by default
\begin{scope}
\path[clip] (#2) -- (#3) -- (#4);
\fill[color=#1,fill opacity=0.5,draw=#1,name path=circle]
(#3) circle (#6mm);
\end{scope}
% middle calculation
\path[name path=line one] (#3) -- (#2);
\path[name path=line two] (#3) -- (#4);
\path[%
name intersections={of=line one and circle, by={inter one}},
name intersections={of=line two and circle, by={inter two}}
] (inter one) -- (inter two) coordinate[pos=.5] (middle);
% bissectrice definition
\path[%
name path=bissectrice
] (#3) -- (barycentric cs:#3=-1,middle=1.2);
% put mark
\path[
name intersections={of=bissectrice and circle, by={middleArc}}
] (#3) -- (middleArc) node[pos=1.3] {#5};
}

\begin{document}
\begin{tikzpicture}
\coordinate[label=below left:$A$] (A) at (0,0);
\coordinate[label=below right:$B$] (B) at (2,0);
\coordinate[label=above:$C$] (C) at (5,5);

\draw[thick] (B) -- (A) -- (C) -- cycle;

\markangle{A}{B}{C}{$\beta$}{5}
\markangle[blue]{B}{A}{C}{$\alpha$}{6}
\markangle[green]{B}{C}{A}{$\gamma$}{12}
\end{tikzpicture}

\end{document}


It will be great if we could pass the radius of the mark as an optional argument also (for instance 5mm by default). Thus, we could use either \markangle{A}{B}{C} if we want to use default values for color and mark radius or \markangle[blue, 10]{A}{B}{C} if we don't. But I think it is impossible because a \newcommand just takes one optional argument, right?

-
add comment

Here is a complement to sylcha's answer.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,intersections}

\newcommand\markangle[6]{% origin X Y radius radiusmark mark
% fill red circle
\begin{scope}
\path[clip] (#1) -- (#2) -- (#3);
\fill[color=red,fill opacity=0.5,draw=red,name path=circle]
(#1) circle (#4);
\end{scope}
% middle calculation
\path[name path=line one] (#1) -- (#2);
\path[name path=line two] (#1) -- (#3);
\path[%
name intersections={of=line one and circle, by={inter one}},
name intersections={of=line two and circle, by={inter two}}
] (inter one) -- (inter two) coordinate[pos=.5] (middle);
% put mark
\node at ($(#1)!#5!(middle)$) {#6};
}

\begin{document}
\begin{tikzpicture}
\coordinate[label=below left:$A$] (A) at (0,0);
\coordinate[label=below right:$x$] (X) at (2,0);
\coordinate[label=above left:$y$] (Y) at (-3,5);

\draw[thick] (X) -- (A) -- (Y);

\markangle{A}{X}{Y}{7mm}{5mm}{$\theta$}
\end{tikzpicture}

\end{document}

-
your automated name of the angle is really smart! I will definitely use it in other occasions, thanks! However I don't understand the coordinate(m)in the clipping path. Is it necessary to name the point #3? –  sylcha May 12 '12 at 17:03
@sylcha the coordinate(m) in the clipping path was just a trace of an old test. I deleted it. –  Paul Gaborit May 13 '12 at 7:39
add comment