World Library  
Flag as Inappropriate
Email this Article


Paradigm imperative, typesetting
Designed by John D. Hobby
Developer Taco Hoekwater
First appeared 1994 (1994)
Stable release 1.212 / 19 October 2010 (2010-10-19)
Preview release 1.750 / 27 April 2011 (2011-04-27)
Typing discipline duck, dynamic, strong
OS Cross-platform
License LGPL
Website //metapost/
Influenced by

MetaPost refers to both a programming language and the interpreter of the MetaPost programming language. Both are derived from Donald Knuth's Metafont language and interpreter. MetaPost excels at producing diagrams in the PostScript programming language from a geometric/algebraic description. The language shares Metafont's elegant declarative syntax for manipulating lines, curves, points and geometric transformations. However,

  • Metafont is set up to produce fonts, in the form of image files (in .gf format) with associated font metric files (in .tfm format), whereas MetaPost produces encapsulated PostScript files
  • The output of Metafont consists of the fonts at a fixed resolution in a raster-based format, whereas MetaPost's output is vector-based postscript graphics (lines, Bézier curves)
  • Metafont output is monochrome, whereas MetaPost uses a simple RGB colour specification.
  • The MetaPost language can include text labels on the diagrams, either strings from a specified font, or pretty much anything that can be typeset with TeX
  • The Metafont interpreter was written by Donald Knuth under an open source license, allowing John D. Hobby to adapt the interpreter to his own ends, giving us MetaPost.

Many of the limitations of MetaPost derive from features of Metafont. For instance, numbers have a low-precision fixed-point representation, sufficient for representing the coordinates of points in a glyph, but this can be restrictive when working with figures in a larger coordinate space. Moreover, MetaPost does not support all features of PostScript. Most notably, paths can have only one segment (so that regions are simply connected), and regions can be filled only with uniform colours. PostScript level 1 supports tiled patterns and PostScript 3 supports Gouraud shading. To this end, the Asymptote graphics language has been developed to address these shortcomings.


  • Availability, usage 1
  • Examples 2
  • See also 3
  • References 4
  • External links 5

Availability, usage

MetaPost is distributed with many current distributions of the TeX and Metafont framework. In particular, it is included in the teTeX and the TeX Live distribution, common on Linux and Unix (including Mac OS X) platforms.

The encapsulated postscript produced by Metapost is easily included in TeX, ConTeXt, and LaTeX documents via standard eps-inclusion commands. Particularly useful is the ability to include this output in the PDFTeX dialect of TeX, thus giving Portable Document Format output from TeX in a single step. This ability is implemented in ConTeXt and in the LaTeX graphics package, and can be used from plain TeX via the supp-pdf.tex macro file. ConTeXt even supports the creation of MetaPost files from within the TeX file.

Although MetaPost itself cannot generate fonts, there is another program, METATYPE1, that is designed to create Type 1 fonts through MetaPost.


This is a single file which when processed by the MetaPost interpreter (via the command mpost on Linux) produces three eps files example.1, example.2, example.3. These are pictured on the right.

transform pagecoords;
pagecoords:=identity scaled 10mm shifted (100mm,150mm);
beginfig (1)
    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;
beginfig (2)
    draw (for i=0 upto 7: dir (135i)-- endfor cycle)
        transformed pagecoords;
pagecoords:=identity scaled 15mm shifted (100mm,150mm);
beginfig (3);
    % declare paths to be used
    path p[],p[]t;
    % set up points by defining relationships
    z1=(0,0);   z2=z1+2up;
    z3=z1+whatever*dir (60)=z2+whatever*dir (-50);
    z5=z1+dir (135);
    % 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); (btex $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;

The resulting three eps files can be used in TeX via LaTeX's \includegraphics command, ConTeXt's \externalfigure, Plain TeX's \epsfbox command, or (in Plain pdftex) the \convertMPtoPDF command from supp-pdf.tex. To view or print the third diagram, this inclusion is necessary, as the TeX fonts (Computer Modern) are not included in the eps files produced by MetaPost.

See also


  • MetaFun (modules for Metapost) by Hans Hagen, [2]
  • Donald Knuth: The METAFONTbook, (Computers and Typesetting Volume C) Addison-Wesley 1986. ISBN 0-201-13444-6
  • Comprehensive TEX Archive Network (CTAN): Repository of the TEX source and hundreds of add-ons and style files.
  • (La)TeX Navigator provides 305 simple MetaPost examples:
  • Taco Hoekwater: MetaPost developments—autumn 2006. TUGboat 27:1 (2006).

External links

  • The TeX users group (TUG) has a page devoted to MetaPost:
  • Active development of MetaPost continues at
  • Functional MetaPost allows MetaPost to be used from the functional programming language Haskell
  • John D. Hobby has a homepage at and some other pages and publications devoted to MetaPost, though these are now a little dated
    • Historic MetaPost homepage:
    • A User's Manual for MetaPost John D. Hobby. Available as a file distributed with MetaPost, or from the Bell Labs web site. Also available in PDF format from CTAN.
  • Troy Henderson's Online MetaPost Previewer
This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.

Copyright © World Library Foundation. All rights reserved. eBooks from Project Gutenberg are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.