This is my current scenario: I have two trees with defined with forest
, side by side, each one inside a minipage
:
\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{fit}
\usepackage{forest}
\begin{document}
\begin{minipage}{0.3\textwidth}
\begin{forest}
[a
[b
[c]
[d]
]
[e,draw,dashed]
]
\end{forest}
\end{minipage}%
\begin{minipage}{0.3\textwidth}
\begin{forest}
[f
[g]
[,phantom]
[h,tikz={\node [draw,dashed,fit=() (!1) (!l)] {};}
[i]
[j]
]
]
\end{forest}
\end{minipage}
\end{document}
So far, so good!
Now I want to link node e
from tree 1 with node h
from tree 2. Now things started to get frustrating. I tried to give these nodes a proper name and apply remember picture
, but it seems the names are not persisted between environments (it's worth mentioning that Alan provided an alternative solution by using only one tree mimicking two trees here; it solves my immediate problem, but I am still interested in seeing how a proper link would be).
My searches in TeX.sx indicated tikzmark
as the easiest, most direct solution, so here we go. I found a promising solution by Adam Liter here:
Using tikz overlay / remember picture option with forest trees
Sadly, it seems there were some updates in perhaps everything in the TeX world that made my trees collapse into a accident of nightmarish proportions and whatnot:
Package tikz Error: Cannot parse this coordinate.
The answer provided in the linked question does not work anymore, and neither does my code. So I beseech your wisdom! Tying a yellow ribbon 'round the old forest
tree seems simple enough, however, my plans of creating a potential hammock between two independent forest
trees have been shattered. :)
Does anybody have an idea of what is broken?
:)
I've also updated my answer accordingly.\subnode
is the best I can think of right now.