我想使用该genealogytree
包来显示几个人的关系,但看过它的文档后,我不确定该怎么做。以下是我想在纯 Ti 中显示的关系的示例钾Z:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{genealogytree}
\begin{document}
\begin{tikzpicture}
\node (X) at (0,2) {X};
\node (RelXY) at (1,2) {\gtrsymPartnership};
\node (Y) at (2,2) {Y};
\node (MarrYZ) at (3,2) {\gtrsymMarried};
\node (Z) at (4,2) {Z};
\node (A) at (0,0) {A};
\node (B) at (2,0) {B};
\node (C) at (4,0) {C};
\node (MarrCD) at (5,0) {\gtrsymMarried};
\node (D) at (6,0) {D};
\node (E) at (8,0) {E};
\node (MarrEF) at (9,0) {$\smash{\stackrel{1}{\gtrsymMarried}}\vphantom{\gtrsymMarried}$};
\node (F) at (10,0) {F};
\node (MarrFG) at (11,0) {$\smash{\stackrel{2}{\gtrsymMarried}}\vphantom{\gtrsymMarried}$};
\node (G) at (12,0) {G};
\node (H) at (2,-2) {H};
\node (I) at (4,-2) {I};
\node (J) at (6,-2) {J};
\node (MarrJK) at (7,-2) {\gtrsymMarried};
\node (K) at (8,-2) {K};
\node (L) at (10,-2) {L};
\node (M) at (12,-2) {M};
\draw (MarrFG.south) -- ($(0,-1)!(MarrFG.south)!(10,-1)$) -- ($(0,-1)!(M.north)!(10,-1)$) -- (M.north);
\draw (MarrEF.south) -- ($(0,-1)!(MarrEF.south)!(10,-1)$) -- ($(0,-1)!(L.north)!(10,-1)$) -- (L.north);
\draw (MarrEF.south) -- ($(0,-1)!(MarrEF.south)!(10,-1)$) -- ($(0,-1)!(K.north)!(10,-1)$) -- (K.north);
\draw (E.north) -- ($(0,1)!(E.north)!(10,1)$) -- ($(0,1)!(D.north)!(10,1)$) -- (D.north);
\draw (C.north) -- ($(0,1)!(C.north)!(10,1)$) -- ($(0,1)!(B.north)!(10,1)$) -- (B.north);
\draw (MarrYZ.south) -- ($(0,1)!(MarrYZ.south)!(10,1)$);
\draw (RelXY.south) -- ($(0,1)!(RelXY.south)!(10,1)$) -- ($(0,1)!(A.north)!(10,1)$) -- (A.north);
\draw (H.north) -- ($(0,-1)!(H.north)!(10,-1)$) -- ($(0,-1)!(MarrCD.south)!(10,-1)$) -- (MarrCD.south);
\draw (I.north) -- ($(0,-1)!(I.north)!(10,-1)$);
\end{tikzpicture}
\end{document}
这产生了
作为演示还可以,但看起来并不是很好,更不用说不必要地难以更改和更新,所以我想使用类似的包genealogytree
来代替。
我遇到的问题与以下事实有关:它genealogytree
似乎主要是为了显示一个人的祖先、后代或两者而设计的。上面显示的关系不符合这一要求。
所以,我的问题是:
- 有没有办法做到这一点使用
genealogytree
(我想同时使用,因为它的语法比纯 Ti 更直观钾Z,并且因为它有好看的模板)? - 是否有更合适的替代方案?
顺便说一句,我并不太在意关系图的具体布局。
答案1
您可以通过调整几棵树的相对位置并链接各个家族来表示一棵复杂的树。
下面的代码仍然需要对边(围绕节点 Y 和 F)进行一些调整,但它确实准确地表示了树。
\documentclass{standalone}
\usepackage{genealogytree}
\begin{document}
\begin{tikzpicture}
\genealogytree[
label options={fill=white,node font=\footnotesize}
]{
child[family label={\gtrsymMarried}]{
union[family label={\gtrsymPartnership}]{
p{X}
c{A}
}
g{Y}
p{Z}
c{B}
c[id=C_node]{C}
}
}
\genealogytree[
adjust node= D_node right of C_node distance 0.4cm,
add parent= C_node to fam_D_node,
label options={fill=white,node font=\footnotesize}
]{
child{
g[disconnect, phantom]{parent}
child[id=fam_D_node, family label={\gtrsymMarried}]{
g[id=D_node]{D}
c{H}
c{I}
}
child[edges up by= 1 of 6, family label={\gtrsymMarried~1}]{
g[id=E_node]{E}
p[id=F_node_1]{F}
child[family label={\gtrsymMarried}]{
p{J}
g{K}
}
c{L}
}
}
}
\genealogytree[
set position= F_node_2 at F_node_1,
label options={fill=white,node font=\footnotesize}
]{
child[id=fam_F_node, edges down by= 1 of 6, family label={\gtrsymMarried~2}]{
g[id=F_node_2]{F}
p{G}
c[disconnect, phantom]{shift child}
c{M}
}
}
\end{tikzpicture}
\end{document}