## LaTeX forum ⇒ Graphics, Figures & Tables ⇒ Drawing similar right triangles

Information and discussion about graphics, figures & tables in LaTeX documents.
Posts: 42
Joined: Fri Oct 17, 2008 5:55 pm

### Drawing similar right triangles

I am trying to recreate the following picture triangle.gif (1.28 KiB) Viewed 9861 times

I have been able to use the TikZ package to create something similar. However with how powerful the package is I am having trouble sorting through the documentation to find out how to do simple things. The hardest part i am finding is getting the label to show the length of each segment, especially when it stretches over several "parts", also an easy way to show the right angle symbol.
\begin{tikzpicture}\draw (0,0) node[anchor=north east]{A}-- (1,3)node[anchor=south]{B} -- (10,0)node[anchor=north]{C}-- (0,0);\draw (1,3)--(1,0)node[anchor=north]{D};\end{tikzpicture}

Edit by localghost: Preferably no external links (see Board Rules). Attachments go onto the forum server where possible.
Last edited by Mikerada6 on Wed Feb 09, 2011 2:21 pm, edited 1 time in total.

Frits
Posts: 169
Joined: Wed Feb 02, 2011 6:02 pm
Is it necessarily that you use TikZ? If not, Here is an alternative to create images for LaTeX purposes, which I prefer over TikZ.
howtoTeX.com - Your LaTeX resource site (Tips, Tricks, Templates and more!)

Posts: 140
Joined: Thu Jul 16, 2009 12:39 am
You can use the tkz-2d package with TikZ to draw the right angles. Here's an example, using the coordinates in your code snippet:

\documentclass{article}\usepackage{tikz,tkz-2d}\begin{document}\begin{tikzpicture}  \coordinate[label=below left:$A$] (A) at (0,0);  \coordinate[label=below right:$B$] (B) at (10,0);  \coordinate[label=above:$C$] (C) at (1,3);  \coordinate[label=below:$D$] (D) at (1,0);  \draw (A) -- (C) -- (B) -- cycle;  \draw (C) -- (D) node[right,midway] {$m$};  \draw[latex-latex,shift={(0,-0.6)}] (1,0) -- (10,0) node[below,midway] {$a$ units};  \draw[latex-latex,shift={(0,-1.2)}] (0,0) -- (10,0) node[below,midway] {$b$ units};  \tkzRightAngle (A/C/B, C/D/B);\end{tikzpicture}\end{document}

Here's a pic of what it looks like:
Attachments tikztest2.png (3.27 KiB) Viewed 9847 times
System: TeX Live 2012, Fedora 18 x86_64, GNU Emacs 24.2

Posts: 42
Joined: Fri Oct 17, 2008 5:55 pm
thank you very much. that simple example will help me create many of the figures I need to create my geometry lesson plans. Thank you again.

Posts: 42
Joined: Fri Oct 17, 2008 5:55 pm
I am having trouble installing the TKZ-2d package. I am running Windows and TexNicCenter

The documentation is confusing and I am not aware what "sudo texhash" means on a windows machine. To my knowledge that is a Linux command

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am
It's not Linux specific, but sudo is Unix-specific and texhash TeXlive specific. The equivalent for MikTeX would be refreshing the file name database(FNDB) in the MikTeX package manager.

localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm
Mikerada6 wrote:I am having trouble installing the TKZ-2d package. I am running Windows and TexNicCenter […]

The »tkz-2d« package is superseded by the tkz-euclide package. So you should find this with the package manager. And the syntax for the right angle symbol has slightly changed. Unfortunately there's only a French version of the manual at the moment.

Thorsten
LaTeX Community Moderator

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

Montag
Posts: 340
Joined: Wed Jul 15, 2009 9:25 am
frabjous wrote:It's not Linux specific, but sudo is Unix-specific and texhash TeXlive specific. The equivalent for MikTeX would be refreshing the file name database(FNDB) in the MikTeX package manager.

And if you also like to use the command line tool for maintaining MikTeX, take a look here.
OS: Win 7 64-bit LaTeX: MikTeX 2.9 64-bit Editor: TXC 1 RC1

Posts: 140
Joined: Thu Jul 16, 2009 12:39 am
If you want to use tkz-euclide instead of tkz-2d, you need TikZ 2.10 installed. Also, make sure you remove the tkz-2d package then update the filename database, or you may encounter problems with conflicting tkz-base.sty files. Using tkz-euclide, the code looks like this:
\documentclass{article}\usepackage{tkz-euclide}\usetkzobj{all}\begin{document}\begin{tikzpicture}  \coordinate[label=below left:$A$] (A) at (0,0);  \coordinate[label=below right:$B$] (B) at (10,0);  \coordinate[label=above:$C$] (C) at (1,3);  \coordinate[label=below:$D$] (D) at (1,0);  \draw (A) -- (C) -- (B) -- cycle;  \draw (C) -- (D) node[right,midway] {$m$};  \draw[latex-latex,shift={(0,-0.6)}] (1,0) -- (10,0) node[below,midway] {$a$ units};  \draw[latex-latex,shift={(0,-1.2)}] (0,0) -- (10,0) node[below,midway] {$b$ units};  \tkzMarkRightAngle (A,C,B);  \tkzMarkRightAngle (C,D,B);\end{tikzpicture}\end{document}

Note that tkz-euclide automatically loads tikz.
System: TeX Live 2012, Fedora 18 x86_64, GNU Emacs 24.2