# Help drawing a more sophisticated right triangle with tikz or something else

I am preparing a geometry note file for my students and I am trying to reproduce a figure I saw on Wikipedia in the proof of the Pythagorean theorem. Here is the figure I can draw a right triangle with tikz after some trial and error, but I do not know how to color the interiors of the shapes, label the vertices, label the angles as nicely as shown in the figure below, drop a perpendicular, and mark the angles with arcs or a square for a right angle as in H and C vertices. I am a math teacher by profession and my computer and TeX proficiency are minimal. I would certainly appreciate any help with this. My aim is to create my own figures so as not to plagiarize. I thank all helpers.

Edit: here is my code for a right triangle

\begin{tikzpicture}[scale=1.25]

\coordinate (A) at (-1.5cm,-1.cm);
\coordinate (C) at (1.5cm,-1.0cm);
\coordinate (B) at (1.5cm,1.0cm);
\draw (A) --  (B) --  (C) -- (A);

\end{tikzpicture}

• Welcome to TeX.SE. Could you post the code for your right triangle? That would give us something to start from. Aug 3, 2021 at 20:40
• You might want to try geogebra classic, it can export tikz code
– DG'
Aug 3, 2021 at 20:45
• @Teepeemm thank you for your suggestion, I have added my code Aug 3, 2021 at 20:48
• Since the two interior triangles are similar (to each other and the outer triangle) it would help to use easily rotated triangles, like 3-4-5 or 30-60-90 (1-2-\sqrt{3}). Aug 3, 2021 at 20:53
• You seem to be working your way through proofs of Pythagoras' theorem. Let me know when you get to the correct one, and I can provide the code for it as seen in loopspace.mathforge.org/CountingOnMyFingers/FavouriteProof Aug 3, 2021 at 20:56

I propose this solution with the pst-eucl module of pstricks, which can mimick constructions of plane geometry:

\documentclass[border=6pt]{standalone}
\usepackage[x11names,svgnames]{xcolor}%
\usepackage{pst-eucl}

\begin{document}

\begin{pspicture}(-1,-1)(7,5)
\psset{PointSymbol=none, linejoin=1,CodeFigStyle=solid, CodeFigColor=black}
\pstTriangle[PosAngle={120,-130,-30}](0,4){A}(0,0){C}(6,0){B}
\pstProjection[CodeFig]{B}{A}{C}[H]\psline(C)(H)
\pspolygon*[linecolor=LightSteelBlue2!90](B)(H)(C)
\pspolygon*[linecolor=YellowGreen!30](C)(H)(A)
\psset{linewidth=0.6pt}
\psline(H)(A)(C)(H)(B)(C)
\pstMarkAngle{H}{C}{A}{$\theta$} \pstMarkAngle{B}{C}{H}{}\pstMarkAngle{B}{C}{H}{}
\pstMarkAngle{H}{B}{C}{$\theta$}
\pstMarkAngle{C}{A}{H}{}
\pstMarkAngle{B}{C}{H}{}
\pstMarkAngle{C}{A}{H}{}
\pstRightAngle{B}{C}{A} \pstRightAngle{C}{H}{A}
\end{pspicture}

\end{document} • thank you so much. Small question if I may ask. How would I also mark the HCB angle with 90-\theta for maximum clarity? Aug 3, 2021 at 23:40
• You may, of course: we're here to help. Actually, it is already marked with the smaller \MarkAngleRadius (I copied your posted image with the pstricks tools). But if you think the larger is confusional, you may use colour the markings for this angle and for the corresponding angle CAH, for instance. Or colour the theta angles. To colour the angles, e.g. in red, use\pstMarkAngle[linecolor=red]{…}. Aug 4, 2021 at 9:16
• thank you so kindly, after reading and learning your code, I copied it into my document and it is giving several errors. It does not seem to be recognizing anything in the pspicture environment. I loaded the two packages in the order you gave, in addition to my other used packages. Could you please advise? Thank you. Aug 4, 2021 at 17:51
• @kroner: Which compiler did you use? Aug 4, 2021 at 18:13
• That doesn't tell how you compiled. The simplest is to use xelatex with the --shell-escape switch Aug 4, 2021 at 18:18

With the help of quotes and angles libraries, it's not difficult to get it.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{calc, angles, quotes, backgrounds}

\begin{document}
\begin{tikzpicture}

\draw (0,0) node[below left] {$C$} coordinate (C) -- (0,3) node[above left] {$A$} coordinate (A) -- (5,0) node[below right] {$B$} coordinate (B)--cycle;
\draw (C)--($(A)!(C)!(B)$) coordinate (H) node[above right]{$H$};

\begin{scope}[on background layer]
\fill[blue!30] (B)--(C)--(H)--cycle;
\fill[green!30] (A)--(C)--(H)--cycle;
\end{scope}

\draw pic[draw] {angle=C--A--H} pic[draw, angle radius=4mm] {angle=C--A--H};
\draw pic["$\theta$",draw, angle radius=7mm, angle eccentricity=.8] {angle=H--B--C};
\draw pic["$\theta$",draw, angle radius=8mm, angle eccentricity=.8] {angle=H--C--A};

\draw pic[draw, angle radius=3mm] {right angle=B--C--A};
\draw pic[draw, angle radius=3mm] {right angle=C--H--A};

\end{tikzpicture}
\end{document} This uses a 3-4-5 triangle.

\documentclass[tikz]{standalone}
\usetikzlibrary{calc,angles}

\begin{document}
\begin{tikzpicture}[scale=1]
\coordinate (A) at (0,0);
\coordinate (C) at (0,3);
\coordinate (B) at (4,0);
\coordinate (D) at ($(C)!{9/25}!(B)$);% see derivation below
\draw (A) -- (B) -- (C) -- cycle;
\draw (A) -- (D);
\path pic [draw,angle radius=2mm] {right angle = C--A--B}
pic [draw,angle radius=2mm] {right angle = A--D--B};
\fill[red, opacity=0.5] (A) -- (B) -- (D);
\fill[blue, opacity=0.5] (A) -- (C) -- (D);
\node[below left] at (A) {A};
\node[below right] at (B) {B};
\node[above left] at (C) {C};
\node[above right] at (D) {D};
\end{tikzpicture}
\end{document}  