[metapost] question about 'Trees' in metapost
Christian Salas
christian.salas at yale.edu
Tue Oct 21 17:13:21 CEST 2008
thanks stephan!!!
this is exactly what i want!!!
cheers
-------------------------------------------------------------------------------
Christian Salas E-mail:christian.salas at yale.edu
PhD student http://environment.yale.edu/salas
School of Forestry and Environmental Studies
Yale University Tel: +1-(203)-432 5126
360 Prospect St Fax:+1-(203)-432 3809
New Haven, CT 06511-2189 Office: Room 35, Marsh Hall
USA
Yale Biometrics Lab http://environment.yale.edu/biometrics
-------------------------------------------------------------------------------
Stephan Hennig wrote:
> Christian Salas schrieb:
>
>> i am following the examples given by Goossens et al book (2008) on the
>> use of 'Trees' in metapost.
>
> Interesting, I have to watch out for that book in the library.
>
>
>> My question is simple: they provide an example with 3 leves (Food;
>> fruits/vegetable; apples--bananas/potatoes-peas). Now i want to add one
>> more level, let say within the sub-sublevel potatoes, i want to create 2
>> new subsubsub levels. How can i achieve that?
>
> There are no sub-...-levels in MetaObj's trees. All tree objects
> actually have height two (or one in some terminology). That is, tree
> objects consist of exactly one root node (first argument) and an
> arbitrary number of direct child nodes (second list argument). Trees
> (in computer science terminology) that have second order child nodes
> have to be constructed by nesting tree objects. In the example below a
> frame is drawn around all tree objects to emphasize tree structure.
>
> One problem of MetaObj trees is that construction needs an enormous
> number of variables. There is an alternative, streamlined construcors,
> described in section "Advanced operations" in the MetaObj manual, but
> that doesn't really make the code more readable. What's missing for
> MetaObj is a macro (or even an external tool) that translates a graph
> from one of the standard graph formats into MetaObj code.
>
> One last hint: if you read the MetaObj manual, start with section 7,
> "Standard Library -- Gallery", and section 5, "Advanced operations" in
> that order.
>
> Best regards,
> Stephan Hennig
>
>
> verbatimtex
> \documentclass{article}
> \usepackage{times}
> \begin{document}
> etex
> input metaobj
> prologues:=2;
>
> beginfig(1);
> setObjectDefaultOption("Tree")("treemode")("R");
> setObjectDefaultOption("Tree")("framed")(true);
> setObjectDefaultOption("Tree")("dx")(5bp);
> setObjectDefaultOption("Tree")("dy")(5bp);
>
> %%% Create tree 'potatoes'.
> newBox.potR(btex potatoes etex);
> newBox.potA(btex papaA etex);
> newBox.potB(btex papaB etex);
> newTree.potatoes(potR)(potA, potB);
>
> %%% Create tree 'vegetables'.
> newBox.pea(btex peas etex);
> newBox.vegR(btex vegetables etex);
> newTree.vegetables(vegR)(potatoes, pea);
>
> %%% Create tree 'fruits'.
> newBox.fruR(btex fruits etex);
> newBox.fruA(btex apples etex);
> newBox.fruB(btex oranges etex);
> newBox.fruC(btex bananas etex);
> newTree.fruits(fruR)(fruA, fruB, fruC);
>
> %%% Create tree 'food'.
> newBox.fooR(btex food etex);
> newTree.food(fooR)(fruits, vegetables);
>
> food.c = origin;
> drawObj(food);
> endfig;
> end
More information about the metapost
mailing list