TransWikia.com

Rooted trees with labelled leaves

TeX - LaTeX Asked by ste2239 on April 19, 2021

I am trying to draw something like this

enter image description here

using the forest package:

  1. how do I draw a tree with circles at every node in a way that I can still label the leaves?
  2. is there a way to add dots between branches as in the pic? And curly brackets?

Thank you all in advance!

One Answer

Depending on how many of these you have, this solution may do what you want. Adjusting the position of the brace and its label is a bit of trial and error. I don't know if there's a way to make this more automatic.

documentclass{article}
usepackage{forest}
usetikzlibrary{decorations.pathreplacing,calc}
forestset{solid nodes/.style={for tree={circle,draw,inner sep=1,fill=black}},
            dir/.style={for tree={grow=#1}},
            leaf/.style={label=$#1$},
            mytree/.style={solid nodes, for tree={grow=north,s sep=1cm}}}
begin{document}
begin{forest}mytree
[[
    [,dir=north east
        [,leaf=mu,name=X] [,leaf=mu,name=Y] [,leaf=S_2]
    ]
    [,dir=north west     
         [,dir=north east
            [,leaf=mu_2] [,leaf=mu_1] 
         ]
         [,leaf=S_1]
    ]
]]
draw[dotted] (Y) -- (X);
draw[decorate,decoration={brace,raise=5pt}] ($(Y)+(0,.35)$) -- node [pos=0.8,above=2.5ex] {$e$} ($(X)+(0,.35)$)  ;
end{forest}
end{document}

output of code

Answered by Alan Munn on April 19, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP