[Tex/LaTex] Labeling sides and angles of a right triangle for an argument of the Pythagorean Theorem

tikz-pgf

I would like to draw a right triangle so that its sides are not vertical or horizontal. (No coordinate axes.) I would like the legs to be labeled a and b and the hypotenuse to be labeled c. I would like to drop a perpendicular, drawn as a dotted line segment, from the vertex across the hypotenuse to the hypotenuse. (I heard that there was a command to instruct TikZ to do this.) This creates two smaller triangles that are similar to each other. I would like the four acute angles of the two smaller triangles to be marked with arcs; one pair of equal angles marked with "|" through it, and the other pair of equal angles marked with "||" through it.

The only code that I could offer is the code for labeling the vertices of the triangle and drawing the line segments between them. I know that there is much more to code. I reckon that it would be more convenient for anybody responding to decide on the coordinates of the vertices himself/herself.

Best Answer

Here's one possibility using "pure" TikZ:

enter image description here

The image was produced using simply

\begin{tikzpicture}
\RectTri{(0,3)}{(1,0)}{6cm}
\begin{scope}[xshift=8.5cm]
\RectTri[black]{(0,0)}{(4,2)}{4cm}
\end{scope}
\end{tikzpicture}

\RectTri has three mandatory arguments; the first two are the coordinates for the vertices of one of the legs and the third one is the length of the second leg. The optional argument lets you customize the style used to draw the triangle.

The code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,angles,quotes,decorations.markings}

\newcommand\RectTri[4][thick,green!50!black,text=black]{%
\coordinate [label=left:$C$] (C) at #2;
\coordinate [label=below right:$B$] (B) at #3;
\coordinate (aux) at ($ #2 ! 1 ! 90:#3 $);
\coordinate [label=above:$A$] (A) at ($ #2 !#4!(aux) $);

\coordinate (perp) at ($(A)!(C)!(B)$);
\draw[purple!70!black,thick,dashed] (C) -- (perp);

\draw[#1] 
  (C) -- 
  node[auto] {$b$} (A) -- 
  node[auto] {$c$} (B) --
  node[auto] {$a$} 
  (C)
  pic ["$\alpha$",draw,cyan,thick,angle radius=1cm] {angle = C--A--B} 
  pic ["$\alpha$",draw,cyan,thick,angle radius=1cm] {angle = B--C--perp}
  pic ["$\beta$",draw,orange!70!black,thick,angle radius=1cm] {angle = A--B--C}
  pic ["$\beta$",draw,orange!70!black,thick,angle radius=1cm] {angle = perp--C--A};
}

\begin{document}

\begin{tikzpicture}
\RectTri{(0,3)}{(1,0)}{6cm}
\begin{scope}[xshift=8.5cm]
\RectTri[black]{(0,0)}{(4,2)}{4cm}
\end{scope}
\end{tikzpicture}

\end{document}

And here's an approach using tkz-euclide:

\documentclass{article}
\usepackage{tkz-euclide}
\usetkzobj{all}

\begin{document}

\begin{tikzpicture}
\tkzDefPoint(0,1){A}
\tkzDefPoint(2,4){C}
\tkzDefPointWith[orthogonal normed,K=7](C,A)
\tkzGetPoint{B}

\tkzLabelPoint[left](A){$A$}
\tkzLabelPoint[right](B){$B$}
\tkzLabelPoint[above](C){$C$}

\tkzMarkRightAngle(A,C,B)

\tkzDrawSegment[green!60!black](A,C)
\tkzDrawSegment[green!60!black](C,B)
\tkzDrawSegment[green!60!black](B,A)

\tkzLabelSegment[auto](B,A){$c$}
\tkzLabelSegment[auto,swap](B,C){$a$}
\tkzLabelSegment[auto,swap](C,A){$b$}

\tkzDrawAltitude[dashed,color=magenta](A,B)(C)
\tkzGetPoint{D}

\tkzMarkAngle[size=1cm,color=cyan,mark=|](C,B,A)
\tkzMarkAngle[size=1cm,color=cyan,mark=|](A,C,D)
\tkzMarkAngle[size=0.75cm,color=orange,mark=||](D,C,B)
\tkzMarkAngle[size=0.75cm,color=orange,mark=||](B,A,C)
\end{tikzpicture}

\end{document}

enter image description here