![如何水平反映复制的树?](https://linux22.com/image/268191/%E5%A6%82%E4%BD%95%E6%B0%B4%E5%B9%B3%E5%8F%8D%E6%98%A0%E5%A4%8D%E5%88%B6%E7%9A%84%E6%A0%91%EF%BC%9F.png)
我正在遵循以下解决方案这个帖子使用 构造一棵树tikz-qtree
。正如下图所示,它运行良好。
这棵树是为了展示锦标赛的比赛。
但我想反映(复制)树来显示其他匹配项,即从champion
到向上,Finalist 2
依此类推。
这是我的代码:
\documentclass[landscape]{article}
\usepackage[margin=1in,a3paper]{geometry}
\usepackage{tikz-qtree}
\usetikzlibrary{shadows,trees}
\begin{document}
\begin{tikzpicture}
\Tree [.Champion
[.{Finalist 1}
[.{Semi Finalist 1}
[.{kk}
[. kk ]
[. kk ] ]
[.{kk}
[. kk ]
[. kk ] ] ]
[.{Semi finalist 2}
[.{kk}
[. kk ]
[. kk ] ]
[.{kk}
[. kk ]
[. kk ] ] ]
]
]
\end{tikzpicture}
\end{document}
答案1
您可以按照 Qrrbrbirlbel 的建议进行操作(除非我误解了您的意思。)
\documentclass[landscape]{article}
\usepackage[margin=1in,a3paper]{geometry}
\usepackage{tikz-qtree}
\usetikzlibrary{shadows,trees}
\tikzset{font=\small,
edge from parent fork down,
level distance=1.75cm,
every node/.style=
{top color=white,
bottom color=blue!25,
rectangle,rounded corners,
minimum height=8mm,
draw=blue!75,
very thick,
drop shadow,
align=center,
text depth = 0pt
},
edge from parent/.style=
{draw=blue!50,
thick
}}
\begin{document}
\begin{tikzpicture}
\begin{scope}[edge from parent fork up,grow'=up]
\Tree [
[.{Finalist 1}
[.{Semi Finalist 1}
[.{kk}
[. kk ]
[. kk ] ]
[.{kk}
[. kk ]
[. kk ] ] ]
[.{Semi finalist 2}
[.{kk}
[. kk ]
[. kk ] ]
[.{kk}
[. kk ]
[. kk ] ] ]
]
]
\end{scope}
\begin{scope}
\Tree [.Champion
[.{Finalist 1}
[.{Semi Finalist 1}
[.{kk}
[. kk ]
[. kk ] ]
[.{kk}
[. kk ]
[. kk ] ] ]
[.{Semi finalist 2}
[.{kk}
[. kk ]
[. kk ] ]
[.{kk}
[. kk ]
[. kk ] ] ]
]
]
\end{scope}
\end{tikzpicture}
\end{document}
答案2
代码
\documentclass[tikz,convert=false]{standalone}
\usepackage{tikz-qtree}
\usetikzlibrary{shadows,trees,positioning}
\tikzset{
font=\small,
level distance=1.75cm,
every node/.style={
top color=white,
bottom color=blue!25,
rectangle,rounded corners,
minimum height=8mm,
draw=blue!75,
very thick,
drop shadow,
align=center,
text depth = 0pt
},
edge from parent/.style={
draw=blue!50,
thick
}
}
\makeatletter
\tikzset{
link tree/.style args={#1of#2}{% not so sure about this ...
every tree node/.append style={#1=\the\tikzleveldistance of #2\if\relax\detokenize{\tikz@growth@anchor}\relax\else.\tikz@growth@anchor\fi,anchor=center}
}
}
\makeatother
\begin{document}
\begin{tikzpicture}
\node[every tree node/.try] (champ) {Champion};
\begin{scope}[link tree=above of champ, grow=up,edge from parent fork up]
\Tree [.\node (fin2) {Finalist 2};
[.{Semi Finalist 3}
[.{kk}
[. kk ]
[. kk ] ]
[.{kk}
[. kk ]
[. kk ] ] ]
[.{Semi finalist 4}
[.{kk}
[. kk ]
[. kk ] ]
[.{kk}
[. kk ]
[. kk ] ] ]
]
\end{scope}
\begin{scope}[link tree=below of champ, grow=down, edge from parent fork down]
\Tree
[.\node (fin1) {Finalist 1};
[.{Semi Finalist 1}
[.{kk}
[. kk ]
[. kk ] ]
[.{kk}
[. kk ]
[. kk ] ] ]
[.{Semi finalist 2}
[.{kk}
[. kk ]
[. kk ] ]
[.{kk}
[. kk ]
[. kk ] ] ]
]
\end{scope}
\path[edge from parent] (champ) edge (fin2) edge (fin1);
\end{tikzpicture}
\end{document}