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.
First of all, here are the contents of file.tex:
\input epsf Hi there: \epsfbox{file.1} \bye
And, here is the MetaPost file file.mp. It contains an arrow and the letter "A" just above the middle of the arrow.
beginfig(1); z1=(0,0); z2=(10mm,10mm); drawarrow(z1--z2); label.ulft(btex $A$ etex, .5[z1,z2]); endfig; bye
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
Notes:
If you want to create a pdf file, modify the tex file to read as follows:
\input ifpdf.sty \ifpdf \input supp-pdf \def\epsfbox#1{\hbox{\convertMPtoPDF{#1}{1}{1}}} \else \input epsf \fi Hi there: \epsfbox{file.1} \bye
(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