2

I'm trying to use the forest package to draw adjacent trees. My problem is that the trees are too close to each other.

\documentclass[border=10pt]{standalone}
\usepackage{forest}
\begin{document} 
\begin{forest}
for tree={grow=north}
[$a+b\cdot c$
    [$\oplus$
        [$b\cdot c$
        ]
        [$a$
        ]
    ]
]
\end{forest}
\begin{forest}
for tree={grow=north}
[$a+b\cdot c$
    [$\oplus$
        [$\otimes$
            [$c$]
            [$b$]
        ]
        [$a$
        ]
    ]
]
\end{forest}
\end{document}

On the other hand the following code doesn't generate two adjacent trees, but only the node a.

\documentclass[border=10pt]{standalone}
\usepackage{forest}
\begin{document}
\begin{forest}
for tree={grow=north}
[a
]
[b
]
\end{forest}
\end{document}

How can I draw adjacent trees?

9
  • try to insert \hfil or \hfill between forest trees: \end{forest}\hfil\begin{forest}
    – Zarko
    Mar 21, 2017 at 18:36
  • @Zarko works like a charm!
    – Arrow
    Mar 21, 2017 at 18:47
  • then we can consider question solved by comment?
    – Zarko
    Mar 21, 2017 at 19:02
  • @Zarko I would like to wait a few hours - perhaps someone will show me how to create such diagrams with forest. Is that okay?
    – Arrow
    Mar 21, 2017 at 19:06
  • OK, i will not take any action. About forest diagram, this is not clear what you expect. To have all trees on one image?
    – Zarko
    Mar 21, 2017 at 19:09

1 Answer 1

2

Only one tree is permitted in any forest, whose name is hopelessly misleading. You can have many trees with Forest, but only one in each forest. That is, a forest of trees requires many forests.

If you really want multiple trees in a forest, you can wrap them in a tree shell with a phantom root.

\documentclass[border=10pt]{standalone}
\usepackage{forest}
\begin{document}
\begin{forest}
  for tree={grow=north}
  [, phantom, fit=band
    [$a+b\cdot c$
      [$\oplus$
          [$b\cdot c$
          ]
          [$a$
          ]
      ]
    ]
    [$a+b\cdot c$
      [$\oplus$
          [$\otimes$
              [$c$]
              [$b$]
          ]
          [$a$
          ]
      ]
    ]
  ]
\end{forest}
\end{document}

fake tree for <code>forest</code> with two trees i.e. too many

I don't know why you would bother, though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.