from Wikipedia, the free encyclopedia

MetaPost logo
Basic data

Maintainer Taco Hoekwater
developer John D. Hobby
Publishing year 1994
Current  version 1,212
(October 18, 2010)
Current preliminary version 1,902
(April 23, 2014)
operating system Cross-platform
programming language C.
category Pleading
License LGPL

MetaPost is on the one hand a programming language and on the other hand the only known interpreter for it. Both are derived from Donald E. Knuth's Metafont language and interpreter. MetaPost can generate diagrams in PostScript or as SVG vector graphics from a geometric / algebraic description. The language has the same syntax as Metafont to create lines, curves, points and geometric transformations.

Comparison of Metafont and MetaPost

  • Metafont was created for the production of fonts with the associated Fontmetric files. MetaPost, on the other hand, creates PostScript files.
  • The output from Metafont consists of fonts at a certain resolution in a raster-based format. MetaPost creates vector-based graphics.
  • In contrast to the monochrome versions of Metafont, MetaPost uses a simple RGB scheme.
  • MetaPost can also attach labels to diagrams. These can be texts from a specified font or simply anything that can be set with TeX .
  • The Metafont interpreter was developed by Knuth under an open source license. This allowed John D. Hobby to adapt the interpreter for his use, thus creating MetaPost.


MetaPost is supplied with many distributions from TeX and Metafont. The output of MetaPost can easily be used in TeX, ConTeXt , and LaTeX documents via standard commands.


This is a single file example.mpthat creates three EPS files. The command must be mpost DATEINAMEcalled to edit the input file .

Metapost ex.png
transform pagecoords;
pagecoords:=identity scaled 10mm shifted (100mm,150mm);

    fill ((0,0)--(2,0)--(2,1)--(1,1)--(1,2)--(0,2)--cycle)
        transformed pagecoords withcolor green;
    draw ((2,0)..(2,1)..(1,1)..(1,2)..(0,2))
        transformed pagecoords;
    drawarrow ((0,0)--(2,2)) transformed pagecoords;

    draw (for i=0 upto 7: dir(135i)-- endfor cycle)
        transformed pagecoords;

pagecoords:=identity scaled 15mm shifted (100mm,150mm);
    % declare paths to be used
    path p[],p[]t;
    % set up points by defining relationships
    z1=(0,0);   z2=z1+2up;
    % set up paths
    p0=fullcircle yscaled .5 rotated 45 shifted z0 ;
    p2=p1 cutbefore p0 cutafter p0;
    p3=p0 cutbefore p1 cutafter p1;
    % define transformed versions of paths and points
    for i=0 upto 4: p[i]t=p[i] transformed pagecoords; endfor
    for i=0 upto 5: z[i]t=z[i] transformed pagecoords; endfor
    % do some drawing
    fill p4t withcolor (1,1,0.2);
    draw z1t--z2t withcolor .5white;
    draw z3t--z4t withcolor .5white;
    pickup pencircle;
    draw p0t dashed withdots scaled .3;
    draw p1t dashed evenly;
    draw p2t withcolor blue;
    draw p3t withcolor red;
    label.lrt(btex $z_0$ etex, z0t);
    label.llft(btex $z_1$ etex, z1t); $z_2$ etex, z2t);
    label.rt(btex $z_3$ etex, z3t);
    label.llft(btex $z_4$ etex, z4t);
    for i=0 upto 4:
        drawdot z[i]t withpen pencircle scaled 2;


Web links