Changes

Jump to navigation Jump to search
m
no edit summary
< [[Graphics]]|[[Metafun]]|[[Metapost]]>__TOC__
ConTeXT provides a tight integration of TeX and [[Metapost]]. Metapost can used behind the scenes for some graphic trickery. This integration is also helpful for drawing figures in metapost and use them in the document. Some of the commonly used commands for this are
MetaFun is ConTeXt extension the [[MetaPost]] language. It provides a tight integration of both TeX and [[MetaPost]]. MetaPost can used behind the scenes for some graphic trickery. This integration is also helpful for drawing figures in MetaPost and use them in the document.
==<cmd>startMPenvironment</cmd>==This is used to change the body font for metapost graphics'''THE [[manual:metafun-p. For examplepdf|MetaFun manual]]''', to get the text also available in metapost graphics in times, usea [[manual:metafun-s.pdf|screen version]].
<texcode>
\startMPenvironment
\usetypescript[times][texnansi]
\switchtobodyfont[times,10pt]
\stopMPenvironment
</texcode>
==<cmd>startMPinclusions</cmd>==This can be page is a brief overview of some of the commonly used for specifying metapost files to ''input'' and also to define metapost functionscommands.For example<texcode>\startMPinclusions input boxes ; vardef my_metapost_fun(expr var)= ... enddef ;\stopMPinclusions</texcode>
=Commonly used commands =<cmd>startMPpage</cmd>==This produces a page containing containing metapost graphic. The resulting pdf is self contained (it has all the fonts embedded) This is useful if you want to send the figure to a coauthor or a journal. For example, one can have
<texcode>\starttext\startMPpage draw fullcircle scaled 2cm ;{{cmd|defineMPinstance}}, {{cmd|setupMPinstance}}: used to set up MetaPost invocations with particular features. One use case could be to select a sans serif font for all MetaPost labels. dotlabel: {{cmd|startMPenvironment}} '''is DEPRECATED''' in which one could place settings that one only wanted to apply in the MetaPost environment, but not in the document itself.bot(textext("(0One should use {{cmd|defineMPinstance}} and {{cmd|setupMPinstance}},0)"),origin) ;\stopMPpageinstead.
\startMPpage draw fullcircle scaled 2cm ; drawarrow (0{{cmd|startMPinclusions}}: Inside,0)--(1cmone can specify MetaPost files to ''input'',0) ; labeland also define MetaPost functions.bot(textext("$r$"),(5mm,0)) ;\stopMPpage
\stoptext</texcode>; {{cmd|startuseMPgraphic}}, {{cmd|useMPgraphic}}: defines a piece of graphics code that is processed anew every time the graphic is placed with {{cmd|useMPgraphic}}.
Processing this file using<texcode> texmfstart texexec --pdf filename</texcode>gives a pdf ; {{cmd|startreusableMPgraphic}}, {{cmd|reuseMPgraphic}}: For graphics that are the same every time, it is better to use {{cmd|startreusableMPgraphic}}: the graphic is compiled only once, and the one resulting picture can be placed at various points with two pages of graphics{{cmd|reuseMPgraphic}}.
==<; {{cmd>startstaticMPfigure</cmd>==<cmd>startuseMPgraphic</cmd> series of commands were designed for using metapost for drawing fancy frames and backgrounds and not for using <i>stand-alone</i> graphics for |startMPcode}}: When reusing a document. <cmd>startstaticMPfigure</cmd> creates a separate pdf file containing the graphic. This pdf is not important, you can be included in the document using <cmd>usestaticMPfigure</simply use {{cmd>. Context is clever enough to recompile the resulting metapost file, only if something inside the start stop staticMPgraphic has changed|startMPcode}}.
For example,<texcode>\startstaticMPfigure; {center{cmd|startMPpage}} draw fullcircle scaled 2cm ; dotlabel: produces a page a containing MetaPost graphic. The page is just large enough to contain the graphic.bot(textext("The resulting pdf is self-contained (0,0it has all the fonts embedded)"),origin) ;\stopstaticMPfigure. This is useful if you want to send the figure to a coauthor or a journal.
\; {{cmd|startstaticMPfigure}}, {radius{cmd|usestaticMPfigure} draw fullcircle scaled 2cm ; drawarrow (0,0)}: The {{cmd|startuseMPgraphic}} series of commands were designed for using MetaPost for drawing fancy frames and backgrounds and not for using <i>stand--(1cm,0) ; labelalone</i> graphics for a document. {{cmd|startstaticMPfigure}} creates a separate pdf file containing the graphic. This pdf can be included in the document using {{cmd|usestaticMPfigure}}. ConTeXt is clever enough to recompile the resulting MetaPost file only if something inside the {{cmd|startstaticMPfigure}} has changed.bot(textext("$r$"),(5mm,0)) ;\stopstaticMPfigure
\starttext= Documentation and links =
Circle centered \usestaticMPfigure* [center[manual:mmakempy.pdf|MakeMPY]]: create MetaPost outlines (by Pragma)* [[width=1cmFlow Charts|FlowCharts]] at origin with radius: encapsulated application, demonstration of MetaPost/MetaFun\usestaticMPfigure* [radiushttp://www.pragma-ade.com/general/sources/mptopdf.pdf MPtoPDF]: create PDF from MetaPost (by Pragma)* [width=1cmhttp://www.pragma-ade.com/show-gra.pdf a few examples of MetaPost graphics] $r=1\,\text{cm}$* [http://www.pragma-ade.com/articles/art-puzz.pdf Puzzling graphics in MetaPost] (article)* [http://www.ntg.nl/maps/25/15.pdf metapost metafun.Hans Hagen at MAPS]
\stoptext
</texcode>
==If transparency is not working==
* '''center''' and '''radius''' above are ''labels'' that are used to access the figure.
* <cmd>usestaticMPfigure</cmd> takes the first argument as the ''label'' of the figure to be inserted. The second argument has the same options as the second argument of <cmd>externalfigure</cmd>
* To force the figure files to be regenerated, remove all the <code>*.mp.md5</code> files from the current directory.
----
[[Category:Graphics]]
[[Category:Metapost]]
 
 
{{MetaPost see also}}
{{Metapost navbox}}

Navigation menu