我希望线条淡入淡出,这样我就可以在多列或多页中看到树状视图。请参阅下面提供的示例。如果长节点线在中间淡出(即使其完全透明以不覆盖文本),它们会好看得多。如果可能的话,我会在两端使用不同的颜色,以区分哪一条线通向哪里。
\documentclass[8pt]{book}
\usepackage[paper=A3,pagesize]{typearea}
%För att göra strukturträd
\usepackage[edges]{forest}
\usepackage{fullpage}
%\usepackage{showframe}
\begin{document}
\begingroup
\begin{forest}
for tree={grow=north}
[\phantom, phantom
[Test sample A (0.00.000), l*=6, name=TSAa
[\dots
[\dots
[\dots, name=TSAb
[obsolete]]]]]
[New article, l*=14, name=NewArticle]
[obsolete, l*=15, name=Obsolete]
[Released article (1.00.000), name=Released2
[1.00.001
[1.00.002
[\dots
[1.01.000, name=TSAa1
[1.02.000, l*=5, name=TSAb1
[\dots
[\dots
[1.04.012, name=ChooseNode
[2.00.000, edge={black!20, dashed}
[\dots]]]]]]]]]]]
[Test sample 2 (0.00.000), l*=9, name=TS2a
[\dots
[\dots
[\dots, name=TS2b
[obsolete]]]]]
[New article number (0.00.000), name=NewArticleNumber
[0.00.001
[0.00.002
[\dots
[0.00.123, name=TS1a1
[\dots
[\dots
[0.00.321, name=TS2a1
[\dots
[\dots
[0.01.000, name=TS1b1
[0.01.001
[0.02.000, name=TS2b1
[0.02.001, name=Revert1
[\dots
[0.02.012, name=TS3a1
[0.02.013, l*=5, name=TS3b1
[0.03.000, name=Revert2, edge={black!20, dashed}
[\dots
[Release (1.00.000), name=Released1]]]]]]]]]]]]]]]]]]]]
[Test sample 1 (0.00.000), l*=6, name=TS1a
[0.00.001
[0.00.002
[\dots
[0.00.234, name=TS1b
[obsolete]]]]]]
[Test sample 3 (0.00.000), l*=17, name=TS3a
[\dots
[\dots
[\dots, name=TS3b
[obsolete]]]]]
]
\draw[-] (TS1a1) to (TS1a);
\draw[-] (TS1b1) to (TS1b);
\draw[-] (TS2a1) to (TS2a);
\draw[-] (TS2b1) to (TS2b);
\draw[-] (TS3a1) to (TS3a);
\draw[-] (TS3b1) to (TS3b);
\draw[-] (Revert1) to[out=east,in=east] (Revert2);
\draw[-] (Released1) to[out=east,in=south] (Released2);
\draw[-] (TSAa1) to (TSAa);
\draw[-] (TSAb1) to (TSAb);
\draw[-, black!20, dashed] (ChooseNode) to (NewArticle);
\draw[-] (NewArticle) to[out=east,in=south] (NewArticleNumber);
\draw[-, black!20, dashed] (ChooseNode) to (Obsolete);
\end{forest}
\endgroup
\end{document}
答案1
这个答案修复了发布的示例中编译错误的两个原因,最小化了序言并提供了一个虚构的解决方案。
除非你有极其充分的理由不这样做,否则听我的建议:假装。
这使用前景层上的填充节点,并将冲突路径放在背景层上,以便它们位于白色框后面。结果就像路径被破坏以避开框一样。
如果想要褪色效果,可以用透明阴影填充节点。但是,这会更麻烦、更脆弱,维护起来也更麻烦。此外,您无法对 s 执行此操作edge
。至少,没有精心设计的工具是不行的,这些工具可能与 Forest 配合,也可能不配合。因此,我会避免这种情况并保持简单。
\documentclass[border=10pt]{standalone}
\usepackage{forest}
\usetikzlibrary{backgrounds}
\begin{document}
\begin{forest}
for tree={grow=north, fill=white, edge={double=black, draw=white}}
[, phantom
[Test sample A (0.00.000), l*=6, name=TSAa
[\dots
[\dots
[\dots, name=TSAb
[obsolete]]]]]
[New article, l*=14, name=NewArticle]
[obsolete, l*=15, name=Obsolete]
[Released article (1.00.000), name=Released2
[1.00.001
[1.00.002
[\dots
[1.01.000, name=TSAa1
[1.02.000, l*=5, name=TSAb1
[\dots
[\dots
[1.04.012, name=ChooseNode
[2.00.000, edge={black!20, dashed}
[\dots]]]]]]]]]]]
[Test sample 2 (0.00.000), l*=9, name=TS2a
[\dots
[\dots
[\dots, name=TS2b
[obsolete]]]]]
[New article number (0.00.000), name=NewArticleNumber
[0.00.001
[0.00.002
[\dots
[0.00.123, name=TS1a1
[\dots
[\dots
[0.00.321, name=TS2a1
[\dots
[\dots
[0.01.000, name=TS1b1
[0.01.001
[0.02.000, name=TS2b1
[0.02.001, name=Revert1
[\dots
[0.02.012, name=TS3a1
[0.02.013, l*=5, name=TS3b1
[0.03.000, name=Revert2, edge={black!20, dashed}
[\dots
[Release (1.00.000), name=Released1]]]]]]]]]]]]]]]]]]]]
[Test sample 1 (0.00.000), l*=6, name=TS1a
[0.00.001
[0.00.002
[\dots
[0.00.234, name=TS1b
[obsolete]]]]]]
[Test sample 3 (0.00.000), l*=17, name=TS3a
[\dots
[\dots
[\dots, name=TS3b
[obsolete]]]]]
]
\begin{scope}[on background layer]
\draw[-] (TS1a1) to (TS1a);
\draw[-] (TS1b1) to (TS1b);
\draw[-] (TS2a1) to (TS2a);
\draw[-] (TS2b1) to (TS2b);
\draw[-] (TS3a1) to (TS3a);
\draw[-] (TS3b1) to (TS3b);
\draw[-] (Revert1) to[out=east,in=east] (Revert2);
\draw[-] (Released1) to[out=east,in=south] (Released2);
\draw[-] (TSAa1) to (TSAa);
\draw[-] (TSAb1) to (TSAb);
\draw[-, black!20, dashed] (ChooseNode) to (NewArticle);
\draw[-] (NewArticle) to[out=east,in=south] (NewArticleNumber);
\draw[-, black!20, dashed] (ChooseNode) to (Obsolete);
\end{scope}
\end{forest}
\end{document}