Take the 2-minute tour ×
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 '13 at 13:30

2 Answers 2

up vote 19 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.

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:

enter image description here

share|improve this answer
    
That's an awesome solution. (And yes, the labels are right. ;-)) –  Patrick Feb 2 '13 at 13:57
1  
+1 for replacing $$ with \textit. –  T. Verron Feb 2 '13 at 17:55
    
@T.Verron: that's the first thing done after having drawn the triangle :) –  Claudio Fiandrino Feb 3 '13 at 8:53
    
I know the OP specified an arc also for the right angle \gamma, but I'll just mention that if one wants a square instead, then one can use \tkzMarkRightAngle[fill=orange,size=0.5,opacity=.4](A,O,B). –  Torbjørn T. Aug 24 '13 at 18:19
    
@TorbjørnT.: it might be a nice addition, thanks. I'll edit as soon as possible. –  Claudio Fiandrino Aug 25 '13 at 10:20

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
    
This does not seem to work for me. I get this image instead using TeXLive2013. –  Peter Grill Jun 8 at 5:47

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.