0

I have a two-column document and created the following tree:

enter image description here

As you can see, the third level overlaps with the text of the other column. To address this issue, I want to place the children Hotel1234567890 and Golf12345 slightly above their parent node and Lima12345678 and Kilo12345 slightly below the parent node to efficiently use the empty space.

The ideal end result would be something like this:

result

Code:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{forest}

\title{Bla}
\author{John Doe}
\date{April 2020}

\begin{document}

\maketitle

\begin{figure} 
    \centering  
    
    \begin{forest}
    for tree={
      grow=east,
      parent anchor=east,
      child anchor=west,
      align=center,
      l=1em, l sep+=0em,anchor=base west,inner sep=0.1pt,outer sep=0pt,
       edge path={
                \noexpand\path [draw, \forestoption{edge}] (!u.parent anchor) -- +(5pt,0) |- (.child anchor)\forestoption{edge label};
            },
      for root={
        parent anchor=east,
      },
    }
    [Main BLA,rotate=90,child anchor=north, parent anchor=south, anchor=center
      [Quebec1234
            [Romeo
                ]
            [Sierra
                ]
      ]
      [Papa123456789]
      [Oscar1234567]
      [Juliet 123 45679
        [November123
            [Kilo12345]
                [Lima12345678]
        ]
        [Mike12345]
      ]
      [Alpha123
          [India12345]
          [Foxtrot1234567891
            [Golf12345]
            [Hotel1234567890]
          ]
          [Echo123456]
          [Delta12345]
          [Charlie123]
          [Bravo12345]
     ]
    ]
  \end{forest}
    \caption{Blah}
    \label{fig:bla}
\end{figure}

\end{document}

I think this can be solved by creating two new edge styles specifically for the two special cases. However, I am not sure how the edge path needs to be designed to accommodate these requirements.

1 Answer 1

2

Like this:

\documentclass[twocolumn]{article}
\usepackage{showframe}
\usepackage{lipsum}
\usepackage{forest}

\begin{document}
\lipsum[1-2]
\begin{figure} 
\centering  
\begin{forest}
    for tree={
      grow=east,
      parent anchor=east,
      child anchor=west,
      align=center,
      l=1em, l sep+=0em,anchor=base west,inner sep=0.1pt,outer sep=0pt,
       edge path={
                \noexpand\path [draw, \forestoption{edge}] (!u.parent anchor) -- +(5pt,0) |- (.child anchor)\forestoption{edge label};
            },
      for root={
        parent anchor=east,
      },
    }
    [Main BLA,rotate=90,child anchor=north, parent anchor=south, anchor=center
      [Quebec1234
            [Romeo
                ]
            [Sierra
                ]
      ]
      [Papa123456789]
      [Oscar1234567]
      [Juliet 123 45679
        [November123,parent anchor=-165
            [Kilo12345,edge path={
                \noexpand\path [draw, \forestoption{edge}] (!u.parent anchor) |- +(5pt,-20pt) |- (.child anchor)\forestoption{edge label};
            },before drawing tree={x-=52pt,y-=25pt}]
            [Lima12345678,edge path={
                \noexpand\path [draw, \forestoption{edge}] (!u.parent anchor) |- +(5pt,-20pt) |- (.child anchor)\forestoption{edge label};
            },before drawing tree={x-=52pt,y-=25pt}]
        ]
        [Mike12345]
      ]
      [Alpha123
          [India12345]
          [Foxtrot1234567891,parent anchor=20
            [Golf12345,edge path={
                \noexpand\path [draw, \forestoption{edge}] (!u.parent anchor) |- +(5pt,20pt) |- (.child anchor)\forestoption{edge label};
            },before drawing tree={x-=25pt,y+=28pt}]
            [Hotel1234567890,edge path={
                \noexpand\path [draw, \forestoption{edge}] (!u.parent anchor) |- +(5pt,20pt) |- (.child anchor)\forestoption{edge label};
            },before drawing tree={x-=25pt,y+=28pt}]
          ]
          [Echo123456]
          [Delta12345]
          [Charlie123]
          [Bravo12345]
     ]
    ]
\end{forest}
\caption{Blah}
\label{fig:bla}
\end{figure}
\lipsum[3-5]
\end{document}

enter image description here

1
  • Perfect! Thank you so much.
    – John Doe
    Commented Jun 16, 2022 at 18:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .