我的家谱有问题(可以找到这里)。有人在评论中建议我使用 forest 包。我尝试转换它,但我不知道是否可以应用相同的样式。
因此,我想要实现的目标是让我的森林看起来像我的家谱树。此外,我希望保留森林的层次,就像我对森林所做的那样,以便轻松容纳更多数据。
我的代码:
\documentclass{article}
\usepackage[]{forest}
%\usetikzlibrary{shadows,arrows.meta}
\usepackage{pdflscape}
\usepackage{genealogytree}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\forestset{
skip one/.style={
replace by={
[,
shape=coordinate,
l*=.25,
append
]
},
},
}
\begin{landscape}
\resizebox{\linewidth}{!}{
\begin{forest}
for tree={
parent anchor=south,
child anchor=north,
draw,
thick,
font=\small\sffamily,
align=center,
delay={
where content={}{
shape=coordinate,
}{},
},
},
before packing={
for tree={
if={isodd(n_children())}{
for children={
if={equal(n,int((1+n_children("!u"))/2))}{
calign with current,
}{},
},
}{},
edge path={
\noexpand\path [draw, thick, \forestoption{edge}] (!u.parent anchor) -- ++(0,-5pt) |- ($(.child anchor) + (0,5pt)$) -- (.child anchor)\forestoption{edge label};
},
},
},
[CERT Services,
[Reactive,
[Incident handling , skip one, l*=3
[incident analysis],
[incident response on-site],
[incident response support],
[incident response coordination ],
]
[Vulnerability Handling,
[Vulnerability analysis],
[Vulnerability response ],
[Vulnerability response coordination],
]
[Artifact Handling, , skip one, l*=5
[Artifact analysis],
[Artifact response],
[Artifact response coordination],
]
]
% [Proactive, skip one, l*=15
% [Announcements],
% [Technology Watch],
% [Security Audits or Assessments],
% [Configuration and Maintenance ],
% [Development of Security Tools],
% [Intrusion Detection Services],
% [Security-Related Information Dissemination]
% ]
% [Quality Management
% [Risk Analysis],
% [Business Continuity and Disaster Recovery Planning],
% [Security Consulting],
% [Awareness Building],
% [Education/Training],
% [Product Evaluation or Certification],
% ]
]
\end{forest}
}
\end{landscape}
\begin{landscape}
\begin{figure}[b]
\noindent\resizebox{\linewidth}{!}{
\begin{genealogypicture}[
processing=database,
database format=full,
info separators={\tcbline}{\tcbline}{}{},
category/.style={box={colback=red!20}}, % category
service/.style={box={colback=green!20}}, % a Service
realization/.style={box={colback=blue!20 }}, %Realization Technique
empty/.style={box={colback=white}}, %Realization Technique
edges={foreground={line width=1pt,black,->,},background={line width=2pt,white},}, %swing,
box={fit basedim=9pt,boxsep=2pt,segmentation style=solid,halign=center,valign=center,before upper=\parskip2pt,\gtrDBsex,{colback=gray!20}},%CATEGORY
% node={ turn=right},
after tree={
\node [draw,black,fill=red!20,text height=1em] (a) at (current bounding box.north east) {Category};
\node [draw,black,fill=green!20,left=2mm of a] (b) {Service};
\node [draw,black,fill=blue!20,left=2mm of b] (c) { Technique};
}
]
child{
g{name={\textbf{CERT \\ Services}}}
child{
g[category]{name={\textbf{React Services}}, comment= {This is performed in the software}}
child{
g[category]{name={\textbf{Linux Kernel Features}}, comment= {A feature in Linux kernel used to provide security}}
child {
g[service]{name={\textbf{Incident Analysis}}, comment= {service explanation}}
c[realization]{name={\textbf{xxx}}, comment= {realization explanation}}
c[realization]{name={\textbf{xxx}}, comment= {realization explanation}}
}
child {
g[service]{name={\textbf{Incident Response On-site}}, comment= {service explanation}}
c[realization]{name={\textbf{xxx}}, comment= {realization explanation}}
c[realization]{name={\textbf{xxx}}, comment= {realization explanation}}
}
child {
g[service]{name={\textbf{Incident Response Support}}, comment= {service explanation}}
c[realization]{name={\textbf{xxx}}, comment= {realization explanation}}
c[realization]{name={\textbf{xxx}}, comment= {realization explanation}}
}
child {
g[service]{name={\textbf{incident response coordination}}, comment= {service explanation}}
c[realization]{name={\textbf{xxx}}, comment= {realization explanation}}
c[realization]{name={\textbf{xxx}}, comment= {realization explanation}}
}
}
child{
g[category]{name={\textbf{Vulnerability Handling}}, comment= {service explanation}}
child {
g[service]{name={\textbf{Vulnerability Analysis}}, comment= {service explanation}}
c[realization]{name={\textbf{xxx}}, comment= {realization explanation}}
c[realization]{name={\textbf{xxx}}, comment= {realization explanation}}
}
child {
g[service]{name={\textbf{Vulnerability Response}}, comment= {service explanation}}
c[realization]{name={\textbf{xxx}}, comment= {realization explanation}}
c[realization]{name={\textbf{xxx}}, comment= {realization explanation}}
}
child {
g[service]{name={\textbf{vulnerability Response Coordination}}, comment= {service explanation}}
c[realization]{name={\textbf{xxx}}, comment= {realization explanation}}
c[realization]{name={\textbf{xxx}}, comment= {realization explanation}}
}
}
child{
g[category]{name={\textbf{Artifact Handling}}, comment= {Configuration automation}}
child {
g[service]{name={\textbf{Artifact Analysis}}, comment= {service explanation}}
c[realization]{name={\textbf{xxx}}, comment= {realization explanation}}
c[realization]{name={\textbf{xxx}}, comment= {realization explanation}}
}
child {
g[service]{name={\textbf{Artifact Response}}, comment= {service explanation}}
c[realization]{name={\textbf{xxx}}, comment= {realization explanation}}
c[realization]{name={\textbf{xxx}}, comment= {realization explanation}}
}
child {
g[service]{name={\textbf{Artifact Response Coordination}}, comment= {service explanation}}
c[realization]{name={\textbf{xxx}}, comment= {realization explanation}}
c[realization]{name={\textbf{xxx}}, comment= {realization explanation}}
}
}
}
% child{
% g[category]{name={\textbf{Proactive Services}}, comment= {This is performed in the hardware}}
% child {
% g[empty]{name={\textbf{x}}}
% child{
% g[empty]{name={\textbf{x}}}
% child {
% g[empty]{name={\textbf{x}}}
% child {
% g[service]{name={\textbf{xxx}}, comment= {service explanation}}
% c[realization]{name={\textbf{xxx}}, comment= {realization explanation}}
% c[realization]{name={\textbf{xxx}}, comment= {realization explanation}}
% }
% child {
% g[service]{name={\textbf{xxx}}, comment= {service explanation}}
% c[realization]{name={\textbf{xxx}}, comment= {realization explanation}}
% c[realization]{name={\textbf{xxx}}, comment= {realization explanation}}
% }
% child {
% g[service]{name={\textbf{xxx}}, comment= {service explanation}}
% c[realization]{name={\textbf{xxx}}, comment= {realization explanation}}
% c[realization]{name={\textbf{xxx}}, comment= {realization explanation}}
% }
% child {
% g[service]{name={\textbf{xxx}}, comment= {service explanation}}
% c[realization]{name={\textbf{xxx}}, comment= {realization explanation}}
% c[realization]{name={\textbf{xxx}}, comment= {realization explanation}}
% }
% child {
% g[service]{name={\textbf{xxx}}, comment= {service explanation}}
% c[realization]{name={\textbf{xxx}}, comment= {realization explanation}}
% c[realization]{name={\textbf{xxx}}, comment= {realization explanation}}
% }
% child {
% g[service]{name={\textbf{xxx}}, comment= {service explanation}}
% c[realization]{name={\textbf{xxx}}, comment= {realization explanation}}
% c[realization]{name={\textbf{xxx}}, comment= {realization explanation}}
% }
% child {
% g[service]{name={\textbf{xxx}}, comment= {service explanation}}
% c[realization]{name={\textbf{xxx}}, comment= {realization explanation}}
% c[realization]{name={\textbf{xxx}}, comment= {realization explanation}}
% }
% }
% }
% }
% }
% child{
% g[category]{name={\textbf{Security Quality Management Services}}, comment= {This is performed in the hardware}}
% c[service]{name={\textbf{xxx}}, comment= {service explanation}}
% c[service]{name={\textbf{xxx}}, comment= {service explanation}}
% c[service]{name={\textbf{xxx}}, comment= {service explanation}}
% c[service]{name={\textbf{xxx}}, comment= {service explanation}}
% c[service]{name={\textbf{xxx}}, comment= {service explanation}}
% c[service]{name={\textbf{xxx}}, comment= {service explanation}}
%
%
% }
}
\end{genealogypicture}
}
\end{figure}
\end{landscape}
\end{document}
最后,我对家谱树和森林的某些部分进行了注释,因为结果会太大,放不下。如果有办法把它放在一页里,我会非常感激。
谢谢你,
答案1
这适合横向的美国字母,geometry
并包括注释部分。它还避免了缩放图表,这被认为是极其令人讨厌的。
只需装载geometry
即可帮助放入物品。搬到使用 A4 的国家也可能会有所帮助:它会使宽度方面变得更好,但高度方面变得更糟。
据我所知,它改变了布局,因为没有其他方法可以容纳东西。
\documentclass{article}
\usepackage[landscape]{geometry}
\usepackage[edges]{forest}
\forestset{declare boolean={switch me}{0}}
\begin{document}
\begin{forest}
where n children=0{!u.switch me}{},
delay={
where switch me={
replace by/.process={ Ow {content} {{[#1, fit=rectangle, append]}}},
no edge,
shape=coordinate,
content=,
for tree={
grow'=0,
},
for children={
folder,
edge path'={(!uu.parent anchor) |- (!.child anchor)},
},
}{},
},
before typesetting nodes={
where level=0{fill=gray!20}{
if level=1{fill=red!20}{
if level=2{fill=green!20}{fill=blue!20},
},
},
for tree={
draw,
thick,
rounded corners,
edge+={->,thick},
align=center,
font=\small\sffamily,
parent anchor=children,
},
where switch me={
for current and ancestors={
edge path'={(!u.parent anchor) -- ++(0pt,-5pt) -| (.child anchor) }, % forked edge seems to get confused
child anchor=parent,
},
for nodewalk={fake=1,descendants}{
folder,
child anchor=west,
}
}{},
},
[CERT Services,
[Reactive,
[Incident\\handling
[incident\\analysis],
[incident\\response\\on-site],
[incident\\response\\support],
[incident\\response\\coordination],
]
[Vulnerability\\Handling, calign with current edge
[Vulnerability\\analysis],
[Vulnerability\\response ],
[Vulnerability\\response\\coordination],
]
[Artifact\\Handling,
[Artifact\\analysis],
[Artifact\\response],
[Artifact\\response\\coordination],
]
]
[Proactive,
[Announcements],
[Technology\\Watch],
[Security\\Audits or\\Assessments],
[Configuration\\\&\\Maintenance ],
[Development\\of Security\\Tools],
[Intrusion\\Detection\\Services],
[Security-Related\\Information\\Dissemination]
]
[Quality\\Management
[Risk\\Analysis],
[Business\\Continuity\\\& Disaster\\Recovery\\Planning],
[Security\\Consulting],
[Awareness\\Building],
[Education\\\& Training],
[Product\\Evaluation or\\Certification],
]
]
\end{forest}
\end{document}
编辑
另一种可能性是,不使用folder
并尝试使节点大小更加统一(如评论中所要求的),如下所示:
请注意,框架显示文本块(具有geometry
默认边距的美国字母)。如果不使图表对于页面来说太高,或者想出其他布局技巧以其他方式移动内容,就不可能使所有节点都具有相同的大小。
你只需要尝试这种事情。最终,你比其他任何人都更有能力决定做出什么样的权衡。这两个例子表明,相对而言,开箱即用是可能的。调整是你必须尝试的事情,直到你满意为止。也就是说,调整不仅是留给你的练习,亲爱的读者。但这种调整是只有你才能做的事情。
\documentclass{article}
\usepackage[landscape,showframe]{geometry}
\usepackage[edges]{forest}
\forestset{
ph me/.style={
tier=#1,
if n children=0{phantom}{edge+=-, shape=coordinate},
},
/tikz/.cd,
col base/.style={fill=#1!20},
moonie/.style={col base=red, minimum height=0pt},
sonny/.style={col base=blue, minimum height=9ex},
grassy/.style={col base=green, minimum height=9ex},
}
\begin{document}
\noindent
\begin{forest}
forked edges,
for tree={
draw,
thick,
rounded corners,
edge+={->,thick},
align=center,
font=\small\sffamily,
parent anchor=children,
child anchor=parent,
if level>=2{
calign child=-1,
calign=child edge,
anchor=parent,
}{},
},
before typesetting nodes={
where content={}{shape=coordinate, edge+=-}{},
},
where level=0{col base=gray}{
if level=1{moonie}{
if level=2{grassy}{sonny},
},
},
[CERT Services,
[Reactive,
[Incident\\handling
[incident\\analysis]
[incident\\response\\on-site]
[incident\\response\\support]
[incident\\response\\coordination, tier=cloud]
]
[, ph me=cloud
[Vulnerability\\Handling, grassy
[Vulnerability\\analysis]
[Vulnerability\\response ]
[Vulnerability\\response\\coordination, tier=sun]
]
]
[, ph me=sun
[Artifact\\Handling, grassy
[Artifact\\analysis]
[Artifact\\response]
[Artifact\\response\\coordination, tier=here]
]
]
]
[, ph me=here
[Proactive, moonie, for children={grassy}
[Announcements],
[Technology\\Watch],
[Security\\Audits or\\Assessments],
[Configuration\\\& Maintenance ],
[Development\\of Security\\Tools],
[Intrusion\\Detection\\Services],
[Security-Related\\Information\\Dissemination, tier=there]
]]
[, ph me=there
[Quality\\Management, moonie, for children=grassy
[Risk\\Analysis],
[Business Continuity \&\\Disaster Recovery Planning],
[Security\\Consulting],
[Awareness\\Building],
[Education\\\& Training],
[Product Evaluation\\or Certification]
]]
]
\end{forest}
\end{document}