Is it possible to avoid hardcoding the \node
position in the below MWE and apply horisontal offset of the Forest node to the TikZ node it links to?
The goal is to put the green nodes as close as possible to right above the linked Forest node, but at the same time try not to overlap other Forest nodes. The vertical position will have to be hardcoded.
\documentclass{standalone}
\usepackage{forest}
\begin{document}
\begin{forest}
for tree={
draw=black, align=center, l sep=4ex, parent anchor=south, child anchor=north,
node options={font=\footnotesize, minimum width=14em, minimum height=10ex},
edge path={
\noexpand\path[\forestoption{edge}]
(!u.parent anchor) -- +(0,-2ex) -| (.child anchor)\forestoption{edge label};
}
}
[Parent
[SubParent
[Child1
[Child11]
[Child12,name=Child12]
]
[Child2
[Child21]
[Child22]
[Child23,name=Child23]
]
[Child3
[Child31]
[Child32]
]
]
]
%
\tikzset{every node/.style={font=\footnotesize, draw=green, minimum width=14em, minimum height=10ex}}
%
\node[anchor=south,draw=green](Second1) at (-30em, -15ex) {Second Parent 1}[];
\node[anchor=south,draw=green](Second2) at (15em, -15ex) {Second Parent 2}[];
%
\draw[->,dotted] (Child12) to[out=north east,in=south] (Second1);
\draw[->,dotted] (Child23) to[out=north east,in=south] (Second2);
\end{forest}
\end{document}
\usetikzlibrary{positioning}
, and instead ofat (...)
add the keyabove=3cm of Child12
to the node options.