3

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.

user143462
  • 1,039
  • 4
    I searched for triangle and this was the second one http://tex.stackexchange.com/questions/156450/triangle-with-text then I added right angle http://tex.stackexchange.com/questions/175501/how-to-add-length-and-right-angle-to-triangle. See we are not asking much, so please just provide a MWE and people would take care of the rest. – percusse Jul 30 '14 at 00:17
  • So it would even be more convenient for potential helpers for them to do all of the work from scratch for you?! As percusse says, an MWE is pretty easy to find, even if you are either unable or unwilling to produce one yourself, but... !! Sorry, but this question really takes the biscuit! (Apologies to those speakers of other languages or dialects to whom this means nothing but I can't think of an equivalent which would not be impolite right now.) – cfr Jul 30 '14 at 00:58
  • What is "MWE"? I have just started using TikZ. The syntax for coding in TikZ is much different than that of LaTeX, and the manuals for TikZ are not of much help. (Don't be cynical, @cfr.) – user143462 Jul 30 '14 at 17:38
  • Information about producing a minimal working example (MWE) that illustrates your problem. Given your comments on Gonzalo Medina's answer, I think cynicism wholly justified. The manual for TikZ is exemplary. If nothing else, you can cut and paste some code as a starting point. There are numerous examples on this site and percusse even did your searching for you. There are further examples in the online gallery and so on and so forth. – cfr Jul 30 '14 at 20:59
  • It would be nice if your comments were of any help. You say that the manual for TikZ " is exemplary." Show me in the manual where it gives the code for marking angles with "|" or with "||". – user143462 Jul 30 '14 at 22:55
  • You are not asking for the markings you are asking for the whole code without putting a 4 line example of a triangle. So I guess you can read my comment a little more constructively instead of coming back with another detail – percusse Jul 31 '14 at 14:48
  • My last comment was not intended for you, @percusse. What is "4 line example of a triangle"? If you wanted me to at least give the code for TikZ to draw a triangle, I was confident that the person providing the code would have to discard most of it. I reckoned that it would take more time for this person to decide what to keep rather than just enter the code that he/she wanted. Look at the code that Gonzalo provided. I had not heard of the command "\tkzGetPoint{B}". If I had labeled the vertices, after the edits, he/she may have found that my positions for them were no longer appropriate. – user143462 Jul 31 '14 at 22:55
  • Believe or not the most boring part is setting up the problem with documentclass and begind{document} etc, each time you need to try a simple thing. And it puts off many people if you don't even give a simple triangle construction which is three nodes and one \draw command finishing with --cycle. That's what I meant. – percusse Jul 31 '14 at 23:25
  • I understand. I appreciate your patience ... and your codes. – user143462 Aug 01 '14 at 12:10

1 Answers1

8

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

Gonzalo Medina
  • 505,128
  • Nice pictures! I would like to make the following edits. I would like to have the right angle mark at C, I would like to replace the "alpha" with a "|" through the arc indicating the measure of angle CAB and angle BC(perp), and I would like to replace the "beta" with a "||" through the arc indicating the measure of the angle ABC and angle AC(perp). (I would also change the radius of angles marked "|" to 0.75cm and I would keep the angles marked "||" to 1cm.) Can you provide the code for these edits? – user143462 Jul 30 '14 at 19:06
  • @user143462 Sure. Please see my updated answer. – Gonzalo Medina Jul 31 '14 at 14:44