Difference between revisions of "Command/setupMPinstance"

From Wiki
Jump to navigation Jump to search
m (Move info about predefined instances to \defineMPinstance)
m (Add explanation about intitalizations and extensions keys)
Line 43: Line 43:
  
 
This command sets up the default MetaPost instance <code>metafun</code> or a custom MetaPost instance previously defined with {{cmd|defineMPinstance}}.
 
This command sets up the default MetaPost instance <code>metafun</code> or a custom MetaPost instance previously defined with {{cmd|defineMPinstance}}.
 +
 +
The <code>extensions</code> and <code>initializations</code> keys control whether the content of the <code>\startMPextensions</code> and <code>\startMPinitializations</code> environment is used or ignored in the metapost code.
  
 
== Usage ==
 
== Usage ==

Revision as of 12:13, 12 June 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

The above code prints:

normal text
prefix: red text

“normal text” is printed in black, as well as “prefix:”, only “red text” is printed in red.

See also

\defineMPinstance, Mpgraphic


Help from ConTeXt-Mailinglist/Forum

All issues with: