Difference between revisions of "Command/setupMPinstance"

From Wiki
Jump to navigation Jump to search
m (Move info about predefined instances to \defineMPinstance)
(added method=scaled double)
(6 intermediate revisions by 3 users not shown)
Line 24: Line 24:
 
     <td class="cmd">initializations</td>
 
     <td class="cmd">initializations</td>
 
     <td>yes no </td>
 
     <td>yes no </td>
 +
  </tr>
 +
  <tr valign="top" class="second">
 +
    <td class="cmd">method</td>
 +
    <td>scaled double </td>
 
   </tr>
 
   </tr>
 
   <tr valign="top" class="second">
 
   <tr valign="top" class="second">
Line 43: Line 47:
  
 
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.
 +
 +
'''Note''': the <code>textstyle</code> and <code>textcolor</code> keys only work when <code>initializations=yes</code> is set.
  
 
== Usage ==
 
== Usage ==
Line 62: Line 70:
 
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 83: Line 91:
  
 
\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 ==
<!-- something like {{cmd|goto}} -->
+
{{MetaPost see also}}
 
 
{{cmd|defineMPinstance}}, [[Mpgraphic]]
 
 
 
  
 
== Help from ConTeXt-Mailinglist/Forum ==
 
== Help from ConTeXt-Mailinglist/Forum ==
Line 104: Line 100:
 
{{Forum|{{SUBPAGENAME}}}}
 
{{Forum|{{SUBPAGENAME}}}}
  
[[Category:Commands|setupMPinstance]]
+
[[Category:Command/MetaPost|setupMPinstance]]

Revision as of 15:33, 26 January 2013

\setupMPinstance

Syntax

\setupMPinstance[...][...,...=...,...]
[...] name
format metafun mpost
extensions yes no
initializations yes no
method scaled double
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.

Note: the textstyle and textcolor keys only work when initializations=yes is set.

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

Help from ConTeXt-Mailinglist/Forum

All issues with: