TikZ bug(功能?):子節點奇怪地向右傾斜

TikZ bug(功能?):子節點奇怪地向右傾斜

我試著把一棵樹放在一棵樹旁邊。然後我發現第二棵樹傾斜得很奇怪。即使我將節點更改為矩陣節點,問題仍然存在。

\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}

在此輸入影像描述

相關內容