From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/4913 Path: main.gmane.org!not-for-mail From: "Denis B. Roegel" Newsgroups: gmane.comp.tex.context Subject: Re: Labeling a tree with MetaObj. Date: Mon, 2 Jul 2001 21:23:00 +0200 Sender: owner-ntg-context@let.uu.nl Message-ID: <20010702212300.A13559@bar.loria.fr> References: <974796191.20010630192115@bigfoot.com> NNTP-Posting-Host: coloc-standby.netfonds.no Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1035395546 29794 80.91.224.250 (23 Oct 2002 17:52:26 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 23 Oct 2002 17:52:26 +0000 (UTC) Cc: ntg-context@ntg.nl Original-To: Tarik Kara In-Reply-To: ; from ktarik@Bilkent.EDU.TR on Mon, Jul 02, 2001 at 11:11:07AM +0300 Xref: main.gmane.org gmane.comp.tex.context:4913 X-Report-Spam: http://spam.gmane.org/gmane.comp.tex.context:4913 On Mon, Jul 02, 2001 at 11:11:07AM +0300, Tarik Kara wrote: > I would like to draw the tree diagram shown at the attachement with > MetaObj. I can label the terminal nodes and the edge labeled "o". But I > had no luck with the nodes label "1", "2", and the other edges. Any > succestions is appreciated. Thanks in advance. Below is a solution. I didn't bother to get the same dimensions as you, though. I have used the (unfortunately) undocumented treeroot macro, which I should actually extend a bit. I know this solution looks complex and that's why a TeX (or ConTeXt) interface is really needed! :-) Feel free to post other queries. I'll use them for the next version of the metaobj manual. However, I am not sure everybody is interested in this group, so it might be a better idea to post the questions on the metafont/metapost mailing list, even though I doubt anybody else than I will answer for some time... Denis % Example requested by Tarik Kara. % A useful inspiration was the figure on page 109 of the metaobj manual. % D. Roegel, 2 July 2001 input metaobj setCurveDefaultOption("arrows","draw"); setObjectDefaultOption("Tree")("hideleaves")(true); def mytc=new_Circle_("")("filled(true)") enddef; labeloffset:=2bp; % 3bp is the default in plain.mp beginfig(1); t:=T_(mytc)(mytc,T_(mytc)(mytc,mytc)("hbsep(2cm)"))("hbsep(2cm)"); Obj(t).c=origin; % |ObjLabel| should appear after an object is positionned (this is not % clearly stated in the manual); one can always move the object afterwards; % this constraint appears when |ObjLabel| is used on subtrees, since % |ObjLabel| temporarily attaches the object; when it unties it, links % to the embedding object(s) are lost. ObjLabel.ntreepos(Obj(t))(1)(btex $(0,2)$ etex) "labcard(s)"; ObjLabel.ntreepos(Obj(t))(2,1)(btex $(-1,0)$ etex) "labcard(s)"; ObjLabel.ntreepos(Obj(t))(2,2)(btex $(1,1)$ etex) "labcard(s)"; % the |treeroot| function should also work for an empty second argument, % but this is currently not the case, so one has to use |obj| and |root| % in order to dig into the object; it will be corrected in the next version % of metaobj. ObjLabel.obj(Obj(t)root)(btex $1$ etex) "labcard(n)"; ObjLabel.treeroot(Obj(t))(2)(btex $2$ etex) "labcard(ne)"; ObjLabel.Obj(t)(btex $o$ etex) "labpathid(1)", "labdir(lft)"; ObjLabel.Obj(t)(btex $e$ etex) "labpathid(2)", "labdir(rt)"; ObjLabel.ntreepos(Obj(t))(2)(btex $f$ etex) "labpathid(1)", "labdir(lft)"; ObjLabel.ntreepos(Obj(t))(2)(btex $a$ etex) "labpathid(2)", "labdir(rt)"; draw_Obj(t); endfig; end