MetaPost Notes


Reading the manual is, as always, recommended. Some parts of the language were unusual for me: the way variable names work, how to do indexing and expressing constraints as unsolved linear equations.


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:

% I copied the next line from somewhere -- may or may not be good for you.
%\usepackage[T1]{fontenc} % It isn't good for me.

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 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.