Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  

































Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 



















Contents

   



(Top)
 


1 Availability and usage  





2 Examples  





3 See also  





4 References  





5 External links  














MetaPost






Català
Čeština
Deutsch
Español
فارسی
Français

Italiano

Polski
Русский
Svenska
Українська

 

Edit links
 









Article
Talk
 

















Read
Edit
View history
 








Tools
   


Actions  



Read
Edit
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Cite this page
Get shortened URL
Download QR code
Wikidata item
 




Print/export  



Download as PDF
Printable version
 




In other projects  



Wikimedia Commons
Wikibooks
 
















Appearance
   

 






From Wikipedia, the free encyclopedia
 


MetaPost
Paradigmimperative, typesetting
Designed byJohn D. Hobby
DeveloperTaco Hoekwater, Luigi Scarso
First appeared1994 (1994)
Stable release

1.8 / 17 June 2013; 11 years ago (2013-06-17)

Preview release

2.0rc2 / 19 February 2018; 6 years ago (2018-02-19)

Typing disciplineduck, dynamic, strong
OSCross-platform
LicenseLGPL
Websitetug.org/metapost
Influenced by
Metafont

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,

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

[edit]

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 gmpormpgraphics.

Examples

[edit]

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

example outputs
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;
endfig;
beginfig (2)
    draw (for i=0 upto 7: dir (135i)-- endfor cycle)
        transformed pagecoords;
endfig;
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);
    z4=z3+(-1.5,-.5);
    z5=z1+dir (135);
    z0=whatever[z1,z2]=whatever[z3,z4];
    % set up paths
    p0=fullcircle yscaled .5 rotated 45 shifted z0 ;
    p1=z2---z4..z0..z3---z1;
    p2=p1 cutbefore p0 cutafter p0;
    p3=p0 cutbefore p1 cutafter p1;
    p4=p2---p3---cycle;
    % 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);
    label.top (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;
    endfor
endfig;
bye

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 by default.

See also

[edit]

References

[edit]
  • Hagen, Hans. "MetaFun" (modules for Metapost).
  • Knuth, Donald (1986). The METAFONTbook. Computers and Typesetting. Vol. C. Addison-Wesley. 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". Archived from the original on 2013-07-27. Retrieved 2006-11-17.
  • Hoekwater, Taco (2006). "MetaPost developments—autumn 2006" (PDF). TUGboat. 27 (1).
  • [edit]
    Retrieved from "https://en.wikipedia.org/w/index.php?title=MetaPost&oldid=1225613761"

    Categories: 
    Programming languages created in 1994
    Declarative programming languages
    Domain-specific programming languages
    Free TeX software
    PostScript
    Public-domain software
    Vector graphics markup languages
    Hidden categories: 
    Articles with short description
    Short description matches Wikidata
    Wikipedia articles with style issues from January 2016
    All articles with style issues
    Articles lacking in-text citations from January 2016
    All articles lacking in-text citations
    Articles with multiple maintenance issues
    Articles containing Polish-language text
     



    This page was last edited on 25 May 2024, at 16:06 (UTC).

    Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



    Privacy policy

    About Wikipedia

    Disclaimers

    Contact Wikipedia

    Code of Conduct

    Developers

    Statistics

    Cookie statement

    Mobile view



    Wikimedia Foundation
    Powered by MediaWiki