更改樹中節點之間的距離

更改樹中節點之間的距離

我使用 qtree 套件編寫了以下樹:

\Tree[.F    [.F[0]  [.F[0][0] {[x, y, z]} ]
                        [.F[0][1] {[x, y, z]} ]
                        {\ldots}
                        [.F[0][m-1] {[x, y, z]} ]]
                [.F[1] {\ldots} ]
                {\ldots}
                [.F[n-1] {\ldots} ]]

這給出了: 在此輸入影像描述

然而,當我向 F[n-1] 添加另一個子樹時,樹超出了邊緣。如何減少 F 下節點之間的空間以避免這種情況: 在此輸入影像描述

答案1

透過使用 package forest,您可以輕鬆調整樹節點之間的距離:

\documentclass{article}
\usepackage{geometry}
\usepackage{forest}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
    \begin{center}
\begin{forest}
  for tree = {font=\small,
              s sep=1mm,  % <---
              l sep=3mm   % <--- 
              }
%
[F    
    [{F[0]},fit=band  
        [{F[0][0]}
            [{[x, y, z]}]
        ]
        [{F[0][1]} 
            [{[x, y, z]}]
        ]
        [\ldots]
        [{F[0][m-1]} 
            [{[x, y, z]} ]
        ]
    ]
    [{F[1]},fit=band 
        [{\ldots}]
    ]
    [\ldots]
    [{F[n-1]},fit=band
        [{F[n-1][0]}
            [{[x, y, z]}]
        ]
        [{F[n-1][1]}
            [{[x, y, z]}]
        ]
        [\ldots]
        [{F[n-1][m-1]}
            [{[x, y, z]} ]
        ]
    ]
]
\end{forest}
    \end{center}
\end{document}

在此輸入影像描述

(紅線表示文字邊框)

相關內容