TikZ 错误(功能?):子节点奇怪地向右倾斜

TikZ 错误(功能?):子节点奇怪地向右倾斜

我尝试将一棵树放在另一棵树旁边。然后我发现第二棵树倾斜得很奇怪。即使我将节点更改为矩阵节点,问题仍然存在。

\documentclass[tikz]{standalone}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
    [level distance = 10mm]

    \node [label=left:{$T_1$}] (T1)
    {
            \begin{tikzpicture}
                [every node/.style={draw, circle, inner sep=1pt, minimum size = 1mm}]
                \node {}
                child {node {} child {node {}}}
                child {node {} child {node {}}}
                child {node {} child {node {}}};
            \end{tikzpicture}
        };

    \node [right = of T1, label=left:{$T_2$}] (T2)
    {
            \begin{tikzpicture}
                [every node/.style={draw, circle, inner sep=1pt, minimum size = 1mm}]
                \node {}
                child {node {} child {node {}}}
                child {node {} child {node {}}}
                child {node {} child {node {}}};
            \end{tikzpicture}
        };

\end{tikzpicture}
\end{document}

两棵树相邻

答案1

切勿(直接)将 tikzpicture 嵌套在另一个 tikzpicture 的节点中。如果您希望将两个树形图合并为一个图像,请查看以下解决方案是否适合您:

\documentclass[tikz, border=3mm]{standalone}
\usetikzlibrary{positioning}

\tikzset{
    every node/.style={draw, circle, inner sep=1pt, minimum size = 1mm},
    label distance = 3mm,
    node distance = 33mm,
    sibling distance=11mm,
    level distance=9mm
        }
\begin{document}
    \begin{tikzpicture}
        \node (T1)  {}
        child {node[label=left:$T_1$] {} child {node {}}}
        child {node {} child {node {}}}
        child {node (T1R) {} child {node {}}};

        \node [right=of T1 -| T1R]{}
        child {node[label=left:$T_2$] {} child {node {}}}
        child {node {} child {node {}}}
        child {node {} child {node {}}};
    \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容