0

I'd like to add right align braces, to a directory tree diagram, for explaination but I don't know how to "mix" package command

here are the 2 links

align right braces

making a directory tree of folders and files

in each cases, this is the last solution provided I try to mix

Yes it's exactly what I want but I struggle a big part of the morning trying to add a 4th brace so once again I required your help. Here are my modifications:

[system
  [config, name=config node
  ]
  [lib, name=lib node
  ]
  [Access, name=access node
  ]
  [Plugin, name=plugin node
  ]
  [file.txt, name=file node
  ]
  [templates
  ]
  [tests
  ]
]
\coordinate(top) at (current bounding box.north east);
\coordinate(bot) at (current bounding box.south east);
\draw[mybrace] (top)--node[right=2mm]{Explanation 1}(top|-lib node.south)coordinate(A);
\draw[mybrace] (A)--node[right=2mm]{Explanation 2}([yshift=-1mm]top|-file node.south)coordinate(B);
\draw[mybrace] (B)--node[right=2mm]{Explanation 3}([yshift=-1mm]top|-file node.south)coordinate(C);
\draw[mybrace] (C)--node[right=2mm]{Explanation 4}(bot);

and the result:

  • Where do you want the 4th brace? Right now your coordinates (B) and (C) are in the same place, so your brace from (B) to (C) is just a point. – Sandy G Dec 12 '22 at 14:45
  • I thought adding name=XXX node after an element of the tree, where XXX is the element name, make a point where begin and finish braces. So i try to regroup system with config, lib with Access, Plugin with file and templates with tests. and then adding \draw[mybrace] (B)--node[right=2mm]{Explanation 3}([yshift=-1mm]top|-file node.south)coordinate(C); – user20006686 Dec 12 '22 at 17:34
  • OK. I edited my code again. – Sandy G Dec 12 '22 at 18:29

1 Answers1

3

If you want to enclose the entire tree in a brace:

enter image description here

you can use \left. and right\}:

$\left.\vcenter{\hbox{
  <forest code goes here>
}}\right\}$

On the other hand, if you want to separate parts of the tree with braces it's a bit more complicated. Here is a possibility using. the calligraphy library to draw the braces.

enter image description here

Use name to name the nodes where the splits occur. Then set coordinates at the northeast and southeast corners of the current bounding box. Then draw the brace using the named nodes. Since the north edges of the nodes do not quite reach the couth edge of the previous node, a manual adjustments using [yshift=] may improve the appearance.

Here is the code:

\documentclass{article}
\usepackage{forest}

\usetikzlibrary {decorations.pathreplacing, calligraphy} \tikzset{mybrace/.style={decorate, decoration={calligraphic brace, amplitude=2mm},ultra thick}, label={0:d}}

\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}; }, % style for your file node file/.style={edge path={\noexpand\path [draw, \forestoption{edge}] (!u.south west) +(7.5pt,0) |- (.child anchor) \forestoption{edge label};}, inner xsep=2pt, font=\small\ttfamily }, before typesetting nodes={ if n=1 {insert before={[,phantom]}} {} }, fit=band, before computing xy={l=15pt}, }
[system, name=system [config, name= config ] [lib, name=lib node [Access, name=access ] [Plugin, name=plugin ] [file.txt, file, name=file ] ] [templates, name=templaes ] [tests, name=tests ] ] \coordinate(top) at (current bounding box.north east); \coordinate(bot) at (current bounding box.south east); \draw[mybrace] (top)--node[right=2mm]{Explanation 1}(top|-config.south)coordinate(A); \draw[mybrace] (A)--node[right=2mm]{Explanation 2}([yshift=-1mm]top|-access.south)coordinate(B); \draw[mybrace] (B)--node[right=2mm]{Explanation 3}([yshift=-1mm]top|-file.south)coordinate(C); \draw[mybrace] (C)--node[right=2mm]{Explanation 4}(bot);
\end{forest}

\end{document}

Sandy G
  • 42,558
  • Hello, thanks for your, help it's close to be the perfect solution for me. There is just a little point that confuse me. In the solution you provide there is 2 braces split by: name=file node where "file node" is the label use to split brace 1 and 2. And, I am not sure a that but a box is created from north east (A) to south east (B) ie from point A to point B. First brace is draw from A to C, C is the element with the node, then second brace is draw from C to B. – user20006686 Dec 09 '22 at 10:09
  • @user20006686: The node (current bounding box) is automatically updated throughout the creation of a tikzpicture. So after the tree is drawn I fix those northeast and southeast coordinates (A) and (B). The middle coordinate (C) should be directly below (A) but with the same y-coordinate as (file node.south). The syntax (A|-file node.south) accomplishes this. – Sandy G Dec 09 '22 at 12:54
  • Sorry, Sandy I don't know what happened but the comment was half of my answered. – user20006686 Dec 09 '22 at 18:11
  • @user20006686: I edited my answer. Is this what you wanted? – Sandy G Dec 09 '22 at 19:14