To answer a question about how to draw family tree on LaTeX-Community.org, I created an example:
\documentclass{minimal}
\usepackage{tikz}
\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=5em}]
% Parents
\coordinate
child[grow=left] {node[man,anchor=east]{Jim}}
child[grow=right] {node[woman,anchor=west]{Jane}}
child[grow=down,level distance=0ex]
[edge from parent fork down]
% Children and grandchildren
child{node[man] {Alfred}
child[grandchild,first] {node[man]{Joe}}
child[grandchild,second] {node[woman]{Heather}}
child[grandchild,third] {node[woman] {Barbara}}}
child{node[woman] {Berta}
child[grandchild,first] {node[man]{Howard}}}
child {node[man] {Charles}}
child {node[woman]{Doris}
child[grandchild,first] {node[man]{Nick}}
child[grandchild,second] {node[woman]{Liz}}};
\end{tikzpicture}
\end{document}
How can this tree be improved? Some things don't seem perfect, such as
- starting with
\coordinate
as root node, - shifting the parent nodes,
- specifying an explicit level distance for the grand children,
- vertical edges are overlapping.
Best Answer
Some marginal improvements can be achieved by setting the width of all the boxes, as I have done below. However, this particular choice of tree-structure (even for an organization chart is difficult to accomodate on an A3 or A4 paper). Imagine the grandchildren spaced horizontally and we are in trouble if we need to grow the tree one further level.
A better approach is to draw such charts as a directory tree. These type of grids are more economical in terms of horizontal spacing. Here is an example drawn using
dirtree
.Since the figure mostly consist of text, the using of boxing is extraneous in the example above, however the
dirtree
can easily be extended to hold tikz nodes rather than text. Another advantage of the above is that in the particular example I have shown in the illustration information was captured in a more intuitive and semantic way,This also permitted automatic recalculation of totals and the production of a summary table. This is perhaps not a full answer, but you are asking to produce a layout which will break in most circumstances. The proper solution is to produce a
dirtree
type solution either withdirtree
or with TikZ following such a pattern.The MWE would produce the image above.