Difference between revisions of "Tex sample metapost"
m (fixed bug with ifpdf.sty in amstex) |
m (Clarified use of \catcode lines) |
||
Line 55: | Line 55: | ||
Hi there: \epsfbox{file.1} | Hi there: \epsfbox{file.1} | ||
\bye | \bye | ||
− | |||
− | |||
− | |||
Then use the following commands to produce the ''pdf'' file: | Then use the following commands to produce the ''pdf'' file: | ||
mpost file | mpost file | ||
pdftex file | pdftex file | ||
− | Again, it is not necessary to run '''mpost''' if it has already been run since | + | * Again, it is not necessary to run '''mpost''' if it has already been run since '''file.mp''' was last updated. |
− | '''file.mp''' was last updated. | + | * The above file can also be used to produce a ''dvi'' file. |
+ | * The two '''\catcode''' lines are needed only for '''amstex'''. They can be omitted for plain TeX. |
Latest revision as of 11:50, 12 August 2009
Contents
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} \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
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
Notes:
- The file file.1 produced by mpost is not really a PostScript file; therefore you cannot use gv to view it.
- For the same reason, xdvi will not show file.dvi.
Creating pdf Files
If you want to create a pdf file, modify the tex file to read as follows:
\catcode`\@=11 \input ifpdf.sty \catcode`\@=\active \ifpdf \input supp-pdf \def\epsfbox#1{\hbox{\convertMPtoPDF{#1}{1}{1}}} \else \input epsf \fi Hi there: \epsfbox{file.1} \bye
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.
- The above file can also be used to produce a dvi file.
- The two \catcode lines are needed only for amstex. They can be omitted for plain TeX.