Download Learning METAPOST by Doing

Transcript
Learning MetaPost by doing
VOORJAAR 2005
%!PS
%%BoundingBox: -1 -1 11 11
%%Creator: MetaPost
%%CreationDate: 2003.05.11:2203
%%Pages: 1
%%EndProlog
%%Page: 1 1
0 0.5 dtransform truncate idtransform setlinewidth pop [] 0 setdash
1 setlinecap 1 setlinejoin 10 setmiterlimit
newpath 0 0 moveto
10 0 lineto
10 10 lineto
0 10 lineto
0 10 lineto
0 0 lineto stroke
showpage
%%EOF
4. Preview the PostScript document on your computer screen, e.g., by typing:
gs example.1
You will notice that gs does not use the picture’s bounding box; alternatively, try
ggv instead of gs, or:
5. Convert the PostScript document into a printable PDF-document:
epstopdf example.1
It creates the file example.pdf that you can you can view on the computer screen
with the Adobe Acrobat Reader by entering the command:
acroread example.pdf
You can print this file in the usual way. The picture should look like the following
small square:
Using the Generated PostScript in a LaTEX Document
EXERCISE 2
Do the following steps:
1. Create a file, say sample.tex, that contains the following lines of LaTEX commands that will include the image:
\documentclass{article}
\usepackage{graphicx}
\DeclareGraphicsRule{*}{mps}{*}{}
\begin{document}
\includegraphics{example.1}
\end{document}
Above, we use the extended graphicx package for including the external graphic
file that was prepared by METAPOST. The DeclareGraphicsRule statement
causes all file extensions that are not associated with a well-known graphic format
to be treated as Encapsulated PostScript files.
2. Typeset the LaTEX-file:
3