[metapost] question about 'Trees' in metapost

Christian Salas christian.salas at yale.edu
Tue Oct 21 01:56:28 CEST 2008


hi there,

i am following the examples given by Goossens et al book (2008) on the 
use of 'Trees' in metapost.

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?

below is the code that i am compiling with $mptopdf XXX.mp

my problem is that this line
 > newTree.food(fo)(fruits,vegetables) "hsep(1cm)", "treemode(R)";
does not recognize that potatoes [that belong to 'vegetables'] have
a subdivision as well

I tried to add 'potag' to that line [after vegetables], but in that 
case, metapost recognize it as it were 3 main branches, which is not my 
case.

please, help

%######################################################
verbatimtex
\documentclass{article}
\usepackage{times}
\begin{document}
etex;

input metaobj

beginfig(1);

beginfig(136);

   newBox.a(btex apples etex);
   newBox.b(btex oranges etex);
   newBox.c(btex bananas etex);
   newBox.f(btex fruits etex);
   newTree.fruits(f)(a,b,c) "Ralign(right)", "treemode(R)";
newBox.da(btex papaA etex);  %i modified this
newBox.db(btex papaB etex);  %i modified this
   newBox.d(btex potatoes etex);
   newBox.e(btex peas etex);
   newBox.v(btex vegetables etex);
   newTree.vegetables(v)(d,e) "Ralign(center)", "treemode(R)";
newTree.potag(d)(da,db) "Ralign(center)", "treemode(R)"; %i modi.this
   newBox.fo(btex food etex);

   newTree.food(fo)(fruits,vegetables) "hsep(1cm)", "treemode(R)";
   scaleObj(food,.5);
   food.c=origin;
   drawObj(food);

endfig;

verbatimtex
\end{document}
etex;

end
%######################################################

c


More information about the metapost mailing list