Tell me more ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm using LaTeX with TikZ to create a right angle triangle. Now I would like to label each angle by adding a half circle and a text label.

Unfortunately I only managed to create a label for the gamma angle. What do I need to do in order to put such a label into the remaining corners?

\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;
\end{tikzpicture}
share|improve this question
Welcome to TeX.sx! No need to add thanks, simply upvote good replies to your questions – Peter Jansson Feb 2 at 13:30

2 Answers

up vote 12 down vote accepted

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:

enter image description here

Disclaimer

Hoping that the labels are right.

share|improve this answer
That's an awesome solution. (And yes, the labels are right. ;-)) – Patrick Feb 2 at 13:57
1  
+1 for replacing $$ with \textit. – T. Verron Feb 2 at 17:55
@T.Verron: that's the first thing done after having drawn the triangle :) – Claudio Fiandrino Feb 3 at 8:53

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.

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.