On Sat, 23 Sep 2006 15:03:57 +0100
Sanjoy Mahajan <[EMAIL PROTECTED]> wrote:

> [Hans: Feature suggestion for figure inclusion at the end...]
> 
> I wrote:
> > So, is --final a requirement when using metafun, or am I hacking
> > around a problem I've caused by leaving something out?
> 
> An answer is that I should set \runMPgraphicstrue.  I thought it was
> automatically set, half-remembering what Aditya said in the previous
> thread on metafun.  So the following works (changing the r changes the
> result right away without requiring --final or requiring two texexec
> runs):
> 
> ========= cut here ==================
> \runMPgraphicstrue
> \starttext
> 
> \startreusableMPgraphic{a}
> r := 1cm;
> fill fullcircle scaled r;
> \stopreusableMPgraphic
> 
> \placefigure[force,none]{}{\reuseMPgraphic{a}}
> 
> the figure above should be a small circle
> 
> \stoptext
> ========= cut here ==================
> 
> To see where and when \runMPgraphicstrue was done, I looked into the
> metafun interface code, and asked grep for help:
> 
> $ grep '\\runMPgraphicstrue' *.tex
> s-pre-02.tex:113:%D switch \type {\runMPgraphicstrue} to the local file \type
> supp-mps.tex:1195:%D \runMPgraphicstrue
> supp-mps.tex:1209:%D \type{\runMPgraphicstrue}, the \METAPOST\ scratch file
> supp-mps.tex:1653:%D \global\runMPgraphicstrue
> supp-mps.tex:1991:   \runMPgraphicstrue
> 
> So it's commented-in only at line 1991, which is part of a new (to me)
> method of figure inclusion: \startstaticMPgraphic, which says
> "Dedicated to Aditya Mahajan. See meta-ini for usage", so I see how
> Aditya would conclude that \runMPgraphicstrue is always true :-)
> 
> The following therefore also works to get instant updating, and is
> more efficient than reusable MP graphics in that it reruns metapost on
> included figures only when they change:
> 
> ========= cut here ==================
> % no need to set \runMPgraphicstrue
> \starttext
> 
> % see how smart staticMPfigure is by changing r here but not
> % in the figure definition itself.  Will it re-metapost the graphic?
> % Answer: It's smart.
> \startMPinclusions
> r := 1cm;
> \stopMPinclusions
> 
> \startstaticMPfigure{a}
> fill fullcircle scaled r;
> \stopstaticMPfigure
> 
> \placefigure[force,none]{}{\usestaticMPfigure[a]}
> 
> the figure above should be a small or large circle
> 
> \stoptext
> ========= cut here ==================
> 
> Which I just now see is on the Wiki page about metafun (I'd been
> working from the excellent metafun manual).
> 
> It's doubly smart in that changing the papersize (which changes the
> layout parameters, which are included in the metapost file) will rerun
> the graphic, even if r stays the same.  So the graphic can base itself
> on those parameters and be updated when needed.
> 
> Thanks, Hans and Aditya!
> 
> While experimenting with the methods of figure inclusion, I've been
> changing among \reuseMPgraphic, \usestaticMPfigure, \useMPgraphic, and
> \externalfigure to call up the figure.  Do all the figure labels live
> in the same namespace?  In which case (warning: feature suggestion!)
> when they are defined, e.g. with \useexternalfigure,
> \startstaticMPfigure, ..., could the label have associated with it the
> command that calls it up?  So one could do for all types:
> 
> \usefigure[thelabel]
> 
> and ConTeXt would figure out what kind of figure it is and turn
> \usefigure into the appropriate one (\reuseMPgraphic, ...).  
> 
> Then speaking purely hypothetically of course: If, after learning
> metafun, one decides to turn many external metapost figures into
> metafun figures (and then static figures instead of reusable figures),
> the figure placement commands don't have change.
> 
> -Sanjoy
> 

Hi Sanjoy,

you should also look in your cont-sys.tex if \runMPgraphicstrue is
enabled for every ConTeXt run. 

Wolfgang

_______________________________________________
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context

Reply via email to