使用 TikZ 构建家谱树,我无法增加父亲和第二任妻子之间的节点线之间的空间

使用 TikZ 构建家谱树,我无法增加父亲和第二任妻子之间的节点线之间的空间

我放弃了@thomas-f-sturm 的genealogytree库,因为它不支持网格结构。

我迁移到了纯 TikZ 和 PGF。我试图建立一个有父系和母系的家谱,有 18 个上级世代和 16 个下级世代,并增加了兄弟姐妹及其配偶和子女、叔叔及其配偶、叔叔和父母的第二任配偶、祖父母的兄弟姐妹及其侄子等。

我能够将父亲与第二任妻子(即继母)联系起来,但我无法增加第二人生与父亲之间的节点线之间的空间。

请记住,图像有所不同,因为您要求的是最小且简单的 MWE 代码。如果您希望我分享完整的代码,我可以为您提供可共享的链接。

以下是小而简单的 MWE 代码:

\documentclass[margin = 10pt, tikz]{standalone}

\usepackage{adjustbox}
\usepackage{etoolbox}
\usepackage{fontspec}
\usepackage[all]{genealogytree}
\usepackage{graphicx}
\usepackage{ifthen}
\usepackage[utf8]{inputenc}
\usepackage{pgffor}
\usepackage{svg}
\usepackage{tcolorbox}
\usepackage{tikz}
\usepackage{xcolor}

\usetikzlibrary{calc, positioning, shapes, shapes.multipart}
\pgfdeclarelayer{background}
\pgfsetlayers{background, main}

\definecolor{art_deco_dark_blue}{HTML}{2E3482}
\definecolor{art_deco_dark_pink}{HTML}{E20042}
\definecolor{art_deco_dark_antique_copper}{HTML}{75524D}
\definecolor{art_deco_light_apple_core_yellow}{HTML}{F3EDD5}

\newlength{\mypxtoin}
\setlength{\mypxtoin}{0.013889in}

\newlength{\mypxtocm}
\setlength{\mypxtocm}{0.026cm}

\newlength{\mypxtopt}
\setlength{\mypxtopt}{0.75pt}

\tikzset
{
    font = \fontsize{11\mypxtopt}{2cm},
    every node/.style = 
    { 
        draw,
        font = \fontsize{12\mypxtopt}{2cm},
        rounded corners = {2\mypxtoin},
        text width = 5cm,
    },
    female/.style = 
    {
        draw = art_deco_dark_pink,
        fill = art_deco_dark_pink!20
    },
    male/.style = 
    {
        draw = art_deco_dark_blue,
        fill = art_deco_dark_blue!20
    },
    neutral/.style = 
    {
        draw = art_deco_dark_antique_copper,
        fill = art_deco_light_apple_core_yellow!20
    }
}

\hbadness = 2300
\hfuzz = 5.5pt

\begin{document}
    \begin{tikzpicture}

        \node[male](01){Me};
        \node[male, below = of 01](02){Brother};
        \node[female, below = of 02](03){Sister};
        \node[female, below = of 03](04){Sister-in-law};
        \node[male, above right = of 01](05){Father};
        \node[female, below right = of 04](06){Mother};
        \node[female, above = of 04](07){Stepmother};

        \coordinate[right = 15pt of 01](aux01);
        \coordinate[right = 15pt of 02](aux02);
        \coordinate[right = 15pt of 03](aux03);
        \coordinate[left = 30pt of 04](aux04);
        \coordinate[right = 15pt of 05](aux05);
        \coordinate[right = 15pt of 06](aux06);
        \coordinate[left = 15pt of 07](aux07);

        \draw (05.west) -| (aux01) |- (06.west);
        \draw (01) -- (aux01);
        \draw (02) -- (aux02);
        \draw (03) -- (aux03);
        \draw (05) -- (aux05);
        \draw (06) -- (aux06);
        \draw (02.west) -| (aux04) |- (04.west);
        \draw (05.west) -| (aux07) |- (07.west);

    \end{tikzpicture}
\end{document}

请注意,05aux05是父亲的标识符,而07aux07是继母(父亲的第二个生命)的标识符。

代码\coordinate[left = 15pt of 07](aux07)表明节点线必须向左完成,因为她是第二个生命。我打算添加一个同父异母的兄弟和他的配偶。

\draw (05.west) -| (aux07) |- (07.west)代码表明父亲与继母有联系。

以下是图片的一部分:

PDF 结果的屏幕截图

如果你想要完整的代码和资产,请点击可共享的链接,点击这里


更新 1

您对此处提供的代码有何问题?

问题出在代码\draw (05.west) -| (aux01) |- (06.west)(汽车、父亲和母亲)和\draw (05.west) -| (aux07) |- (07.west)(父亲和第二任妻子)中。它们有两条节点线,在汽车、父亲和继母之间。父亲和继母线之间的线需要通过增加的空间来分隔。我想在坐标中添加abovebelow使用15pt以增加空间,但没有奏效。我尝试重新设置水平距离,也没有奏效。

答案1

中级编译,尚无解决方案:

  • 注释掉了看似“不错”的内容
  • 使用 pdfLatex 编译

?? 你怎么了 ??

暗示:我在文本中添加了节点名称 01..07,以便更好地遵循您的问题描述......

结果

\documentclass[margin = 10pt, tikz]{standalone}

%\usepackage{adjustbox}
%\usepackage{etoolbox}
%\usepackage{fontspec}
%\usepackage[all]{genealogytree}
%\usepackage{graphicx}
%\usepackage{ifthen}
%\usepackage[utf8]{inputenc}
%\usepackage{pgffor}
%\usepackage{svg}
%\usepackage{tcolorbox}
%\usepackage{tikz}
\usepackage{xcolor}
%
\usetikzlibrary{calc, positioning, shapes, shapes.multipart}
%\pgfdeclarelayer{background}
%\pgfsetlayers{background, main}
%
\definecolor{art_deco_dark_blue}{HTML}{2E3482}
\definecolor{art_deco_dark_pink}{HTML}{E20042}
\definecolor{art_deco_dark_antique_copper}{HTML}{75524D}
\definecolor{art_deco_light_apple_core_yellow}{HTML}{F3EDD5}
%
\newlength{\mypxtoin}
\setlength{\mypxtoin}{0.013889in}
%
\newlength{\mypxtocm}
\setlength{\mypxtocm}{0.026cm}
%
\newlength{\mypxtopt}
\setlength{\mypxtopt}{0.75pt}

\tikzset
{
    font = \fontsize{11\mypxtopt}{2cm},
    every node/.style = 
    { 
        draw,
        font = \fontsize{12\mypxtopt}{2cm},
        rounded corners = {2\mypxtoin},
        text width = 5cm,
    },
    female/.style = 
    {
        draw = art_deco_dark_pink,
        fill = art_deco_dark_pink!20
    },
    male/.style = 
    {
        draw = art_deco_dark_blue,
        fill = art_deco_dark_blue!20
    },
    neutral/.style = 
    {
        draw = art_deco_dark_antique_copper,
        fill = art_deco_light_apple_core_yellow!20
    }
}

\hbadness = 2300
\hfuzz = 5.5pt

\begin{document}
    \begin{tikzpicture}

        \node[male](01){01 Me};
        \node[male, below = of 01](02){02 Brother};
        \node[female, below = of 02](03){03 Sister};
        \node[female, below = of 03](04){04 Sister-in-law};
        \node[male, above right = of 01](05){05 Father};
        \node[female, below right = of 04](06){06 Mother};
        \node[female, above = of 04](07){07 Stepmother};

        \coordinate[right = 15pt of 01](aux01);
        \coordinate[right = 15pt of 02](aux02);
        \coordinate[right = 15pt of 03](aux03);
        \coordinate[left = 30pt of 04](aux04);
        \coordinate[right = 15pt of 05](aux05);
        \coordinate[right = 15pt of 06](aux06);
        \coordinate[left = 15pt of 07](aux07);

        \draw (05.west) -| (aux01) |- (06.west);
        \draw (01) -- (aux01);
        \draw (02) -- (aux02);
        \draw (03) -- (aux03);
        \draw (05) -- (aux05);
        \draw (06) -- (aux06);
        \draw (02.west) -| (aux04) |- (04.west);
        \draw (05.west) -| (aux07) |- (07.west);

    \end{tikzpicture}
\end{document}

相关内容