Automatically draw and labels angles of a triangle in TikZ
I'd use tkz-euclide
for this task. It provides a nice macro \tkzMarkAngle
which is really of help in this case.
The code:
\documentclass[tikz,border=2pt,png]{standalone}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}[thick]
\coordinate (O) at (0,0);
\coordinate (A) at (4,0);
\coordinate (B) at (0,2);
\draw (O)--(A)--(B)--cycle;
\tkzLabelSegment[below=2pt](O,A){\textit{adjacent leg}}
\tkzLabelSegment[left=2pt](O,B){\textit{opposite leg}}
\tkzLabelSegment[above right=2pt](A,B){\textit{hypotenuse}}
\tkzMarkAngle[fill= orange,size=0.65cm,%
opacity=.4](A,O,B)
\tkzLabelAngle[pos = 0.35](A,O,B){$\gamma$}
\tkzMarkAngle[fill= orange,size=0.8cm,%
opacity=.4](B,A,O)
\tkzLabelAngle[pos = 0.6](B,A,O){$\alpha$}
\tkzMarkAngle[fill= orange,size=0.7cm,%
opacity=.4](O,B,A)
\tkzLabelAngle[pos = 0.5](O,B,A){$\beta$}
\end{tikzpicture}
\end{document}
The result:
Disclaimer
Hoping that the labels are right.
As Torbjørn T. was suggesting in its comment, it is even possible to create square angles thanks to the macro \tkzMarkRightAngle
. The previous example becomes:
\documentclass[tikz,border=2pt,png]{standalone}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}[thick]
\coordinate (O) at (0,0);
\coordinate (A) at (4,0);
\coordinate (B) at (0,2);
\draw (O)--(A)--(B)--cycle;
\tkzLabelSegment[below=2pt](O,A){\textit{adjacent leg}}
\tkzLabelSegment[left=2pt](O,B){\textit{opposite leg}}
\tkzLabelSegment[above right=2pt](A,B){\textit{hypotenuse}}
\tkzMarkRightAngle[fill=orange,size=0.5,opacity=.4](A,O,B)% square angle here
\tkzLabelAngle[pos = 0.35](A,O,B){$\gamma$}
\tkzMarkAngle[fill= orange,size=0.8cm,%
opacity=.4](B,A,O)
\tkzLabelAngle[pos = 0.6](B,A,O){$\alpha$}
\tkzMarkAngle[fill= orange,size=0.7cm,%
opacity=.4](O,B,A)
\tkzLabelAngle[pos = 0.5](O,B,A){$\beta$}
\end{tikzpicture}
\end{document}
The result:
A solution with 'pure' tikz
could be:
\documentclass[tikz]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[thick]
\draw(0,0) -- (90:2cm) node[midway,left]{$opposite\ leg$} -- (0:4cm) node[midway,above right]{$hypotenuse$} -- (0,0) node[midway,below]{$adjacent\ leg$};
\draw[fill=lightgray, thick] (0,0) -- (0:0.8cm) arc (0:90:0.8cm) node at (45:0.5cm) {$\gamma$} -- cycle;
\draw[fill=lightgray, thick] (4,0) -- ++(180:0.8cm) arc (180:180-atan2(4,2):0.8cm) node at ($(167:0.6cm)+(4,0)$) {$\alpha$} -- cycle;
\draw[fill=lightgray, thick] (0,2) -- ++(-90:0.8cm) arc (-90:-90+atan2(2,4):0.8cm) node at ($(-60:0.5cm)+(0,2)$) {$\beta$} -- cycle;
\end{tikzpicture}
\end{document}
Note that you need the calc
library and you need to tweak the coordinates by hand if you change the size of the triangle. Of course you can parametrize to some extent by defining lengths (e.g. \def\adjleg{4}
and \def\oppleg{2}
) and use these in the figure. The angles are a bit more difficult, though.