[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 
figure.

> 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) =
  begingroup
  charcode:=c;
  clearxy; clearit; clearpen;
  pickup defaultpen;
  drawoptions();
  scantokens extra_beginfig;
enddef;

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

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.

Aditya


More information about the ntg-context mailing list