I currently have a Forest binary tree as follows:
This is produced by the code:
% Adapted from https://tex.stackexchange.com/questions/425238/horizontal-probability-tree-using-forest-with-edge-labels
\documentclass{standalone}
\usepackage{standalone}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
\usepackage{xcolor}
\usepackage{forest}
\usepackage{amsmath}
\usepackage{MnSymbol}
\usepackage{commath}
\forestset{
ptree/.style={
for tree={
grow'=0,
parent anchor=children,
child anchor=parent,
l=2.4cm,
s sep=0.5cm,
fit=rectangle
},
before typesetting nodes={
for tree={
split option={content}{:}{content, my edge label},
},
},
},
my edge label/.style={
if={
> O_= {n'}{1}
}{
edge label={node [midway, fill=white, font=\color{red}\footnotesize] {#1} }
}{
edge label={node [midway, fill=white, font=\color{red}\footnotesize] {#1} }
},
}
}
\begin{document}
\begin{forest}
ptree
[1
[2: 1
[1: 1
[2: 1
[{(1,-1)}: 1]
]
[{(-1,1)}: 2]
]
[1: 2
[{(-1,1)}: 1]
]
]
[2: 2
[1: 1
[{(-1,1)}: 1]
]
[{(1,-1)}: 2]
]
]
\end{forest}
\end{document}
This is perfect for what I need it do, except I’m hoping to pushed dashed ellipses encompassing arbitrary ellipses, often with multiple in the same tree. I put an example of what I mean below.
As well, to make it easier to code rapidly (since I’m using this for lecture notes), I was hoping to simply modify the forest tree to look like:
\begin{forest}
ptree
[1
[2: 1
[1: 1: A
[2: 1
[{(1,-1)}: 1]
]
[{(-1,1)}: 2]
]
[1: 2: A
[{(-1,1)}: 1]
]
]
[2: 2: B
[1: 1: B
[{(-1,1)}: 1]
]
[{(1,-1)}: 2]
]
]
\end{forest}
where A
and B
will be used to designate two separate ellipses. As well, occasionally, these ellipses may encompass three or more nodes, so I am hoping they can expand as needed.
Any help changing the \forestset
would be very much appreciated!