1

I try to put a tree next to a tree. Then I find the second tree is leaning strangely. Even if I change the node to a matrix node, the problem is still there.

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

Two trees next to each other

0

1 Answer 1

3

Never (directly) nest tikzpicture in node of another tikzpicture. If you like to have two tree diagrams as one image, than see, if the following solution works for you:

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

enter image description here

3
  • Thank you for your answer. It shall suffice for the simple case. But I still wonder why this problem also appears even when I use matrix node instead of nesting tikzpicture?
    – MMM
    Commented Nov 9, 2020 at 5:33
  • @MMM, please show a "unsimple" case., which not give the same result (vertical branches) as proposed solution. How matrix replace nesting figures? Sorry, for help more information is needed. The best is ask a new question.
    – Zarko
    Commented Nov 9, 2020 at 6:58
  • Thank you for your answer. I manage to locate the problem. It is due to the positioning right = of on matrix node. I find a workaround by using achnors, see here. Now I can draw more complicated Hasse diagram.
    – MMM
    Commented Nov 15, 2020 at 7:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .