[Tex/LaTex] Draw directory tree using folder icons

directoryfolders

I need to create a figure like the following one
image

An image shows a directory tree using folders icons. What do you suggest me to do?

Best Answer

Here's one possibility using forest and TikZ:

enter image description here

The code:

\documentclass{article}
\usepackage{forest}

\definecolor{fblue}{RGB}{92,144,192}
\definecolor{fgreen}{RGB}{34,162,70}

\newcommand\myfolder[2][fblue]{%
\begin{tikzpicture}[overlay]
  \draw[fill=#1!82!black] 
    (-20pt,14pt) -- 
    (-17pt,17pt) --
    (-1pt,17pt) --
    (1pt,19pt) --
    (12pt,19pt) --
    (14pt,17pt) --
    (17pt,17pt) --
    (20pt,14pt) -- cycle;
  \draw[line width=0.75pt,white] 
    (-18.5pt,14pt) -- 
    (-15.5pt,16.5pt) --
    (0.5pt,16.5pt) --
    (2pt,18.3pt) --
    (10.5pt,18.3pt) --
    (12.5pt,16.5pt) --
    (15.5pt,16.5pt) --
    (18.5pt,14pt) -- cycle;
  \draw[rounded corners,top color=#1,bottom color=#1!30] 
    (-23pt,14pt) -- 
    (23pt,14pt) --
    (21pt,-14pt) --
    (-21pt,-14pt) -- cycle;
  \draw[rounded corners,line width=1pt,white] 
    (-22pt,13pt) -- 
    (22pt,13pt) --
    (20pt,-13pt) --
    (-20pt,-13pt) -- cycle;
\end{tikzpicture}%
\makebox[0pt]{\raisebox{-3pt}{{\ttfamily\small/#2}}}%
}


\begin{document}

\begin{forest}
for tree={
  parent anchor=south,
  child anchor=north,
  node options={inner sep=11pt},
  l sep=25pt,
  s sep=40pt,
} 
[\myfolder{}
  [\myfolder{bin}]
  [\myfolder{dev}]
  [{\myfolder[fgreen]{home}}
    [{\myfolder[fgreen]{anna}}]
    [{\myfolder[fgreen]{claudio}}]
  ]
  [\myfolder{media}]
  [\myfolder{mnt}]
  [\myfolder{usr}]
]
\end{forest}

\end{document}

The command \myfolder has one mandatory argument for the label of the folder and an optional argument for the color.