3

I want the first part of the tree is in the first page, the other part in in the second page or even in the third part. I want it can be done automatically.

Here is the code (use Pdflatex), you can see the tree can not be displayed in one page.

\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-qtree}
\usetikzlibrary{positioning}


\tikzset{edge from parent/.style=
{draw,
edge from parent path={(\tikzparentnode.east)
-- +(14pt,0)
|- (\tikzchildnode)}}}

\begin{document}

\begin{tikzpicture}
\tikzset{grow'=right,level distance=100pt}
\tikzset{execute at begin node=\strut}
\tikzset{every tree node/.style={anchor=base west}}
\Tree
[.\node(shixuan){A};
                 [.\node(yusheng){B};
                     [.\node(xun){C};
                         [.\node(shikong){D}; ]
                         [.E ] ]
                     [.F
                         [.F ]
                         [.F ] ]
                     [.F
                         [.G ]
                         [.H ]
                         [.I ] ] ]
                 [.A
                     [.A
                         [.A ]
                         [.E ] ]
                     [.F
                         [.F ]
                         [.F ] ]
                     [.F
                         [.G ]
                         [.H ]
                         [.I ] ] ]
                 [.A
                     [.B
                         [.B ]
                         [.E ] ]
                     [.F
                         [.F ]
                         [.F ] ]
                     [.F
                         [.G ]
                         [.H ]
                         [.I ] ] ]
                 [.A
                     [.B
                         [.B ]
                         [.E ] ]
                     [.F
                         [.F ]
                         [.F ] ]
                     [.F
                         [.G ]
                         [.H ]
                         [.I ] ] ]
                 [.A
                     [.B
                         [.B ]
                         [.E ] ]
                     [.F
                         [.F ]
                         [.F ] ]
                     [.F
                         [.G ]
                         [.H ]
                         [.I ] ] ]
                 [.A
                     [.B
                         [.B ]
                         [.E ] ]
                     [.F
                         [.F ]
                         [.F ] ]
                     [.F
                         [.G ]
                         [.H ]
                         [.I ] ] ]]
\begin{scope}[every node/.style={align=center,
anchor=center, font=\normalsize\sffamily\bfseries,
rectangle,draw,text width=1.4cm,}]
 \node[above= 2mm of shikong ] (thenode) {fifth};
  \node[at =(thenode-|shixuan)] {lll};
  \node[at =(thenode-|yusheng)] {five};
  \node[at =(thenode-|xun)] {aaa};
\end{scope}
\end{tikzpicture}

\end{document}
Jesse
  • 29,686

1 Answers1

1

Not a nice solution and not automatic. I wouldn't do it but if you need it.

First use standalone class to obtain an independent pdf file adjusted to tree dimensions.

% This is file mytree.tex
\documentclass[tikz,border=2mm]{standalone}
\usepackage{tikz}
\usepackage{tikz-qtree}
\usetikzlibrary{positioning}

\tikzset{edge from parent/.style=
{draw,
edge from parent path={(\tikzparentnode.east)
-- +(14pt,0)
|- (\tikzchildnode)}}}

\begin{document}

\begin{tikzpicture}
\tikzset{grow'=right,level distance=100pt}
\tikzset{execute at begin node=\strut}
\tikzset{every tree node/.style={anchor=base west}}
\Tree
[.\node(shixuan){A};
                 [.\node(yusheng){B};
                     [.\node(xun){C};
                         [.\node(shikong){D}; ]
                         [.E ] ]
                     [.F
                         [.F ]
                         [.F ] ]
                     [.F
                         [.G ]
                         [.H ]
                         [.I ] ] ]
                 [.A
                     [.A
                         [.A ]
                         [.E ] ]
                     [.F
                         [.F ]
                         [.F ] ]
                     [.F
                         [.G ]
                         [.H ]
                         [.I ] ] ]
                 [.A
                     [.B
                         [.B ]
                         [.E ] ]
                     [.F
                         [.F ]
                         [.F ] ]
                     [.F
                         [.G ]
                         [.H ]
                         [.I ] ] ]
                 [.A
                     [.B
                         [.B ]
                         [.E ] ]
                     [.F
                         [.F ]
                         [.F ] ]
                     [.F
                         [.G ]
                         [.H ]
                         [.I ] ] ]
                 [.A
                     [.B
                         [.B ]
                         [.E ] ]
                     [.F
                         [.F ]
                         [.F ] ]
                     [.F
                         [.G ]
                         [.H ]
                         [.I ] ] ]
                 [.A
                     [.B
                         [.B ]
                         [.E ] ]
                     [.F
                         [.F ]
                         [.F ] ]
                     [.F
                         [.G ]
                         [.H ]
                         [.I ] ] ]]
\begin{scope}[every node/.style={align=center,
anchor=center, font=\normalsize\sffamily\bfseries,
rectangle,draw,text width=1.4cm,}]
 \node[above= 2mm of shikong ] (thenode) {fifth};
  \node[at =(thenode-|shixuan)] {lll};
  \node[at =(thenode-|yusheng)] {five};
  \node[at =(thenode-|xun)] {aaa};
\end{scope}
\end{tikzpicture}

\end{document}

Second, include previous tree (mytree.pdf) into your main document with \includegraphics command and clip its bounding box.

\documentclass{article}
\usepackage{graphicx}

\begin{document}

\begin{figure}
\centering
\includegraphics[height=.8\textheight,keepaspectratio]{mytree}
\caption{A very long long tree scaled to fit the page height}
\end{figure}

\begin{figure}
\centering
\includegraphics[bb=0 350 450 900,clip]{mytree}
\caption{Top part of previous tree}
\end{figure}

\begin{figure}
\centering
\includegraphics[bb=0 0 450 350,clip]{mytree}
\caption{Bootom part of previous tree}
\end{figure}

\end{document}

Tree

Tree1

Tree2

Ignasi
  • 136,588
  • Thank you . this is a solution. Can I just cut a long tree from the half part in ONE file? – Yiming Feng Mar 27 '15 at 11:47
  • @YimingFeng Could your rephrase your question? I don't understand what do you want to do. With standalone you have the whole tree in one independent file. And now, what do you want to do with it? – Ignasi Mar 27 '15 at 13:31
  • Your method is good. But it is not automatic. Thanks. I am trying other ways. – Yiming Feng Mar 27 '15 at 16:25