在 TikZ 中單獨設定每個兄弟姊妹的距離

在 TikZ 中單獨設定每個兄弟姊妹的距離

我在 LaTeX 中有以下程式碼:

\begin{figure}
    \centering
    \begin{tikzpicture}[nodes={draw, circle}, -, 
        level/.style = {level distance = 1.5cm, sibling distance = 1cm},
        level 1/.style={sibling distance=3cm}]
        \node [minimum size=0.75cm]{$\rightarrow$\strut}
        child { node[rectangle, minimum size=0.75cm] {a\strut} }
        child { node [minimum size=0.75cm] {$\land$} 
            child { node [rectangle, minimum size=0.75cm] {b\strut}}
            child { node [rectangle, minimum size=0.75cm] {c\strut}}
            child { node [rectangle, minimum size=0.75cm] {d\strut}}
            child { node [rectangle, minimum size=0.75cm] {e\strut}}
        }
        child { node[rectangle, minimum size=0.75cm] {g\strut} }
        child { node [minimum size=0.75cm] {$\times$} 
            child { node [rectangle, minimum size=0.75cm] {h\strut}}
            child { node [rectangle, minimum size=0.75cm] {\tau \strut}}
        }
        child { node [minimum size=0.75cm] {$\land$} 
            child { node [rectangle, minimum size=0.75cm] {i\strut}}
            child { node [rectangle, minimum size=0.75cm] {j\strut}}
            child { node [rectangle, minimum size=0.75cm] {k\strut}}
            child { node [rectangle, minimum size=0.75cm] {l\strut}}
            child { node [minimum size=0.75cm] {$\times$} 
                child { node [rectangle, minimum size=0.75cm] {m\strut}}
                child { node [rectangle, minimum size=0.75cm] {\tau \strut}}
            }
        }
        child { node[rectangle, minimum size=0.75cm] {n\strut} };
    \end{tikzpicture}
\end{figure}

它產生以下輸出:

在此輸入影像描述

我如何設定之間的距離G, 這邏輯和, 這乘號正確和所以這樣tau蛋白節點不重疊?

答案1

您可以考慮使用該forest包,預設情況下它將防止重疊節點。

在此輸入影像描述

\documentclass{article}
\usepackage{forest}

\begin{document}

\begin{forest}
for tree={draw, minimum size=.75cm, l sep=7mm, if n children=0{text depth=0, text height=1.5ex}{circle}},
s sep=1cm
[$\rightarrow$, minimum size=1cm
    [a]
    [$\land$
        [b][c][d][e]
    ]
    [g]
    [$\times$
        [h][$\tau$]
    ]
    [$\land$
        [i][j][k][l][$\times$[m][$\tau$]]
    ]
    [n]
]
\end{forest}

\end{document}

相關內容