How to draw the directory tree image shown below, indicating folders and files?
To draw the folder tree I used the code from Making a (simple) directory tree, but there is no obvious option to include files, and I therefore edited the image in Inkscape, as indicated in red.
The replicated code from Gonzalo Medina post (Making a (simple) directory tree) is shown below
\documentclass[border=5pt]{standalone}
\usepackage{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,
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},
}
[system
[config
]
[lib
[Access
]
[Plugin
]
]
[templates
]
[tests
]
]
\end{forest}
\end{document}
Best Answer
You can create a
style
for your file node like thisCode