tree growth function

View: New views
3 Messages — Rating Filter:   Alert me  

tree growth function

by Flavio Costa :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I'm drawing a tree with the code below:

\documentclass{minimal}

\usepackage{tikz}
\usetikzlibrary{trees}

\begin{document}

\begin{tikzpicture}[
    every node/.style={draw},
    single/.style={
        %grow=south,
        grow via three points={one child at (0,-1) and two children at (1,-1) and (1,-2)},
        edge from parent path=(\tikzparentnode) -- (\tikzchildnode)},
    level 2/.style={
        grow via three points={one child at (1,-1) and two children at (1,-1) and (1,-2)},
        edge from parent path=(\tikzparentnode) |- (\tikzchildnode)}]

\node {Root}[edge from parent fork down,sibling distance=30mm]
    child {node {Item 1}
        child {node {Item 1.1}}
        child {node {Item 1.2}}}
    child {node {Item 2}
        child[single] {node {Item 2.1}}}
    child {node {Item 3}
        child {node {Item 3.1}}
        child {node {Item 3.2}}
        child {node {Item 3.3}}}
    child {node {Item 4}
        child {node {Item 4.1}}
        child {node {Item 4.2}}
        child {node {Item 4.3}}
        child {node {Item 4.4}}}
        ;
\end{tikzpicture}

\end{document}

It produces the desired effect, but I feel that it could be made simpler. For the [single] style, if I replace "grow via three points" by "grow=south" the child node gets misaligned vertically. Why does this happen?

Is it possible to get the same effect without having to create a separate [single] style? I tried playing with "grow via three points" possibilites, but none worked as expected.

Thanks.

Flavio Costa


      ____________________________________________________________________________________
Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users

Re: tree growth function

by JL Diaz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Sep 3, 2009 at 1:20 AM, Flavio Costa<flaviocosta@...> wrote:
> Hi,
>
> I'm drawing a tree with the code below:
[ ... ]

> It produces the desired effect, but I feel that it could be made simpler. For the [single] style, if I replace "grow via three points" by "grow=south" the child node gets misaligned vertically. Why does this happen?

Because the default distance among levels is not 1cm (as it is for the
other siblings, due to your (0,1) specification).


> Is it possible to get the same effect without having to create a separate [single] style? I tried playing with "grow via three points" possibilites, but none worked as expected.

It is possible to simplify your single style, using grow=south instead
of grow via three points. you have to add [level distance=10mm] option
to your Root node. However, I cannot imagine any way for getting rid
of the [single] style.

Regards,
--JL Diaz

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users

Res: tree growth function

by Flavio Costa :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> It is possible to simplify your single style, using grow=south instead

> of grow via three points. you have to add [level distance=10mm] option
> to your Root node. However, I cannot imagine any way for getting rid
> of the [single] style.

Hi,

[grow=south,level distance=10mm] works perfectly, thanks for the explanation.

Flavio Costa


      ____________________________________________________________________________________
Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users