2

I would like to add a file structure to my document and be able to add a description to each directory/file. From another Question I got the file structure like this:

\usepackage{forest}

\begin{document}
\begin{forest}
    for tree={
        font=\ttfamily,
        grow'=0,
        child anchor=west,
        parent anchor=south,
        anchor=west,
        calign=first,
        edge path={
            \noexpand\path [draw, \forestoption{edge}]
            (!u.south west) +(7.5pt,0) |- node[fill,inner sep=1.25pt] {} (.child anchor)\forestoption{edge label};
        },
        before typesetting nodes={
            if n=1
            {insert before={[,phantom]}}
            {}
        },
        fit=band,
        before computing xy={l=15pt},
    }
    [text1
        [text1.1
            [text1.1.1 ... Here goes a description that could be multiple lines long]
            [some\_random\_file.txt ... This description is not aligned with the description above]
        ]
    ]
\end{forest}
\end{document}

There are two problems with my approach (just adding three dots and then the description)

The first is that when a description is to long it just continues the line instead of going into the next line.

The second is that descriptions are not alligned with each other. I tried to use \tabto but this doesn't seem to work.

Does anyone knows how to fix any of those problems or knows another was to make this look nice?

Ian Fako
  • 169
  • 6

1 Answers1

0

like this?

enter image description here

\documentclass{article}
    \usepackage{justtrees}% v 0.07
    \usetikzlibrary{arrows.meta}
    \useforestlibrary{edges}
    \forestapplylibrarydefaults{edges}

\begin{document}
{
\tikzset{lbl/.style={text width=16em, align=left,
                     xshift=12pt, yshift=1ex, inner ysep=0pt,
                     font=\linespread{0.84}\selectfont,
                     anchor=north west}}

\begin{forest}
    for tree={
        font=\ttfamily,
        anchor=west,
        grow'=0,
        s sep+=13pt,  % 7pt if descritons has only 2 lines
        calign=first,
        edge path={
            \noexpand\path [draw, \forestoption{edge}]
            (!u.south west) +(7.5pt,0) |- node[fill,inner sep=1.25pt] {} (.child anchor)\forestoption{edge label};
        },
        before typesetting nodes={
            if n=1
            {insert before={[,phantom]}}
            {}
        },
        fit=band,
        before computing xy={l=15pt},
    }
    [text1
        [text1.1,
            [text1.1.1, name=A]
            [some\_random\_file.txt,name=B]
        ]
    ]
\node[lbl] at (A-|B.east) {Here goes a description that could be multiple lines long long long long long long long long long long};
\node[lbl] at (B.east)    {This description is not aligned with the description above};
\end{forest}

\end{document}

Note: this solution need some manual tweak. If you have description longer or shorter than three lines, you need to change s sep+ accordingly (increase/shortened).

Zarko
  • 296,517