如何在“森林”中勾勒轮廓?

如何在“森林”中勾勒轮廓?

在此处输入图片描述

我想制作如图所示的轮廓。我重用了其中一个可用模板。代码如下:

\documentclass[tikz,border=10pt]{standalone}
\usepackage[edges]{forest}
\usetikzlibrary{shadows}
\tikzset{every shadow/.style={shadow xshift=5pt,shadow yshift=-5pt}}
\begin{document}

\begin{forest}
  forked edges,
  for tree={
            l sep+=10pt,
             grow'=east,
              drop shadow,
            font=\sffamily, rounded corners, top color=gray!25, bottom color=gray!10, edge+={darkgray, line width=1pt}, draw=darkgray, align=center, anchor=children},
  before packing={where n children=3{calign child=2, calign=child edge}{}},
  before typesetting nodes={where content={}{coordinate}{}},
  where level<=0{line width=2pt}{line width=1pt},
  [\textbf{Outline}, 
     [Section 1
     [Subsection 1.1]
     [Subsection 1.2]
     ]
        [Section 2
        [Subsection 2.1
        [Subsection 2.1.1]
        ]
        [Subsection 2.2
        [Subsection 2.2.1]
        ]
        ]
          [Section 3
          [Subsection 3.1]
          [Subsection 3.2]
     ]
      ] 
    ]
    ]
     ]
\end{forest}
\end{document}

有人可以指导我如何修改类似于图像的 LaTeX 代码吗?

答案1

也许你想要的是folder风格。唯一棘手的部分是断开大纲节点与 Section 节点的距离。这需要调整edge path与初始点的偏移。

在此处输入图片描述

\documentclass{article}
\usepackage[edges]{forest}

\begin{document}
    \begin{forest}
    for tree={
        font=\sffamily,
        s sep=1mm,
        l sep=8mm,
        folder,
        grow'=east,
        edge=-stealth,
        if level=1
            {draw, rounded corners, minimum height=8mm, minimum width=2cm,
                edge path={\noexpand\path [draw, \forestoption{edge}]([shift={(\forestregister{folder indent},-1)}]!u.south west)  |- (.child anchor);}}
            {}
    }
[\textbf{Outline}
    [Section 1      
        [Subsection 1.1]
            [Subsection 1.2]
    ]
    [Section 2
        [Subsection 2.1
            [Subsection 2.1.1]
        ]
        [Subsection 2.2
            [Subsection 2.2.1]
        ]
    ]
    [Section 3
        [Subsection 3.1]
        [Subsection 3.2]
    ]
] 
\end{forest}
\end{document}

相关内容