
서로 아래에 놓기를 원하는 2개의 qtree가 있다고 가정합니다.
\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-qtree,tikz-qtree-compat}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\Tree
[.{1}
[.1-1 ]
[.\node (1) {1-2}; ]
]
\node [below = 0.5cm of 1.south] (note-1) {la la la};
\draw[-]
(note-1.north) -- (1.south);
\Tree
[.{2}
[.2-1 ]
[.2-2 ]
]
\end{tikzpicture}
\end{document}
이제 나무가 겹쳐집니다. 첫 번째에는 별도의 노드에 있는 'la la la' 주석이 있습니다. 그것이 없다면 두 나무를 모두 노드에 넣고 노드를 배치할 수 있었습니다. 그러나 베어 qtree를 배치하는 방법은 무엇입니까? 따라서 그들의 뿌리는 수평으로 일치하고 두 번째 나무는 'la la la' 아래에 있게 됩니다.
답변1
로 구분된 두 개의 서로 다른 TikZ 그림을 사용하는 것 외에도 \\
수동으로 추가된 노드를 사용하여 note-1
전체 두 번째 트리를 아래로 이동할 수 있습니다.
이미 정의된 트리 노드를 사용할 수도 있지만 보조 좌표(코드 2)를 사용하여 좌표를 다시 설정해야 합니다.
% somewhere in the tree:
[. \node (lowest node) {1-2-2-1-1}; ]
% outside of tree:
\coordinate (aux1) at (lowest node);
% The coordinate aux1 can now be used for placement, e.g.
% below=of toptree |- aux1
에서는 이 아래에 배치되었는지 확인 |-
합니다 .2
1
코드 1
\documentclass[tikz]{standalone}
\usepackage{tikz,tikz-qtree,tikz-qtree-compat}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\Tree
[.\node (toptree) {1};
[.1-1 ]
[.\node (1) {1-2}; ]
]
\node [below = 0.5cm of 1.south] (note-1) {la la la};
\draw[-] (note-1.north) -- (1.south);
\begin{scope}[every tree node/.append style={below=of toptree |- note-1.south}]
\Tree
[.2
[.2-1 ]
[.2-2 ]
]
\end{scope}
\end{tikzpicture}
\end{document}
코드 2
\documentclass[tikz]{standalone}
\usepackage{tikz,tikz-qtree,tikz-qtree-compat}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\Tree
[.\node (toptree) {1};
[.1-1 ]
[.1-2
[.1-2-1
[.1-2-2-1
[. \node (lowest node) {1-2-2-1-1}; ]
]
]
]
]
\coordinate (aux1) at (lowest node);
\begin{scope}[opacity=.5,every tree node/.append style={below=of toptree |- lowest node}]
\Tree
[.2
[.2-1 ]
[.2-2 ]
]
\end{scope}
\begin{scope}[every tree node/.append style={below=of toptree |- aux1}]
\Tree
[.2
[.2-1 ]
[.2-2 ]
]
\end{scope}
\end{tikzpicture}
\end{document}
산출
답변2
scope
두 번째 트리에 대해 적절한 이동과 함께 a를 사용할 수 있습니다 .
\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-qtree,tikz-qtree-compat}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\Tree
[.1
[.1-1 ]
[.\node (1) {1-2}; ]
]
\node [below = 0.5cm of 1.south] (note-1) {la la la};
\draw[-]
(note-1.north) -- (1.south);
\begin{scope}[yshift=-3cm]
\Tree
[.2
[.2-1 ]
[.2-2 ]
]
\end{scope}
\end{tikzpicture}
\end{document}