family-tree.tex 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. \documentclass[varwidth=true, border=2pt]{standalone}
  2. \usepackage{xcolor}
  3. \usepackage{tikz}
  4. \usetikzlibrary{trees}
  5. \def\name#1{\hbox to 50pt{#1\rule{10pt}{0pt}}}
  6. \begin{document}
  7. \begin{tikzpicture}[
  8. man/.style={rectangle,draw,fill=gray!30},
  9. woman/.style={rectangle,draw,fill=gray!10},
  10. grandchild/.style={grow=down,xshift=1em,anchor=west,
  11. edge from parent path={(\tikzparentnode.south) |- (\tikzchildnode.west)}},
  12. first/.style={level distance=6ex},
  13. second/.style={level distance=12ex},
  14. third/.style={level distance=18ex},
  15. level 1/.style={sibling distance=70pt}]
  16. % Parents
  17. \coordinate
  18. child[grow=left] {node[man,anchor=east]{\name{Jim}}}
  19. child[grow=right] {node[woman,anchor=west]{\name{Jane}}}
  20. child[grow=down,level distance=0ex]
  21. [edge from parent fork down]
  22. % Children and grandchildren
  23. child{node[man] {\name{Alfred}}
  24. child[grandchild,first] {node[man]{\name{Joe}}}
  25. child[grandchild,second] {node[woman]{\name{Heather}}}
  26. child[grandchild,third] {node[woman] {\name{Barbara}}}}
  27. child{node[woman] {\name{Berta}}
  28. child[grandchild,first] {node[man]{\name{Howard}}}}
  29. child {node[man] {\name{Charles}}
  30. child[grandchild,first] {node[man]{\name{Howard}}}}
  31. child {node[woman]{\name{Doris}}
  32. child[grandchild,first] {node[man]{\name{Nick}}}
  33. child[grandchild,second] {node[woman]{\name{Liz}}}};
  34. \end{tikzpicture}
  35. \end{document}