我想在目录树图中添加右对齐括号以便于解释,但我不知道如何“混合”包命令
以下是两个链接
在每种情况下,这是我尝试混合的最后解决方案
是的,这正是我想要的,但我早上花了很多时间试图添加第四个支架,所以我再次需要你的帮助。以下是我的修改:
[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);
答案1
如果要将整个树括在括号中:
您可以使用\left.
和right\}
:
$\left.\vcenter{\hbox{
<forest code goes here>
}}\right\}$
另一方面,如果你想用括号分隔树的各个部分,那就有点复杂了。这里有一个可能性,使用calligraphy
库来绘制括号。
使用name
命名发生分裂的节点。然后将coordinate
s 设置在 的东北角和东南角current bounding box
。然后使用 d 节点绘制支架name
。由于节点的北边缘未完全到达前一个节点的底边缘,使用 进行手动调整[yshift=]
可能会改善外观。
以下是代码:
\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}