MetaPost Notes

References

The manual isn’t that long and is one of those things with a steep learning curve but high reward. The way variable names work and how to do indexing was unusual for me. The way you can express constraints as unsolved linear equations, was also unexpected and very cool.

Notes

MetaPost is installed as mpost by tetex, not mp as the manual suggests.

I do not set “Prologue:=1”. While I get output which ghostscript doesn’t understand, pdflatex/LaTeX/TeX will include it beautifully. To get a standalone eps file I use mps2eps rather than fiddling with Prologue.

To include LaTeX instead of Plain TeX code in your diagrams set the environment variable TEX to ‘latex’. Then the top of your .mp file must contain:

verbatimtex
\documentclass[12pt]{article}
% I copied the next line from somewhere -- may or may not be good for you.
%\usepackage[T1]{fontenc} % It isn't good for me.
\begin{document}
etex

I use shell scripts to sort out each document I have, including setting TEX. Setting TEX to latex in a shell’s profile forces you to include the latex header above in all .mp files, which is a pain.

gnuplot

gnuplot can produce metapost output (set term mp). Any labels you use are handled by TeX, but I found I needed to escape backslashes with a backslash, eg: $\\int dx$. I haven’t found any way to change the choice of line colours within gnuplot — so in my scripts I produce the .mp file and then hack that with patch/perl/whatever. Note that the mp driver has a tex/latex option too.

Problems with pdflatex and acroread

I have had some font problems with figures produced in metapost and included in documents created with old versions of pdflatex. They displayed on screen fine, but did not print correctly from Acrobat 5.x on linux (version 7.x worked fine). Documents created with a newer version of pdflatex never had this problem.

The problem version of pdflatex was:

pdfTeX (Web2C 7.3.3.1) 3.14159-0.14h-released-20010417

The following version did not give the problem:

pdfeTeX 3.141592-1.21a-2.2 (Web2C 7.5.4)