Drawing a triangle

The language Eukleides has been designed in order to be close to the traditionnal language of Euclidean geometry. For instance, to draw a triangle, you just have to type:

A B C triangle
draw(A, B, C)

If you save these two lines in a file, say triangle.euk, you can now try this:

$ eukleides triangle.euk

and you'll get the following output:

% Generated by eukleides *.*.*
\psset{linecolor=black, linewidth=.5pt, arrowsize=2pt 4}
\psset{unit=1.0000cm}
\pspicture*(-2.0000,-2.0000)(8.0000,6.0000)
\pspolygon(0.0000,0.0000)(6.0000,0.0000)(2.2500,3.6742)
\endpspicture

The lines above are PSTricks commands, they can be inserted verbatim in a (La)TeX source file (remember to first load the PSTricks package).

The resulting document will contain the following figure:

To see this triangle there is a shorter way: the shell script euk2eps generates a file in EPS format, which can be viewed with GhostView. Furthermore, the script euk2edit (which uses pstoedit) allows to convert the figure in a vector graphic format, like the ones used for Xfig or Sketch. For instance, in order to edit the figure with Sketch, type:

$ euk2edit triangle.euk sk

It is usually more convenient to have a single file containing both text and illustrations. This is possible with eukleides, using the -f option and the special comments %--eukleides and %--end. For instance, if you type the following lines with your favorite text editor:

\input pstricks
This is a scalene triangle:\par
%--eukleides
A B C triangle
draw(A, B, C)
%--end
\bye

and save this as triangle.etex, you can get a DVI file with:

$ eukleides -f triangle.etex > triangle.tex && tex triangle.tex

Then, you may convert this file in PostScript format and view it with:

$ dvips -o triangle.ps triangle && gv triangle.ps


Go to: Tutorial index Next page Concept index Command index