MetaPost

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 produces vector graphic diagrams from a geometric/algebraic description. The language shares Metafont's 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 EPS, SVG, or PNG 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 graphics (lines, Bézier curves)
 * Metafont output is monochrome, whereas MetaPost uses RGB or CMYK colors.
 * The MetaPost language can include text labels on the diagrams, either strings from a specified font, or anything else that can be typeset with TeX.
 * Starting with version 1.8, Metapost allows floating-point arithmetic with 64 bits (default: 32 bit fixed-point arithmetic)

Many of the limitations of MetaPost derive from features of Metafont. For instance, 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.

Availability and usage
MetaPost is distributed with many distributions of the TeX and Metafont framework, for example, it is included in the MiKTeX and the TeX Live distributions.

The encapsulated postscript produced by Metapost can be included in LaTeX, ConTeXt, and TeX documents via standard graphics inclusion commands. The encapsulated postscript output can also be used with the PDFTeX engine, thus directly giving PDF. 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 and LuaTeX supports the inclusion of MetaPost code within the input file. Inclusion of MetaPost code in LaTeX is also possible by using LaTeX-packages, for example  or.

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

The resulting three eps files can be used in TeX via LaTeX's  command, ConTeXt's , Plain TeX's   command, or (in Plain pdftex) the   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 by default.