Changes

Jump to navigation Jump to search
Add section about \defineMPinstance and \setupMPinstance
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
 
==<cmd>defineMPinstance</cmd> and <cmd>setupMPinstance</cmd>==
 
These commands can be used to set up MetaPost invocations with particular
features. One use case could be to select a sans serif font for all MetaPost
labels. Example:
 
<texcode>
\setupMPinstance [metafun] [textstyle=sans]
\starttext
 
\startMPcode
draw textext("some text") ;
\stopMPcode
 
\stoptext
</texcode>
 
Another use case could be to create a custom setup with important text in bold and red for
selected MetaPost graphics. Example:
 
<texcode>
\defineMPinstance
[important]
[metafun] % needs to be inherited from the global metafun instance
[textcolor=red]
 
\defineMPinstance
[veryimportant]
[important]
[textstyle=bold]
 
\starttext
 
% normal black text
\startMPcode
draw textext("some text") ;
\stopMPcode
 
% red text
\startMPcode{important}
draw textext("some text") ;
\stopMPcode
 
% red bold text
\startMPcode{veryimportant}
draw textext("some text") ;
\stopMPcode
 
\stoptext
</texcode>
==<cmd>startMPenvironment</cmd>==
<em>Deprecated,</em> use <cmd>defineMPinstance</cmd> and <cmd>setupMPinstance</cmd> instead.
 
This is used to change the body font for metapost graphics. For example, to get the text in metapost graphics in times, use
69

edits

Navigation menu