Graphics, Figures & TablesDrawing similar right triangles

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

Drawing similar right triangles

Post by Mikerada6 »

I am trying to recreate the following picture
triangle.gif
triangle.gif (1.28 KiB) Viewed 15631 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.

Code: Select all

\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.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Frits
Posts: 169
Joined: Wed Feb 02, 2011 6:02 pm

Drawing similar right triangles

Post by Frits »

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!)
Follow howtoTeX on twitter
User avatar
shadgrind
Posts: 140
Joined: Thu Jul 16, 2009 12:39 am

Drawing similar right triangles

Post by shadgrind »

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:

Code: Select all

\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
tikztest2.png (3.27 KiB) Viewed 15617 times
System: TeX Live 2012, Fedora 18 x86_64, GNU Emacs 24.2
Mikerada6
Posts: 42
Joined: Fri Oct 17, 2008 5:55 pm

Re: Drawing similar right triangles

Post by Mikerada6 »

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.
Mikerada6
Posts: 42
Joined: Fri Oct 17, 2008 5:55 pm

Re: Drawing similar right triangles

Post by Mikerada6 »

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
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Re: Drawing similar right triangles

Post by frabjous »

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.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Drawing similar right triangles

Post by localghost »

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
Montag
Posts: 340
Joined: Wed Jul 15, 2009 9:25 am

Drawing similar right triangles

Post by Montag »

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
User avatar
shadgrind
Posts: 140
Joined: Thu Jul 16, 2009 12:39 am

Drawing similar right triangles

Post by shadgrind »

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:

Code: Select all

\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
Post Reply