[Xy-pic] Automatic layout of trees with xypic

Aivo Jürgenson kala at tux.linux.ee
Sun Apr 9 19:40:01 CEST 2006


I would like to typeset the tree structures with xypic and because some 
numbers in the node contents are dynamically calculated, I would like to 
automate this typesetting process as much as I can. The best solution 
would be to describe the tree and the parameters of the nodes in separate 
text file, then to process this file with my program, which calculates the 
missing parameters, then to convert the tree description to the xypic 
language and finally typeset it as a picture in my LaTeX document. I have 
been able to create some basic examples, but the results are not very 

With the standard grid of 3pc units the nodes tend to overlap with each 
other very much. Even when I modify the standard grid with something like 
!{<0cm,0cm>;<3cm,0cm>:<0cm,0cm>} escape, I get larger grid, but some nodes 
still overlap and the space between tree levels is very large, therefore 
creating not very nice trees.

Automatically generated xypic source code is attached to the letter and 
the corresponding pdf output as well. As you can see, the structure of the 
tree itself is not very complicated.

So, first, I would like to ask, is it possible to somehow "intelligently" 
position the nodes of the each level of tree, so that the individual size 
of the nodes are taken into account? Say, if I figure out that my nodes 
are all no more than 1 cm tall, I could easily handle my tree as levels, 
which must be separated by 2 cm. Now, if I could somehow slide the next 
node to right or left, so that its not overlapping with its previous 
neighbour, then I think the result would be ok. I was thinking about 
[dl]!... escapes and some stack operations, but its all over my head and I 
can't figure it out by myself.

If somebody could send me an example of some simpler trees, I would be 
very grateful.

If this automatic layout of not possible with xypic, then perhaps it would 
be possible to specifdy the base for the new grid, so that base would be 
something like (3,1). I would like to get the situation, that when I say 
[dl] the current position moves down by 1cm, but left by 3cm. At the 
moment, I can set it to (3,3) with !{<0cm,0cm>;<3cm,0cm>:<0cm,0cm>}, but 
all other combinations that I have been trying, either don't work, or come 
up with somehow "skewed" base, so that the tree become "tilted".

How to specify base <3cm,1cm> ?

If this automatic layout is not possible, then another option could be to 
put less information to node contents and to use pictures just to 
represent the structre. I could use the numbers, instead of sentences, for 
the nodes names and leave out the parameters, but it would very good to 
lay some parameters to the tree structure as well, so I do not want to 
give up yet.

Aivo Jürgenson, aivo.jurgenson at linux.ee
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tree.pdf
Type: application/pdf
Size: 45184 bytes
Url : http://tug.org/pipermail/xy-pic/attachments/20060409/a4da2ce2/tree-0001.pdf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tree.tex
Type: text/x-tex
Size: 1385 bytes
Url : http://tug.org/pipermail/xy-pic/attachments/20060409/a4da2ce2/tree-0001.bin

More information about the xy-pic mailing list