On Fri, 9 Aug 2013, Sanjoy Mahajan wrote:

Try adding
     prologues := 2;
or
     prologues := 3;
in your mp file.


Good thought, which I tried, though neither setting resolved the
problem.

Any particular reason that you are compiling metapost files using mp and
then including them in ConTeXt rather than directly using any one of the
inbuilt ConTeXt environments for handling mp (\startMPcode, \useMPgraphic,
\processMPbuffer, etc.)

Mostly conservatism.  I cannot quite figure out the canonical
replacement for btex ... etex (textext, sometext?), and then I get
confused by the many possible environments.

What do you recommend as the best btex...etex replacement

Nothing. Just leave them as it is and MkIV is smart enough to process them [^1]. If you used the TEX macros (to build strings with metapost variables), use textext("...") instead of TEX("....").

and the best
environment for replacing a standalong metapost figure (that I would
otherwise just include with \externalfigure)?

I use the following:

\startcomponent figures

\startbuffer[system-1]
 ... mp code ..
\stopbuffer

% Other figures in separate buffer

\stopcomponent

and then use

\processMPbuffer[list of buffers]

to typeset them [^2]. With this approach you loose some of the features of \externalfigure (scaling, backgrounds, etc.) For scaling, you can use

  \scale[....]{\processMPbuffer[...]}


and if you really need a background, you can use \framed.

Another option is to use \startMPcode .... \stopMPcode environment, but I usually like my figures to be separate files.

[^1]: To process btex ... etex, the content of each metapost environment is processed twice. This can sometimes lead to unexpected results. Basically you have to careful with := vs =, otherwise you'll get inconsistent equations.

[^2]: You also need to keep in mind that all metapost graphics are processed in a single run (think of a single mp file with multiple beginfigs). So you have to be careful with initializing and resetting variables (\startMPinclusions, \startMPinitializations, \startMPdefinitions, see wiki for difference) or adding bgroup ... egroup at appropriate location to limit scope.

Another way to avoid interference is to use separate MPinstances, but in my opinion that feature is more useful to module writers than normal users.


Aditya


___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to