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 am trying to alter the code I made for a family tree using TikZ, by inserting birthdays in a row below a name. Here is the initial code, without the birthday rows, which has a nice output (if someone knows how to post output here, please do so and delete this parenthetical request):

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

  \usetikzlibrary{trees}
  \usetikzlibrary{shapes}


  \begin{document}


  \begin{tikzpicture}
   [-,thick,
    every node/.style={shape=rectangle,inner sep=3pt,draw,thick}]
    \footnotesize
\node {Parent} [edge from parent fork down]
[sibling distance=2cm]
child {node {Child}
[sibling distance=2.2cm]
  child {node {Grandchild 1}}
  child {node {Grandchild 2}}
  child {node {Grandchild 3}}
  }
  ;
\end{tikzpicture}

  \end{document}

I tried to add some second rows with birthdays using the following code between the \begin{document} and \end{document}, but the output looks bad. Connecting lines change or disappear or show up in the wrong place. (If you can post output for the code below, please do so and delete this parenthetical request.)

  \begin{tikzpicture}
   [-,thick,
    every node/.style={shape=rectangle,inner sep=3pt,draw,thick}]
    \footnotesize
\node {Parent} [edge from parent fork down]
[sibling distance=2cm]
    child{node [name=block2, rectangle split, rectangle split parts=2]
      {Child \nodepart{second}1/15/59}
[sibling distance=2.2cm]
 child{node [name=block2, rectangle split, rectangle split parts=2]
      {Grandchild 1\nodepart{second}10/20/80}}
  child{node [name=block2, rectangle split, rectangle split parts=2]
       {Grandchild 2\nodepart{second}2/5/84}}
  child{node [name=block2, rectangle split, rectangle split parts=2]
      {Grandchild 3\nodepart{second}8/9/89}}
}
 ;
 \end{tikzpicture}

Can someone advise how to include the second birthday rows without altering the tree structure from the original code?

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

Using the align= key you can introduce line breaks for the dates:

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

  \usetikzlibrary{trees}
  \usetikzlibrary{shapes}


  \begin{document}


  \begin{tikzpicture}
   [-,thick,
    every node/.style={shape=rectangle,inner sep=3pt,draw,thick,align=center}]
    \footnotesize
\node {Parent\\ 1/15/59} [edge from parent fork down]
[sibling distance=2cm]
child {node {Child\\1/15/59}
[sibling distance=2.2cm]
  child {node {Grandchild 1\\1/15/59}}
  child {node {Grandchild 2\\1/15/59}}
  child {node {Grandchild 3\\1/15/59}}
  }
  ;
\end{tikzpicture}

  \end{document}

enter image description here

share|improve this answer
    
This works very nicely (and simply). I had tried using \\ before to create a new line, but I wasn't using an align= command so the \\ wasn't working. Thanks! –  KCd Sep 29 '12 at 1:20
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.