如何让树更加紧凑?

如何让树更加紧凑?

我正在使用该qtree包,并且我制作了一棵树,它伸展得太大,因此无法放在页面上。这是我的代码:

\Tree [.1/1 [.1/2 [.1/3 [.1/4  [.1/5 1/6 2/9 ]   [.2/7 3/11 3/10 ]  ] [.2/5  [.3/8 4/11 7/12 ]   [.3/7 5/12 4/9 ]  ] ] [.2/3 [.3/5  [.4/7 5/9 7/12 ]   [.5/8 8/13 7/11 ]  ] [.3/4  [.5/7 7/10 8/11 ]   [.4/5 7/9 5/6 ]  ] ] ] [.2/1 [.3/2 [.4/3  [.5/4 6/5 9/7 ]   [.7/5 11/8 10/7 ]  ] [.5/3  [.8/5 11/7 13/8 ]   [.7/4 12/7 9/5 ]  ] ] [.3/1 [.5/2  [.7/3 9/4 12/5 ]   [.8/3 12/7 11/4 ]  ] [.4/1  [.7/2 10/3 11/3 ]   [.5/1 9/2 6/1 ]  ] ] ] ]

有没有办法使得每个节点到下一个节点的线变得更小并且所有节点之间的间距变得更小?

谢谢

答案1

你可能还想使用tikz-qtree对于这个(语法相同):

\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{graphicx}
\usepackage{tikz-qtree}
\begin{document}

\begin{tikzpicture}[scale=.5]
\Tree [.1/1 [.1/2 [.1/3 [.1/4  [.1/5 1/6 2/9 ]   [.2/7 3/11 3/10 ]  ] [.2/5  [.3/8 4/11 7/12 ]   [.3/7 5/12 4/9 ]  ] ] [.2/3 [.3/5  [.4/7 5/9 7/12 ]   [.5/8 8/13 7/11 ]  ] [.3/4  [.5/7 7/10 8/11 ]   [.4/5 7/9 5/6 ]  ] ] ] [.2/1 [.3/2 [.4/3  [.5/4 6/5 9/7 ]   [.7/5 11/8 10/7 ]  ] [.5/3  [.8/5 11/7 13/8 ]   [.7/4 12/7 9/5 ]  ] ] [.3/1 [.5/2  [.7/3 9/4 12/5 ]   [.8/3 12/7 11/4 ]  ] [.4/1  [.7/2 10/3 11/3 ]   [.5/1 9/2 6/1 ]  ] ] ] ]
\end{tikzpicture}
\end{document}

答案2

\documentclass{article}
\usepackage{graphicx,pdflscape}
\usepackage{qtree}

\begin{document}
\noindent
\resizebox{\linewidth}{!}{%
  \Tree [.1/1 [.1/2 [.1/3 [.1/4 [.1/5 1/6 2/9 ] [.2/7 3/11 3/10 ] ] [.2/5 [.3/8 4/11 7/12 ] [.3/7 5/12 4/9 ] ] ] [.2/3 [.3/5 [.4/7 5/9 7/12 ] [.5/8 8/13 7/11 ] ] [.3/4 [.5/7 7/10 8/11 ] [.4/5 7/9 5/6 ] ] ] ] [.2/1 [.3/2 [.4/3 [.5/4 6/5 9/7 ] [.7/5 11/8 10/7 ] ] [.5/3 [.8/5 11/7 13/8 ] [.7/4 12/7 9/5 ] ] ] [.3/1 [.5/2 [.7/3 9/4 12/5 ] [.8/3 12/7 11/4 ] ] [.4/1 [.7/2 10/3 11/3 ] [.5/1 9/2 6/1 ] ] ] ] ]%
}

\begin{landscape}
\thispagestyle{empty}
\hspace*{-0.1\linewidth}\resizebox{1.2\linewidth}{!}{%
  \Tree [.1/1 [.1/2 [.1/3 [.1/4 [.1/5 1/6 2/9 ] [.2/7 3/11 3/10 ] ] [.2/5 [.3/8 4/11 7/12 ] [.3/7 5/12 4/9 ] ] ] [.2/3 [.3/5 [.4/7 5/9 7/12 ] [.5/8 8/13 7/11 ] ] [.3/4 [.5/7 7/10 8/11 ] [.4/5 7/9 5/6 ] ] ] ] [.2/1 [.3/2 [.4/3 [.5/4 6/5 9/7 ] [.7/5 11/8 10/7 ] ] [.5/3 [.8/5 11/7 13/8 ] [.7/4 12/7 9/5 ] ] ] [.3/1 [.5/2 [.7/3 9/4 12/5 ] [.8/3 12/7 11/4 ] ] [.4/1 [.7/2 10/3 11/3 ] [.5/1 9/2 6/1 ] ] ] ] ]%
}
\end{landscape}

\end{document}

相关内容