有人知道如何将这种垂直目录结构转换为水平目录结构吗?我已经尝试了不同的解决方案,但都没有达到预期的效果。
\documentclass[12pt,a4paper,oneside, ngerman, tikz,multi,dvipsnames,svgnames,x11names]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[textwidth=18cm]{geometry}
\usepackage{import}
\usepackage[edges]{forest}
\begin{document}
\begin{center}
\begin{forest}
my label/.style={
label={[font=\sffamily]right:{#1}},
},
for tree={% addaswyd o gôd Gonzalo Medina: https://tex.stackexchange.com/a/270761/
folder,
font=\sffamily,
text=white,
minimum height=0.75cm,
text width=20mm,
if level=0{fill=ForestGreen}{fill/.wrap pgfmath
arg={SlateBlue#1}{int(4-(mod((level()-1),4)))}},
rounded corners=4pt,
grow'=0,
edge={ForestGreen,rounded corners,line width=1pt},
fit=band,
},
[app
[api
[v1]
]
[core]
[crud]
[database]
[models
[router
[$<$vendors$>$
[$<$models$>$]
]
]
[switch
[$<$vendors$>$
[$<$models$>$]
]
]
]
[schemas]
]
\end{forest}
\end{center}
\end{document}
答案1
我不确定这是否是您想要的,但由于folder
选项的自然方向是向下,因此您需要更改grow'=0
为grow=270
。然后旋转节点,将其添加rotate=-90
到您的for tree
。
for tree={% addaswyd o gôd Gonzalo Medina: https://tex.stackexchange.com/a/270761/
folder,
font=\sffamily,
text=white,
minimum height=0.75cm,
text width=20mm,
if level=0{fill=ForestGreen}{fill/.wrap pgfmath
arg={SlateBlue#1}{int(4-(mod((level()-1),4)))}},
rounded corners=4pt,
grow=270,
rotate=-90,
edge={ForestGreen,rounded corners,line width=1pt},
fit=band,
}