LaTeX forum ⇒ Graphics, Figures & TablesDrawing similar right triangles

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

Drawing similar right triangles

Postby Mikerada6 » Tue Feb 08, 2011 12:05 am

I am trying to recreate the following picture
triangle.gif
triangle.gif (1.28 KiB) Viewed 5447 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.
  1. \begin{tikzpicture}
  2. \draw (0,0) node[anchor=north east]{A}-- (1,3)node[anchor=south]{B} -- (10,0)node[anchor=north]{C}-- (0,0);
  3. \draw (1,3)--(1,0)node[anchor=north]{D};
  4. \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.

Link:
BBcode:
HTML:
Hide post links
Show post links

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

Postby Frits » Tue Feb 08, 2011 7:00 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!)
Follow howtoTeX on twitter

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
shadgrind
Posts: 140
Joined: Thu Jul 16, 2009 12:39 am

Postby shadgrind » Wed Feb 09, 2011 11:18 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:

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


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

Link:
BBcode:
HTML:
Hide post links
Show post links

Mikerada6
Posts: 42
Joined: Fri Oct 17, 2008 5:55 pm

Postby Mikerada6 » Wed Feb 09, 2011 2:21 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.

Link:
BBcode:
HTML:
Hide post links
Show post links

Mikerada6
Posts: 42
Joined: Fri Oct 17, 2008 5:55 pm

Postby Mikerada6 » Thu Feb 10, 2011 12:14 am

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

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am
Location: Amherst, MA

Postby frabjous » Thu Feb 10, 2011 1:41 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.

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
localghost
Site Moderator
Posts: 9206
Joined: Fri Feb 02, 2007 12:06 pm
Location: Braunschweig, Germany

Postby localghost » Thu Feb 10, 2011 10:16 am

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
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ System: openSUSE 13.1 (Linux 3.11.10), TeX Live 2013 (vanilla), TeXworks 0.5 (r1351)
² Posting stopped indefinitely due to offenses

Link:
BBcode:
HTML:
Hide post links
Show post links

Montag
Posts: 340
Joined: Wed Jul 15, 2009 9:25 am

Postby Montag » Thu Feb 10, 2011 10:58 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

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
shadgrind
Posts: 140
Joined: Thu Jul 16, 2009 12:39 am

Postby shadgrind » Fri Feb 11, 2011 11:14 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:
  1. \documentclass{article}
  2. \usepackage{tkz-euclide}
  3. \usetkzobj{all}
  4. \begin{document}
  5. \begin{tikzpicture}
  6. \coordinate[label=below left:$A$] (A) at (0,0);
  7. \coordinate[label=below right:$B$] (B) at (10,0);
  8. \coordinate[label=above:$C$] (C) at (1,3);
  9. \coordinate[label=below:$D$] (D) at (1,0);
  10. \draw (A) -- (C) -- (B) -- cycle;
  11. \draw (C) -- (D) node[right,midway] {$m$};
  12. \draw[latex-latex,shift={(0,-0.6)}] (1,0) -- (10,0) node[below,midway] {$a$ units};
  13. \draw[latex-latex,shift={(0,-1.2)}] (0,0) -- (10,0) node[below,midway] {$b$ units};
  14. \tkzMarkRightAngle (A,C,B);
  15. \tkzMarkRightAngle (C,D,B);
  16. \end{tikzpicture}
  17. \end{document}

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

Link:
BBcode:
HTML:
Hide post links
Show post links


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 7 guests