[NTG-context] drawoptions in startMPinclusions

Aditya Mahajan adityam at umich.edu
Thu Jun 14 20:08:42 CEST 2007

Quoting nicola <vitacolo at dimi.uniud.it>:

> Hi,
> the following code
> \startMPinclusions
> drawoptions(withpen pencircle scaled 1mm);
> u := 1cm;
> \stopMPinclusions
> \startreusableMPgraphic{foo}
> draw origin--(u,u);
> \stopreusableMPgraphic
> \starttext
> \midaligned{\reuseMPgraphic{foo}}
> \stoptext
> produces a line with default thickness, not 1mm wide. Is this a bug?

No a feature of metapost. beginfig resets drawoptions. Otherwise 
drawoptions from one figure will also affect the output of another 

> Or > do I misunderstand the purpose of \startMPinclusions (I have assumed
> that it inserts the text verbatim inside each figure definition)?

It inserts text *before* the figure definitions. Have a look at the 
resulting -mpgraph.mp file. The problem is that in metapost beginfig 
resets drawoptions. This is how beginfig is defined

def beginfig(expr c) =
  clearxy; clearit; clearpen;
  pickup defaultpen;
  scantokens extra_beginfig;

So, you can use
extra_beginfig := "drawoptions(withpen pencircle scaled 1mm)" ;
u := 1cm;

to override beginfig's redefinitions. I hope that some day there will 
be a overhaul of plain.mp to something more flexible. Metafun provides 
some useful enhancements, but the metapost user interface is still very 
low level.


More information about the ntg-context mailing list