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 would create a simple picture of a small websitestructure and i found these nice example http://www.texample.net/tikz/examples/family-tree/.

But I would change some things and I don't know if it is possible.

  • Is it possible to create a direct line between Jim and the next line?
  • And is it also possible to get a direct line from Alfred to Step Two and then from Step Two to Step Three.

I also don't, know why the box of the Steps will be bigger as the other one.

I'm happy if someone had an answer. Thanks for your help.

Kind Regards

Here is the example:

    % A family tree
% or: an organisational chart
% Author: Stefan Kottwitz , http://texblog.net
\documentclass{article}
\usepackage{tikz}
%%%<
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%
%%%>
\begin{comment}
:Title: A family tree
:Tags: Styles; Trees; Charts
:Author: Stefan Kottwitz
:Slug: family-tree

Posted for discussing and improving on http://tex.stackexchange.com/q/39696/213
\end{comment}

\usetikzlibrary{trees}
\begin{document}
\begin{tikzpicture}[
  man/.style={rectangle,draw,fill=blue!20},
  woman/.style={rectangle,draw,fill=red!20,rounded corners=.8ex},
  grandchild/.style={grow=down,xshift=1em,anchor=west,
    edge from parent path={(\tikzparentnode.south) |- (\tikzchildnode.west)}},
  first/.style={level distance=6ex},
  second/.style={level distance=12ex},
  third/.style={level distance=18ex},
  level 1/.style={sibling distance=7em}]

    % Parents
    \coordinate
    child[grow=left] {node[man,anchor=east]{Jim}}
    child[grow=down,level distance=0ex]
    [edge from parent fork down]

    % Children and grandchildren
    child{node[man] {Alfred}
        child[grandchild,first] {node[man]{Step Two}
            child[grandchild,first] {node[man]{Step Three}
                child[grandchild,first] {node[man]{Step Four}
                }
            }
        }
    }
    child{node[man] {Berta}
    child[grandchild,first] {node[man]{Howard}}}
    child {node[man] {Charles}}
    child {node[man]{Doris}
    child[grandchild,first] {node[man]{Nick}}
    child[grandchild,second] {node[man]{Liz}}};
\end{tikzpicture}
\end{document}
share|improve this question
add comment

1 Answer

I am not sure if this is what you want:

\documentclass{article}
\usepackage{tikz}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%
\usetikzlibrary{trees}

\begin{document}
\begin{tikzpicture}[
  every node/.style={text width=2cm,align=center},
  man/.style={rectangle,draw,fill=blue!20},
  woman/.style={rectangle,draw,fill=red!20,rounded corners=.8ex},
  grandchild/.style={grow=down,xshift=1em,anchor=west,
    edge from parent path={(\tikzparentnode.south) |- (\tikzchildnode.west)}},
  first/.style={level distance=6ex},
  second/.style={level distance=12ex},
  third/.style={level distance=18ex},
  level 1/.style={sibling distance=7em}]

    % Parents
    \node[man]{Jim}
    [edge from parent fork down]

    % Children and grandchildren
    child{node[man] {Alfred}
        child[first] {node[man]{Step Two}
            child[first] {node[man]{Step Three}
                child[first] {node[man]{Step Four}
                }
            }
        }
    }
    child{node[man] {Berta}
    child[grandchild,first] {node[man]{Howard}}}
    child {node[man] {Charles}}
    child {node[man]{Doris}
    child[grandchild,first] {node[man]{Nick}}
    child[grandchild,second] {node[man]{Liz}}};
\end{tikzpicture}
\end{document}

enter image description here

The first node was originally a child, I changed it to be the root of the tree. I removed the grandchild (which introduces a horizontal shift) option for the nodes "Step Two", "Step Three" and "Step Four". By default, each node width will be the natural width of its content (plus some padding), to change this, I declared a fixed common width for the nodes using the text width key for the every node style.

Detailed information about trees can be found in the PGF manual. The tikz-qtree package could also be of interest.

share|improve this answer
    
Thank you very much Gonzalo Medina. This is exactly what i need. –  Peter Jul 30 '12 at 12:58
    
@Peter You're welcome! Around here, we usually thank someone by up-voting his/her answer (with the upward pointing arrow to the left of it; you need 15 reputation points before you can up-vote) and accepting it (in case of doubt, please see How do you accept an answer?.) –  Gonzalo Medina Jul 30 '12 at 14:53
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.