A Quick MetaPost Example

This document gives a quick example of how to use MetaPost for graphics in plain TeX or AmSTeX. The files given here are written in plain TeX; the same methods work in AmSTeX.

The Files

First of all, here are the contents of file.tex:

\input epsf
Hi there:  \epsfbox{file.1}

And, here is the MetaPost file file.mp. It contains an arrow and the letter "A" just above the middle of the arrow.



label.ulft(btex $A$ etex, .5[z1,z2]);



Creating and Viewing dvi Files

To create a dvi file, use the following commands. You don't need to run mpost a second time if you just update the tex file.

mpost file
tex file

To view the dvi file, use the commands:

dvips -o file.ps file
gv file.ps


Creating pdf Files

If you want to create a pdf file, modify the tex file to read as follows:

\input ifpdf.sty

  \input supp-pdf
  \input epsf

Hi there:  \epsfbox{file.1}

(You may also use this version of the file to produce a dvi file.)

Then use the following commands to produce the pdf file:

mpost file
pdftex file

Again, it is not necessary to run mpost if it has already been run since file.mp was last updated.

Last updated 31 May 2010