MP(1)

NAME
mp, inimp, virmp - MetaPost, a system for drawing pictures

SYNOPSIS
mp [ -T ] [ first-line ]

inimp [ -T ] [ first-line ]

virmp [ -T ] [ first-line ]

DESCRIPTION
MetaPost interprets the MetaPost language and produces PostScript pictures. The MetaPost language is similar to Knuth's Metafont with additional features for including tex(1) or troff(1) commands and accessing features of PostScript not found in Metafont. The -T flag selects troff instead of tex.

Like TeX and Metafont, MetaPost is normally used with a large body of precompiled macros. The basic program as compiled is called inimp; it can be used to precompile macros into a .mem file. The virmp variant is used to reload the .mem files quickly. Typically, virmp has links to it by the names of the various mem files. For example, if you link virmp to mp and then execute the program mp, you get the mem file mp.mem. You can load a different base by saying, e.g., virmp \\&mymem.

An argument given on the command line behaves as the first input line. That can be either a (possibly truncated) file name or a sequence MetaPost commands starting with \ and including an input command. Thus mp figs processes the file figs.mp. The basename of figs becomes the ``jobname'', and is used in forming output file names. If no file is named, the jobname becomes mpout. The default extension, .mp, can be overridden by specifying an extension explicitly.

There is normally one output file for each picture generated, and the output files are named jobname.nnn, where nnn is a number passed to the beginfig macro. The output file name can also be jobname.ps if this number is negative.

The output files can be used as figures in a TeX document by including
\special{psfile=jobname.nnn} in the TeX document. Alternatively, one can \input epsf.tex and then use the macro
\epsfbox{jobname.nnn} to produce a box of the appropriate size containing the figure.

btex TeX commands etex
    This causes mp to generate a MetaPost picture expression that corresponds to the TeX commands. If the TeX commands generate more than one line of text, it must be in a \vbox or a minipage environment.

verbatimtex TeX commands etex
    This is ignored by mp except that the TeX commands are passed on to TeX. When using LaTeX instead of TeX the input file must start with a verbatimtex block that gives the \documentstyle and \begin{document} commands.

Since most TeX fonts have to be downloaded as bitmaps, the btex feature works best when the output of mp is to be included in a TeX document so that dvips(1) can download the fonts. For self-contained PostScript output that can be used directly or included in a troff document, start your MetaPost input file with the command prologues:=1 and stick to standard PostScript fonts. TeX and MetaPost use the names in the third column of the file @MPINPUTDIR@/support/trfonts.map.

MetaPost output can be included in a troff document via the -m pictures macro package. In this case mp should be invoked with the -T flag so that the commands between btex and etex or between verbatimtex and etex are interpreted as troff instead of TeX. (This automatically sets prologues:=1 ).

ENVIRONMENT
The default values for all environment variables are set at the time of compilation in the file kpathsea/paths.h. See the Kpathsearch library documentation (the `Path specifications' node) for the details of the searching.

If the environment variable TEXMFOUTPUT is set, MetaPost attempts to put its output files in it, if they cannot be put in the current directory.

Here is a list of the environment variables affect the behavior of mp:

MPINPUTS
    Search path for input files. It should be colon-separated, and start with dot. Default: @DEFAULT_MP_PATH@

MFINPUTS
    Auxiliary search path for input files with .mf extensions. Default: @DEFAULT_MF_PATH@

TEXFONTS
    Search path for font metric (.tfm) files. Default: @DEFAULT_TFM_PATH@

VFONTS
    Search path for virtual font (.vf) files. Default: @DEFAULT_VF_PATH@

MPMEMS
    Search path for .mem files. Default: @DEFAULT_MEM_PATH@

MPPOOL
    Search path for internal MetaPost strings. (Used by inimp only.) Default: @DEFAULT_MPPOOL_PATH@

MPSUPPORT
    Directory for various tables for handling included tex and troff. Default: @MPINPUTDIR@/support

MPXCOMMAND
    The name of a shell script that converts embedded typesetting commands to a form that MetaPost understands. Defaults: makempx for tex and troffmpx for troff.

TEX The version of TeX - or LaTeX - to use when processing btex and verbatimtex commands. Default: tex

TROFF
    The troff pipeline for btex and verbatimtex commands. Default: eqn -d\$\$ | troff

MPEDIT
    A command template for invoking an editor. Default: @EDITOR@

A .mem file is a binary file that permits fast loading of macro packages. mp reads the default plain.mem unless another .mem file is specified at the start of the first line with an & just before it. There is also an that simulates plain Metafont so that mp can read .mf fonts. (Plain Metafont is described in The Metafontbook).

Experts can create .mem files be invoking inimp and giving macro definitions followed by a dump command.

The MetaPost language is similar to Metafont, but the manual A User's Manual for MetaPost assumes no knowledge of Metafont. MetaPost does not have bitmap output commands or Metafont's online display mechanism.

FILES

@MPPOOLDIR@/mp.pool
    Encoded text of MetaPost's messages.

@MEMDIR@/*.mem
    Predigested MetaPost mem files.

@plain.mp@
    The standard mem file. This is loaded when virmp is invoked via a symbolic link as mp.

@mfplain.mp@
    The Metafont-compatible mem file. This is loaded when virmp is invoked via a symbolic link as mfmp.

@MPINPUTDIR@/base/*.mp
    The standard MetaPost macros included in the original distribution.

@MPINPUTDIR@/support/*
    Various tables for handling included tex and troff.

@MPINPUTDIR@/support/trfonts.map
    Table of corresponding font names for troff and PostScript.

@FONTMAPDIR@/psfonts.map
    Table of corresponding font names for tex and PostScript.

@TEXMF@/doc/mp/examples.mp
    The source file for a few sample figures that are part of a LaTeX document @TEXMF@/doc/mp/mpintro.tex that describes the MetaPost system in a little more detail.

SUGGESTED READING
Donald E. Knuth, The Metafontbook (Volume C of Computers and Typesetting), Addison-Wesley, 1986, ISBN 0-201-13445-4.
John D. Hobby, A User's Manual for MetaPost, CSTR 162, AT&T Bell Labs,
John D. Hobby, Drawing Graphs with MetaPost, CSTR 164, AT&T Bell Labs,
TUGboat (the journal of the TeX Users Group).

SEE ALSO
tex(1), mf(1), dvips(1).

AUTHORS
MetaPost was designed by John D. Hobby, incorporating algorithms from Metafont by Donald E. Knuth. It was originally implemented on Unix, incorporating system-dependent routines from web2c, while not relying on it except for the actual Web-to-C translator.

Ulrik Vieth adapted MetaPost to take advantage of the advanced path searching features in more recent versions of web2c and worked towards fully integrating MetaPost into the canonical Unix TeX distribution. He also updated and extended this manual page.

TRIVIA
Unlike TeX and Metafont, MetaPost originally didn't use any fancy logo. John Hobby says he prefers the spelling ``MetaPost'', yet Don Knuth has updated the Metafont logo.mf font to be able to typeset a proper MetaPost logo similar to the Metafont logo. Feel free to use whatever you think is more appropriate!