[Tex/LaTex] Example of matrix node in trees in tikzpicture

matricestikz-pgftikz-trees

I'm trying to recreate this image

enter image description here

using tikz matrices in a tree. I can create the first node and can hook up to children, but I can't get the syntax for including more matrices as child nodes of the first matrix node. Can anyone give an example of a matrix node as a child in a tikzpicture?

Best Answer

Here is one option that you can further modify:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{trees,matrix}
\begin{document}
\begin{tikzpicture}[level distance=2cm,
  level 1/.style={sibling distance=2cm}]
  \node[matrix,matrix of nodes,ampersand replacement=\&] {root \& beer\\is \& good\\}
    child {
        node[matrix,matrix of nodes,ampersand replacement=\&] {first \& row \\another \& row\\} 
  child {node {Write}}
  child {node {Wright}}
}
    child {node {right}};
\end{tikzpicture}
\end{document} 

enter image description here

I had some difficulty with the ampersand in QTikZ environment so I changed it to something else for next column trigger. It might not be needed for other media.

Related Question