below you can see my code of a tree besides a table.
Now I would like to insert some rectangles and ellipses around the nodes. Can someone show me how I can do this. I tried it but it did not work. Thank you!
\documentclass[doc,apacite]{apa}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
%%%%Tikz%%%%%%
\usepackage{tikz}
\usetikzlibrary{trees,matrix,fit}
%%%%%%%%%%%%%%
%%%%Table%%%%%
\usepackage{ctable} % needed for \cmidrule{}
\usepackage{multirow} % needed for \multirow{}
%%%%%%%%%%%%%%
\usepackage{pgfkeys}
\begin{document}
\begin{tikzpicture}[
grow=right,
sloped,
bag/.style={text width=4em, text centered},
end/.style={circle, minimum width=3pt,fill, inner sep=0pt,font=\tiny},
sibling distance=\sibdist,
level 1/.style={level distance=2.0cm},
level 2/.style={level distance=2.5cm},
every node/.style={font=\strut},
]
\node(n){x}
child {
node{U2}
child {
node[label=right:
]{D2} {}
child {node[end, label=right:
{R1}] {}
edge from parent
node[above] {$1-R$}
node[below] {}}
child {node[end, label=right:
{R2}] {}
edge from parent
node[above] {$R$}
node[below] {}}
child[missing]
edge from parent
node[above] {$1-D$}
node[below] {}
}
child {%empty child on level 2
child{
node[end, label=right:
{D1}] {}
edge from parent
node[above] {$D$}
node[below] {}
}
}
child[missing]
edge from parent
node[above] {}
node[below] {$1-u$}
}
child {
node{U1}
child{% empty child on level 2
child{
node[end, label=right:
{$T$}](e) {}
edge from parent
node[above] {}
node[below] {}
}
}
edge from parent
node[above] {$u$}
node[below] {}
};
\matrix[
matrix of nodes,
anchor=m-4-1.west,
xshift=1cm,
nodes={inner xsep=\tabcolsep,minimum height=\sibdist}
](m)at(n-1-1-1){%
c&b&a&c&bd&a\\
a&c&b&a&a&c\\
x&g&f&c&d&b\\%[1cm]
ta&g&a&x&p&d\\
};
\foreach \i in {1,...,6}\node[draw,fit=(m-1-\i) (m-2-\i) (m-3-\i) (m-4-\i),inner sep=-.5\pgflinewidth](c\i){};
\foreach \i in {1,...,3}\draw([yshift=-.5*\sibdist]m-\i-1.center-|c1.west)--([yshift=-.5*\sibdist]m-\i-1.center-|c6.east);
\end{tikzpicture}
\end{document}
\sibdist
in your code. I'm not sure what exactly you mean by "insert rectangles and ellipses around the nodes". If my guess is correct, however, you could try the following: put\usetikzlibrary{shapes}
in the preamble, and add optionsdraw,ellipse
(for ellipse) or simplydraw
(for rectangle) to thenode
commands (in addition toabove
/below
/etc). – Herr K. Jul 25 '14 at 20:43