# Is there an easy way to TeX geometric pictures?

Say I want to include geometry graphics such as the following in a document:

I don't merely want to import preexisting figures, I want to be able to draw my own corresponding to a solution I may write up. Is there a package or something that allows one to do this relatively easily?

tkz-euclide arrives on the ctan servers. You can get it with ftp from dante.de

ftp://ftp.dante.de:21//pub/tex/macros/latex/contrib/tkz you need to install tkz-base and tkz-euclide. These packages work only with pgf 2.1

\documentclass{article}
\usepackage[upright]{fourier}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{tkz-euclide}
\usetkzobj{all}
\definecolor{fondpaille}{cmyk}{0,0,0.1,0}
\pagecolor{fondpaille}
\color{Maroon}
\tkzSetUpColors[background=fondpaille,text=Maroon]
\thispagestyle{empty}

\begin{document}

\begin{tikzpicture}
\tkzDefPoint(0,0){A}\tkzDefPoint(6,0){B}
\tkzDefPoint(6,4){C}\tkzDefPoint(0,4){D}
\tkzInterLL(A,C)(B,D)  \tkzGetPoint{I}

\tkzDrawPolygon (A,B,C,D)
\tkzDrawSegments(A,C B,D)
\tkzMarkRightAngles[fill=Maroon!20,size=.3,opacity=.5](D,A,B A,B,C B,C,D C,D,A)
\tkzDrawPoints(A,B,C,D,I)

\tkzMarkSegments[mark=s||](I,A I,B I,C I,D)
\tkzLabelPoints(A,B) \tkzLabelPoints[above=6pt](I)
\tkzLabelPoints[above right](C,D)
\end{tikzpicture}
\end{document}


Best regards

Alain Matthes (author of tkz-euclide) There are a lot of examples on my site altermundus.fr

• @Alain the user manual is a work of art! Thanks! – Yiannis Lazarides Jan 26 '11 at 16:02

Run it with xelatex

\documentclass{minimal}
\usepackage{pst-eucl}
\begin{document}

\begin{pspicture}(8,5)
\pstGeonode[PosAngle={180,0,0,180}](0,0){A}(6,0){B}(6,4){C}(0,4){D}
\pspolygon[fillstyle=solid,fillcolor=blue!20](A)(B)(C)(D)
\pstInterLL[PointSymbol=square]{A}{C}{B}{D}{E}
\pstSegmentMark{A}{E}\pstSegmentMark{C}{E}
\pstSegmentMark[MarkAngle=-65]{B}{E}\pstSegmentMark[MarkAngle=-65]{D}{E}
\pstRightAngle{C}{B}{A}\pstRightAngle{B}{A}{D}
\pstRightAngle[RightAngleType=german]{D}{C}{B}\pstRightAngle{C}{D}{A}
\end{pspicture}

\end{document}


• Thanks Herbert, this seems like a easy thing to implement. May I ask what PosAngle={180,0,0,180}] means? What do the arguments specify? Why is it not PosAngle={90,90,90,90}]? – yunone Jan 25 '11 at 19:43
• @yunone: makes the setting of the labels easier. It is the angle where the A,B,C,and D are printed. With all set to 90 you'll get the A and B half inside the frame. A -90 -90 90 90 would make sense – user2478 Jan 25 '11 at 19:50
• Instructions for LyX users: 1. Download and install pst-eucl from here: ctan.org/tex-archive/graphics/pstricks/contrib/pst-eucl . 2. go to Document->Settings->Document Preamble, insert "\usepackage{pst-eucl}". 3. Click Ctrl+L, add the tex code from "\begin{pspicture}(8,5)" to "\end{pspicture}". 4. Click Ctrl+T to convert to PS. You should see a nice rectangle. – Erel Segal-Halevi Jul 5 '13 at 6:14

There are at least two packages that I know of, one based on pstricks: the pst-eucl package (which should be part of your TeX distribution) and one based on TikZ: the tkz-euclide package available here: tkz-euclide (or on CTAN). Unfortunately for the latter, the documentation is only in French, but there are plenty of examples so this may not be too much of a problem.

• Thanks for the answer, Alan. I'm not too familiar with pstricks. Can I simply say \usepackage{pst-eucl} in my preamble after installing it, or do I have to do something with pstricks first? – yunone Jan 25 '11 at 5:41
• @yunone For some of the examples in the documentation you may have to load the pst-plot package. But the simple examples should work just with loading pst-eucl. You need to compile your documents with latex+dvips instead of pdflatex. – Alan Munn Jan 25 '11 at 6:07
• @yunone: Yes, \usepackage{pst-eucl} is ok, then you can run xelatex to get a pdf, which should be available on all TeX distributions. alternatively run pdflatex -shell-escape <file> with \usepackage{auto-pst-pdf}. There is no need for running latex+dvips – user2478 Jan 25 '11 at 7:43

Geogebra and asymptote are further tools which could be used in this regard.

• It's worth pointing out that GeoGebra exports TikZ code. – Matthew Leingang May 3 '11 at 17:17
• It's also worth pointing out that GeoGebra exports PSTricks codes. – xport Jun 3 '11 at 9:53
• It's also worth pointing out that GeoGebra exports Asymptote codes. – g.kov Apr 17 '19 at 15:42