# A drawing issue regarding the forest package and tikz

I provide the following MWE regarding the construction of a semantic tableaux for modal logic.

\documentclass[a4paper,twoside,10pt]{memoir}
\usepackage{alphabeta}
\usepackage {tikz}
\usepackage {forest}
\usetikzlibrary {positioning,graphs}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{amsthm}
\usepackage{mathtools}
\begin{document}

\begin{forest}
[$F(\Box A\wedge\Box B)\rightarrow\Box(A\wedge B)$, name=root, tikz={\node [draw,red,fit=(!1)(!ll)] {};}
[ $T(\Box A\wedge\Box B)$, name=nodeA [ $F\:\Box(A\wedge B)$, name=nodeB, tikz={\node [draw,red,fit=(!1)(!ll)] {};}
[ $T\Box A$, name=nodeC [ $T\:\Box B$, name=nodeD [ $F(A\wedge B)$, name=nodeE
[ $FA$, rectangle, draw [ $TA$, rectangle, draw, name=nodeF [ $\otimes$ ] ] ]
[ $FB$, rectangle, draw [ $TB$, rectangle, draw, name=nodeG [ $\otimes$ ] ] ] ] ] ] ] ] ]
\draw[->] (nodeA) to [out=west, in=west] (nodeC);
\draw[->] (nodeB) to [out=east, in=east] (nodeE);
\end{forest}
\end{document}


I need to improve the drawing of the arrows .. the main issue, is to use the nodes enclosed in the second rectangle as a single (virtual) node, and draw the tip (namely, the end) of the left arrow (starting from the second node), in the middle of the left vertical side of the second rectangle ... it would also be great, if the arrows did not intersect the borders of the rectangles (but this is a secondary and not so important issue)..

I did not precisely know how to read your question so I added a second possible interpretation in blue, hoping one of them is what you're after.

\documentclass[a4paper,twoside,10pt]{memoir}
\usepackage{alphabeta}
\usepackage {tikz}
\usepackage {forest}
\usetikzlibrary {positioning,graphs}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{amsthm}
\usepackage{mathtools}
\begin{document}

\begin{forest}
[$F(\Box A\wedge\Box B)\rightarrow\Box(A\wedge B)$, name=root,
[ $T(\Box A\wedge\Box B)$, name=nodeA [ $F\:\Box(A\wedge B)$, name=nodeB,
[ $T\Box A$, name=nodeC [ $T\:\Box B$, name=nodeD [ $F(A\wedge B)$,
name=nodeE
[ $FA$, rectangle, draw [ $TA$, rectangle, draw, name=nodeF [ $\otimes$ ] ] ]
[ $FB$, rectangle, draw [ $TB$, rectangle, draw, name=nodeG [ $\otimes$ ] ] ] ] ] ] ] ] ]
\node [draw,red,fit=(nodeA)(nodeB)] (fit1) {};
\node [draw,red,fit=(nodeC)(nodeD)] (fit2) {};
\draw[->] (nodeA-|fit1.west) to [out=west, in=west] (nodeC-|fit2.west);
\draw[->] (nodeB-|fit1.east) to [out=east, in=east] (nodeE);
\draw[->,blue] (fit1.west) to [out=west, in=west] (fit2.west);
\draw[->,blue] (fit1.east) to [out=east, in=east] (nodeE);
\end{forest}
\end{document}


• Yes, this is what I want, thanks for your effort. – Athanasios Margaris Oct 18 '18 at 19:26
• Is it possible to remove completely the short vertical line between the nodes in the first red rectangle, and type the strings one after the other? this is useful in some cases and i need it – Athanasios Margaris Oct 19 '18 at 7:52
• I found that I can write the formulas in the same node and then split them in two lines using \\ ... however, they will still belong to the same node .. i want for each formula to be in its own separate node in order to draw some arrows – Athanasios Margaris Oct 19 '18 at 8:28
• @AthanasiosMargaris I am wondering if you want to use forest at all for the upper part of the diagram. And I guess that you are after a TikZ matrix of nodes. Yet I am not sure if it is easy to combine this with forest (seems like no one tried this), but I do not think you need forest for the upper part of the diagram. BTW, according to the rules of the sites you should ask a separate question for this additional request. Asking questions is free, after all. – user121799 Oct 19 '18 at 14:43