森林-水平目录结构

森林-水平目录结构

有人知道如何将这种垂直目录结构转换为水平目录结构吗?我已经尝试了不同的解决方案,但都没有达到预期的效果。

\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'=0grow=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,
      }

相关内容