Download Learning mEtapost by Doing
Transcript
1 Introduction TEX is the well-known typographic programming language that allows its users to produce high-quality typesetting especially for mathematical text. METAPOST is the graphic companion of TEX. It is a graphic programming language developed by John Hobby that allows its user to produce high-quality graphics. It is based on Donald Knuth’s METAFONT, but with PostScript output and facilities for including typeset text. This course is only meant as a short, hands-on introduction to METAPOST for newcomers who want to produce rather simple graphics. The main objective is to get students started with METAPOST on a UNIX platform1 . A more thorough, but also much longer introduction is the Metafun manual of Hans Hagen [Hag02]. For complete descriptions we refer to the METAPOST Manual and the Introduction to METAPOST of its creator John Hobby [Hob92a, Hob92b]. We have followed a few didactical guidelines in writing the course. Learning is best done from examples, learning is done from practice. The examples are often formatted in two columns, as follows:2 beginfig(1); draw unitsquare scaled 1cm; endfig; The exercises give you the opportunity to practice METAPOST, instead of only reading about the program. Compare your answers with the ones in the section ‘Solutions to the Exercises’. 2 A Simple Example METAPOST is not a WYSIWYG drawing tool like xfig or xpaint. It is a graphic document preparation system. First, you write a plain text containing graphic formatting commands into a file by means of your favorite editor. Next, the METAPOST program converts this text into a PostScript document that you can preview and print. In this section we shall describe the basics of this process. 2.1 Running METAPOST EXERCISE 1 Do the following steps: 1. Create a text file, say example.mp, that contains the following METAPOST statements: beginfig(1); draw (0,0)--(10,0)--(10,10)--(0,10)--(0,0); endfig; end; Figure 1: A Simple METAPOST document. 1 2 You can also run METAPOST on a windows platform, e.g., using MikTEXand the WinEdt shell. On the left is printed the graphic result of the METAPOST code on the right. Here, a square is drawn. 3