On Mon, 27 Oct 2008, Wolfgang Schuster wrote: > On Fri, Oct 24, 2008 at 2:15 PM, Aditya Mahajan <[EMAIL PROTECTED]> wrote: >> On Fri, 24 Oct 2008, Wolfgang Schuster wrote: >> >>> Hi all, >>> >>> what is the best method to format MetaPost labels in MkII with >>> \doattributes. >> >> \startMPenvironment[global] >>> \setupcolors[state=start] >>> >>> \def\labelstyle{bold} >>> \def\labelcolor{red} >> \stopMPenvironment >> >> This gives you only bold label. >> >>> \starttext >>> \startMPcode >>> label(textext("\doattributes{label}{style}{color}{Label}"),origin) ; >>> \stopMPcode >>> \stoptext >> >> Tex colors do not work inside textext. Try >> >> label(textext("\startcolor[red] red \stopcolor"), origin) ; >> >> One way to get around this is to use \sometxt. >> >> label(\sometxt{\doattributes{label}{style}{color}{Label}},(5cm,0)) ; >> >> But then you have to be careful about the differences between \sometxt in >> MKII and MKIV (which I need to summarize on the wiki). > > Here is a new example where I can't even use \sometxt.
Sometxt does not work appear to work with \startMPdrawing (there is no output at all). I think that the reason is that MPdrawing simply writes stuff to the MPfile without doing the extra work needed for sometxt. I will call this is a bug, but I do not know if Hans wants to work on TeX-MP interaction in MKII now. > \setupcolors[state=start] > > \def\labelstyle{bold} > \def\labelcolor{red} > > \starttext > \resetMPdrawing > \startMPdrawing > label(textext("\doattributes{label}{style}{color}{Label}"),origin) ; > label(\sometxt{\doattributes{label}{style}{color}{Label}},origin) ; > \stopMPdrawing > \MPdrawingdonetrue > \getMPdrawing > \stoptext It may be possible to write your macros without \start-stop-MPdrawing. Everything inside \start-stop MP(code|graphic) is first parsed by TeX, so you can do things like \newif\ifcircle \circletrue \startMPcode draw \ifcircle fullcircle \else fullsquare \fi xyscaled (5cm,5cm) ; \stopMPcode So, instead of writing stuff to MP using start-stop MPdrawing, you can simply set some flags in conditionals and chardefs, and then write one MP(graphic|code) to write one MP file. This strategy will not work for all cases, but can be useful for some. 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 : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________