
폴더/파일 구조에 대한 다이어그램을 만들려고 합니다. 내가 가진 문제는 정말 긴 다이어그램을 생성하는 하위 폴더에 많은 수의 파일이 있다는 것입니다.
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}