创建有吸引力的目录树 - dirtree 的替代品

创建有吸引力的目录树 - dirtree 的替代品

我已经找到了类似问题从而知道目录树包。但是,结果看起来不太好。

我还想将树放在图形环境中并使其居中。这根本行不通,因为只有文本居中,而不是树结构

\begin{figure}
  \centering
  \dirtree{%
    .1 spam.
    .2 ham.
    .2 eggs.
    .3 more spam.
    .3 dead parrots.
  }
  \caption[Directory Structure]{This is an example directory structure.}
  \label{fig:dir}
\end{figure}

有没有更好的方法来创建文件系统可视化?

答案1

Tikz 树更复杂,但允许微调:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{trees}
\begin{document}
\tikzstyle{every node}=[draw=gray, very thick,anchor=west]
\begin{tikzpicture}[%
  grow via three points={one child at (0.5,-0.7) and %
  two children at (0.5,-0.7) and (0.5,-1.4)},%
  edge from parent path={(\tikzparentnode.south)%
  |- (\tikzchildnode.west)}]
\node {root}
    child { node {spam}}     
    child { node {ham}}
    child { node {eggs}
       child {node {more spam} }
      child { node {dead parrots}}}
    child [missing] {}              
    child [missing] {}              
    child [missing] {}              
    child { node {peanuts}};  
\end{tikzpicture}
\end{document}

平均能量损失

相关内容