I'm constructing a tree diagram using the forest
package, and I want to label the edges.
Usually, Tikz is quite good at avoiding a collision between the label and the edge, but if the branches of my tree are forced to spread out too much then the label starts to overlap the edge.
Is there a way of manually offsetting the labels I've added?
Or perhaps there is a way of getting the labels to interrupt the edge, much like the description
option for labels in tikzcd?
\documentclass[a4paper,10pt]{article}
\usepackage{tikz}
\usepackage{forest}
\begin{document}
\begin{forest}
for tree={grow'=north}
[A
[B, edge label={node[midway,left,font=\scriptsize]{1}} [] [] [] [] [] [] [] [] [] []]
[C, edge label={node[midway,left,font=\scriptsize]{2}} [] [] [] [] [] [] [] [] [] []]
]
\end{forest}
\end{document}
Best Answer
You can use
auto
instead of `left:Or use
above
:Or
below
There is also
above left
above right
below right
above=2mm
below=1cm
etc. Choose whatever you like.If you want the labels to interrupt the edges, remove
left
or whatever you are using and usefill=white