Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a diagram in tikz-qtree like figure A, but I'd like something like figure B. Is it possibe, to alter the properties of only one brach? (these figures made with Dia and arrows not important)

edit: (added my modified code, based on Alan Munn's answer)


\begin{center}
\begin{tikzpicture}[grow'=right,level distance=1.45in,sibling distance=.2in]

\tikzset{edge from parent/.style= 
{thick, draw, edge from parent fork right},
  every tree node/.style=
    {draw,minimum width=1.3in,text width=1.15in,align=center}
}
\Tree 
  [.parent
    [.child0
      grandchild0-0
      grandchild0-1
      [[.{grandchild0-2} 
        {greatgrandchild0} 
        {greatgrandchild0}
        {greatgrandchild0} 
        {greatgrandchild0}
      ]] 
      grandchild0-3
    ] 
    [.child1
      [.grandchild1-0 ] 
      [.grandchild1-1 ] 
    ] 
  ]
\end{tikzpicture}
\end{center}

share|improve this question
4  
It would be helpful to post the TikZ code that you have already in a complete compilable document. –  Alan Munn May 8 '12 at 18:44
    
Welcome to TeX.SE. –  Peter Grill May 8 '12 at 19:01
    
@Greg Your second edit is a perfectly acceptable solution (especially for a one-off diagram) so instead of editing your question you should post it as a solution. It's fine to post answers to your own questions (and even accept them (although there's a 2 day waiting period for that, I think). –  Alan Munn May 8 '12 at 21:29
    
Yeah, I edited because I couldn't post own topic. Now, I've just I done. It was a solution to that issue. The funny thing is, atfer 2 days requirements have changed, so finally I will rahter use qtree. :D Thanks for your help. :) –  Greg May 11 '12 at 15:55
add comment

2 Answers

You can add extra brackets around a node to extend its branch:

\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-qtree}
\usetikzlibrary{trees} % this is to allow the fork right path

\begin{document}

\begin{tikzpicture}[level distance=1.25in,sibling distance=.15in,scale=.75]
\tikzset{edge from parent/.style= 
            {thick, draw,
                edge from parent fork right},every tree node/.style={draw,minimum width=1in,text width=1in, align=center},grow'=right}
\Tree 
    [. parent 
        [.{nice child0}
                [.{grandchild0-0 } ]
            [.{grandchild0-1 } ]
            [.{grandchild0-2 } ]
            [.{grandchild0-3 } ]
        ]
        [[[.child1
            [.{grandchild1-0 } ]
            [.{grandchild1-1 } ]
            [.{grandchild1-2 } ]
        ]]]
        [.child2 ]
        [.child3 ]
    ]
\end{tikzpicture}
\end{document}

output of code

share|improve this answer
    
Thank you, but there is another thing I'd like to modify on it. Namely to reduce its height. Using your figure nodenames... the gap between "nice child0" and "child2" is as wide as child1's grandchild. But I'd like to reduce it. This is why I mainly wanted the modification you gave me. –  Greg May 8 '12 at 19:25
    
@greg tikz-qtree is designed to automatically calculate the node spacing (which is why it's so useful), but this comes at the expense of not having individual control of specific nodes, I think. –  Alan Munn May 8 '12 at 19:44
add comment

I managed to find a solution to my problem without qtree baesd on this one: How to modify the distance between branches when drawing trees using TiKZ?
The code:


\documentclass[a4paper,12pt]{article}
\usepackage{tikz}
\usetikzlibrary{trees}%szögletességhöz kell
\begin{document}

\begin{tikzpicture}[grow'=right,level distance=90pt,sibling distance=30pt]

\tikzset{edge from parent/.style= 
{thick, draw, edge from parent fork right}
}

    \node [draw] (z){parent}
        child { 
            node[draw] (a) {child0}
            child { 
                node[draw] (c) {grandchild0-0} 
            }
            child { 
                node[draw] (d) {grandchild0-1} 
            }   
            child { 
                node[draw] (e) {grandchild0-2} 
            }   
            child { 
                node[draw] (f) {grandchild0-3} 
            }   
        }
        child {
            node[draw] (b) {child1}
        }
        child {
            node[draw] (b) {child2}
        }
        child {
            node[draw] (b) {child3}
            child { 
                node[draw] (c) {grandchild3-0} 
            }
            child { 
                node[draw] (c) {grandchild3-1} 
            }
        }
        ;

    \path (z) -- (a);
    \path (z) -- (b);
    \path (a) -- (c);
    \end{tikzpicture}

\end{document}

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.