Take the 2-minute tour ×

When I was more active in LaTeX and Metapost (~10 years ago) I could not find a way to directly use Metapost in LaTeX. There were few tutorials on how to use it within ConTeXt, but for using it with LaTeX you had to make the .mp file separate, compile it into .ps or .pdf and then add the .ps (for latex → dvi → ps) or .pdf (for pdflatex → pdf) using the graphix package.

I am currently seeing many questions related to TikZ, and most examples use TikZ within LaTeX.

So. Are there current tools to use the Metapost language within LaTeX without using a separate source and a separate compilation?

share|improve this question
With LuaLaTeX using the mplib –  morbusg Nov 6 '13 at 14:08
The gmp package? –  egreg Nov 6 '13 at 14:16
If you want one way communication (MP figures appear in PDF), then either gmp and luamplib packages should work. As far as I know, no LaTeX package provides two way communication as in ConTeXt (context passes the dimensions of a box to MP, and MP draws a frame/background around it; context typesets the labels (using current font settings) and passes the dimension of the labels to metapost, which then places the labels as required, etc). With luatex, ConTeXt also provides separate instances of metapost for different types of graphics; but that feature is not available with luamplib. –  Aditya Nov 6 '13 at 14:39

1 Answer 1

There are three packages that provide “direct” integration of Metapost in LaTeX

  1. mpgraphics

  2. gmp (disclaimer: I'm its author)

  3. luamplib

The first two work with all LaTeX engines (pdflatex, XeLaTeX and LuaLaTeX) and require enabling --shell-escape (but generated Metapost files can be run separately with gmp that provides a basic shell script in case the option is not active).

The third package works only with LuaLaTeX and its last versions allow passing TeX side dimensions to the Metapost source.

share|improve this answer
Indeed, luamplib works only with LuaLaTeX, and in PDF mode. It won't work at all with dviLuaLaTeX. Another of its features is the fact it also allows the use of the textext function for label inclusion, much more handy than the classical btex…etex. –  fpast Mar 1 at 22:20

Your Answer


