如何对齐森林包中某些级别的边缘?

如何对齐森林包中某些级别的边缘?

我有一个两列的文档并创建了以下树:

在此处输入图片描述

如您所见,第三级与另一列的文本重叠。为了解决这个问题,我想将子节点Hotel1234567890Golf12345略高于其父节点,将Lima12345678Kilo12345略低于父节点,以有效利用空白空间。

理想的最终结果应该是这样的:

结果

代码:

\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}

我认为可以通过为这两种特殊情况创建两种新的边缘样式来解决此问题。但是,我不确定需要如何edge path设计才能满足这些要求。

答案1

像这样:

\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}

在此处输入图片描述

相关内容