Difference between revisions of "Command/setupMPinstance"

From Wiki
Jump to navigation Jump to search
m (Add explanation about intitalizations and extensions keys)
m (Show output of example)
Line 64: Line 64:
 
Another example using the <code>setups</code> key:
 
Another example using the <code>setups</code> key:
  
<texcode>
+
<context source="yes" mode="mkiv" text="produces">
 
\defineMPinstance
 
\defineMPinstance
 
   [mpinstanceprefixed]
 
   [mpinstanceprefixed]
Line 85: Line 85:
  
 
\stoptext
 
\stoptext
</texcode>
+
</context>
 
 
The above code prints:
 
 
 
<pre>
 
normal text
 
prefix: red text
 
</pre>
 
 
 
“normal text” is printed in black, as well as “prefix:”, only “red text” is printed in red.
 
  
 
== See also ==
 
== See also ==

Revision as of 20:52, 3 November 2012

\setupMPinstance

Syntax

\setupMPinstance[...][...,...=...,...]
[...] name
format metafun mpost
extensions yes no
initializations yes no
textstyle bold sans mono …
textcolor color spec
setups


Description

This command sets up the default MetaPost instance metafun or a custom MetaPost instance previously defined with \defineMPinstance.

The extensions and initializations keys control whether the content of the \startMPextensions and \startMPinitializations environment is used or ignored in the metapost code.

Usage

To print all MetaPost labels in red:

\setupMPinstance [metafun] [textcolor=red]

\starttext

\startMPcode
  draw textext("some text") ;
\stopMPcode

\stoptext

Another example using the setups key:

\defineMPinstance
  [mpinstanceprefixed]
  [metafun]
  [setups=mp:instanceprefix:one, textcolor=red]

\startsetups mp:instanceprefix:one
   prefix:\space
\stopsetups

\starttext

\startMPcode
  draw textext("normal text") ;
\stopMPcode

\startMPcode{mpinstanceprefixed}
  draw textext("red text") ;
\stopMPcode

\stoptext

produces

See also

\defineMPinstance, Mpgraphic


Help from ConTeXt-Mailinglist/Forum

All issues with: