森林の水平および垂直のツリー構造を持つ

森林の水平および垂直のツリー構造を持つ

フォルダー/ファイル構造の図を作成しようとしています。問題は、サブフォルダーに多数のファイルがあるため、非常に長い図が作成されることです。

MWE:

\documentclass[border=5pt]{standalone}
\usepackage[edges]{forest}

\definecolor{folderbg}{RGB}{124,166,198}
\definecolor{folderborder}{RGB}{110,144,169}

\def\Size{4pt}
\tikzset{
  folder/.pic={
    \filldraw[draw=folderborder,top color=folderbg!50,bottom color=folderbg]
      (-1.05*\Size,0.2\Size+5pt) rectangle ++(.75*\Size,-0.2\Size-5pt);  
    \filldraw[draw=folderborder,top color=folderbg!50,bottom color=folderbg]
      (-1.15*\Size,-\Size) rectangle (1.15*\Size,\Size);
  }
}

\begin{document}
\begin{forest}
  for tree={
    font=\ttfamily,
    grow'=0,
    child anchor=west,
    parent anchor=south,
    anchor=west,
    calign=first,
    inner xsep=7pt,
    forked edges,
    edge path={
        \noexpand\path [draw, \forestoption{edge}]
        (!u.south west) +(7.5pt,0) |- (.child anchor) pic {folder} \forestoption{edge label};
    },
    before typesetting nodes={
        if n=1
        {insert before={[,phantom]}}
        {}
    },
    fit=band,
    before computing xy={l=15pt},
  }  
[Main Folder
  [subfolder 1
    [subsubfolder 1
      [file
      ]
    ]
    [subsubfolder 2
      [file
      ]
    ]
    [file
    ]
 ]
 [subfolder 2
 ]
 [subfolder 3
 ]
 [subfolder 4
 ]
]
\end{forest}
\end{document}

これによって次のものが生成されます:

ここに画像の説明を入力してください

上の図のように、各トップレベルのサブフォルダを水平に分岐し、サブフォルダ内の残りの構造を垂直にする方法はありますか? 例:

図

アップデート

@js bibraの回答を使用して行を変更しました

grow'=0,

に:

where level=0{
    l sep'=0.1cm,
    s sep'=0.5cm,
}{
    grow'=0,
},

参考までに、私の完全な図は次のようになります。 ここに画像の説明を入力してください

これは私が達成したいことにかなり近いです。水平方向の間隔を減らして、枝を親に対して中央に配置する方法はありますか?

答え1

これがあなたが探しているものですか

ここに画像の説明を入力してください

\documentclass[border=10pt]{standalone}
\usepackage[edges]{forest}
\usetikzlibrary{shadows,arrows.meta}
\tikzset{
  parent/.style={align=center,text width=4cm,fill=gray!50,rounded corners=2pt},
  child/.style={align=center,text width=2.5cm,fill=gray!20,rounded corners=6pt},
  grandchild/.style={fill=white,text width=2.3cm}
}
\begin{document}
\begin{forest}
  for tree={%
    thick,
    drop shadow,
    node options={
      draw,
      font=\sffamily
    },
    edge={
      semithick,
      -Latex
    },
    where level=0{
      parent,
      l sep'=0.8cm,
      s sep'=1.0cm,
    }{
      folder,
      grow'=0,
    },
    where level=1{
      minimum height=1cm,
      child,
      l sep=7.5mm,
      for descendants={%
        grandchild,
        minimum height=0.6cm,
      },
      for children={
        before computing xy={s+=5mm},
      }
    }{},
  }
  [\large Long text with line break%
    [\textbf{Test 1} \\ with a lot of subtext%
      [Topic]
      [Long topic with line break]
      [Topic]
    ]
    [\textbf{Test 2} \\ with a lot of subtext%
      [Topic]
      [Long topic with line break]
      [Topic]
    ]
    [\textbf{Test 3} \\ with a lot of subtext%
      [Topic]
      [Long topic with line break]
      [Topic]
    ]
    [\textbf{Test 4} \\ with a lot of subtext%
      [Topic]
      [Long topic with line break]
      [Topic]
    ]
  ]
\end{forest}
\end{document}

関連情報