Latex sample metapost

From UCB Math Wiki
Revision as of 13:29, 6 May 2013 by Vojta (talk | contribs) (Change "filenametemplate" to the current "outputtemplate")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

A Quick MetaPost Example

This document gives a quick example of how to use MetaPost for graphics in LaTeX.

The Files

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

Hi there:  \includegraphics{file1.mps}

And, here is the MetaPost file 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
latex file

To view the dvi file, use the commands:

dvips -o file


  • The file file1.mps 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, just use the following commands:

mpost file
pdflatex file

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