我必须为我的最终论文制定一个文献综述分类法,突出每篇论文的显著特点、类别等。我想用层次结构以图表形式表示这一点(类似于下图)
如何使用 Latex 完成此操作?我不想使用任何图表软件,因为我必须维护分类法中论文的引用。我查看了可用的森林包示例这里(由@skpblack 发布),并尝试使用它,但我不确定如何将其自定义为我需要的纯色样式。有人可以帮我吗?提前感谢任何帮助。
编辑:添加了 MWE
\documentclass[12pt,a4paper,twoside, index, tikz]{book}
%for drawing lit survey hierarchies
\usepackage{tikz}
\usetikzlibrary{trees}
%for drawing lit survey trees
\usetikzlibrary{arrows.meta, shapes.geometric, calc, shadows}
\colorlet{linecol}{black!75}
\usepackage{forest}
\usepackage{newfloat}
\DeclareFloatingEnvironment[fileext=lod]{Figure} %for adding captions
\forestset{/.style=
{
{for tree=
{parent anchor=south,
child anchor=north,
align=center
l+=1.5cm}
}
}
}
\begin{document}
\pgfkeys{/forest,
my rounded corners/.append style={rounded corners=2pt},
}
\begin{forest}
for tree={
% font=\sffamily,
line width=1pt,
draw=linecol,
% drop shadow,
fit=rectangle,
edge={color=linecol, >={Triangle[]}, ->},
where level=0{%
l sep+=5pt,
calign=child,
calign child=2,
% inner color=green!80,
% outer color=green,
align=center,
my rounded corners,
for descendants={%
calign=first,
},
}{%
where level=1{%
%inner color=green!80,
%outer color=green,
my rounded corners,
align=center,
parent anchor=south west,
tier=three ways,
for descendants={%
child anchor=west,
parent anchor=west,
align=left,
anchor=west,
% inner color=MistyRose1!80,
% outer color=MistyRose1,
edge path={
\noexpand\path[\forestoption{edge}]
(!to tier=three ways.parent anchor) |-
(.child anchor)\forestoption{edge label};
},
},
}{}%
},
}
[Drawing Diagrams
[Defining node\\and arrow styles
[Setting shape
[Choosing colour
[Adding shading]
]
]
]
[Positioning\\the nodes
[Using a matrix
[Absolutely
[Relatively
[Using overlays]
]
]
]
]
[Drawing arrows\\between nodes
[Default arrows
[Arrow library
[Re-sizing tips
[Shortening
[Bending]
]
]
]
]
]
]
\end{forest}
\end{document}
我不确定如何进一步编辑以获得我想要的显示。尝试编辑代码的其他部分(例如生成边界矩形的部分等),但结果却出现了错误。
编辑#2:(更新)
我在我的文档(书籍类)中编辑了答案,并使用了@cfr提供的确切代码,并反复收到“缺少插入的 \endcsname。\bgroup \end{forest}”错误。。当我注释掉 fancyhdr 包时,它起作用了。但现在我得到的是以下显示。指向 3 级子节点的水平箭头太长,因此相互重叠。我做错了什么?(抱歉,我不知道如何在评论部分添加最新的屏幕截图。)
答案1
更新
如果您不介意稍微调整一下树的结构,您可以得到更接近目标的东西。我也尝试使用angles
这里的库来绘制顶部的弧线。
如果您对第二级(子标题层级之下)使用空节点,然后将子子标题设置为该级别的子节点,则可以根据需要使用进一步的子节点,并获得更好的子子标题对齐。
代码如下:
\documentclass[12pt, border=20pt, tikz]{standalone}
% based on skpblack's answer at http://tex.stackexchange.com/questions/206971/diagram-using-forest-package, modified by skarth at http://tex.stackexchange.com/q/263749/.
%for drawing lit survey trees
\usetikzlibrary{arrows.meta,angles,quotes}
\colorlet{linecol}{black!75}
\usepackage{forest}
\tikzset{
my rounded corners/.append style={rounded corners=2pt},
}
\begin{document}
\begin{forest}
for tree={
line width=1pt,
if={level()<2}{
my rounded corners,
draw=linecol,
}{},
edge={color=linecol, >={Triangle[]}, ->},
if level=0{%
l sep+=1.5cm,
align=center,
parent anchor=south,
tikz={
\path (!1.child anchor) coordinate (A) -- () coordinate (B) -- (!l.child anchor) coordinate (C) pic [draw, angle radius=20mm, every node/.append style={fill=white}, "based on"] {angle};
},
}{%
if level=1{%
parent anchor=south west,
child anchor=north,
tier=parting ways,
align=center,
font=\bfseries,
for descendants={
child anchor=west,
parent anchor=west,
anchor=west,
align=left,
},
}{
if level=2{
shape=coordinate,
no edge,
grow'=0,
calign with current edge,
xshift=20pt,
for descendants={
parent anchor=south west,
l sep+=-20pt
},
for children={
edge path={
\noexpand\path[\forestoption{edge}] (!to tier=parting ways.parent anchor) |- (.child anchor)\forestoption{edge label};
},
font=\bfseries,
for descendants={
no edge,
},
},
}{},
},
}%
},
[Main Heading
[Attributes
[
[Type of attributes
[1. a\\2. b]
]
[Weight of attributes
[$w <$ 1g\\1g $\leq w \leq$ 5g\\5g $\leq w \leq$ 10g\\10g $\leq w$]
]
[Number of attributes
[10\\100\\1000]
]
]
]
[Support value
[
[Support value
[Positive\\Negative]
]
[Variations
[Optimised\\Fuzzy]
]
[Absolute value
[Fractional\\Decimal\\Normalised]
]
[Relative value
[Fractional\\Decimal\\Normalised]
]
]
]
[Constraints
[
[None]
[Some
[One\\A few\\Many\\Lots]
]
[Statistical comparisons
[Median\\Mean\\Mode\\Standard deviation\\Reliability\\T test]
]
]
]
[Concept taxonomy
[
[Categories]
]
]
[Types of data
[
[Noumena
[Thing 1-in-itself\\Thing 2-in-itself\\Thing 3-in-itself]
]
[Phenomena
[Appearance 1\\Appearance 2\\Appearance 3\\Appearance 4]
]
]
]
]
\end{forest}
\end{document}
对我来说,这看起来更好一些,部分原因是取消fit=rectangle
使得树更紧凑,我认为这使得结构更清晰。
原始(无需额外节点)
\documentclass[12pt, border=20pt, tikz]{standalone}
%for drawing lit survey trees
\usetikzlibrary{arrows.meta}
\colorlet{linecol}{black!75}
\usepackage{forest}
\tikzset{
my rounded corners/.append style={rounded corners=2pt},
}
\begin{document}
\begin{forest}
for tree={
line width=1pt,
if={level()<2}{
my rounded corners,
draw=linecol,
}{},
fit=rectangle,
edge={color=linecol, >={Triangle[]}, ->},
if level=0{%
l sep+=1.5cm,
for descendants={%
calign=first,
},
align=center,
parent anchor=south,
tikz={
\draw (!1.north |- .south) +(0,-5pt) coordinate (a) [out=-30, in=-150] to node [midway, above=5pt] {Something here} (!l.north |- a);
},
}{%
if level=1{%
parent anchor=south west,
child anchor=north,
tier=three ways,
align=center,
for descendants={%
child anchor=west,
parent anchor=west,
align=left,
anchor=west,
xshift=-20pt,
edge path={
\noexpand\path[\forestoption{edge}]
(!to tier=three ways.parent anchor) |-
(.child anchor)\forestoption{edge label};
},
},
}{}%
},
}
[Drawing Diagrams
[Defining node\\and arrow styles
[Setting shape
[Choosing colour
[Adding shading]
]
]
]
[Positioning\\the nodes
[Using a matrix
[Absolutely
[Relatively
[Using overlays]
]
]
]
]
[Drawing arrows\\between nodes
[Default arrows\\1. something\\2. else
[Arrow library
[Re-sizing tips
[Shortening
[Bending]
]
]
]
]
]
]
\end{forest}
\end{document}