我怎样才能延长大支架,使其不仅覆盖yyyy
而且还能覆盖uuuu
节点?
\tikzstyle{level 1}=[level distance=3.5cm, sibling distance=3.5cm]
\tikzstyle{level 2}=[level distance=3.5cm, sibling distance=2cm]
\begin{figure}
\centering
\begin{tikzpicture}[grow=right, sloped]
\node[draw] {ppp\textsuperscript{p}}
child {
node[draw, circle, label=right:
{$xxxx$}]
{}
edge from parent
node[above] {xx}
node[below] {$xxxx$}
}
child {
node[draw, circle, label=right:
{$uuuu$}]
{}
edge from parent
node[above] {uu}
node[below] {$uuuu$}
}
child {
node[draw, circle,label=right:
{$yyyy \Bigg\} $}]
{}
edge from parent
node[above] {yy}
node[below] {$yyyy$}
};
\end{tikzpicture}
\end{figure}
答案1
我\smash
编辑了又\raisebox
编辑一个零宽度\rule
,它后面跟着一个右括号。
\documentclass{article}
\usepackage{tikz}
\begin{document}
\tikzstyle{level 1}=[level distance=3.5cm, sibling distance=3.5cm]
\tikzstyle{level 2}=[level distance=3.5cm, sibling distance=2cm]
\begin{figure}
\centering
\begin{tikzpicture}[grow=right, sloped]
\node[draw] {ppp\textsuperscript{p}}
child {
node[draw, circle, label=right:
{$xxxx$}]
{}
edge from parent
node[above] {xx}
node[below] {$xxxx$}
}
child {
node[draw, circle, label=right:
{$uuuu$}]
{}
edge from parent
node[above] {uu}
node[below] {$uuuu$}
}
child {
node[draw, circle,label=right:
{$yyyy
\smash{\raisebox{-52pt}{$\left.\rule{0pt}{60pt}\right\}$}} $}]
{}
edge from parent
node[above] {yy}
node[below] {$yyyy$}
};
\end{tikzpicture}
\end{figure}
\end{document}
答案2
您可以为相关节点添加标签
child {
node[draw, circle, label=right:
{$uuuu$}] (U)
{}
类似地(Y)
,然后你可以画一个括号作为装饰:
\draw [decoration={brace,amplitude=8pt},decorate] ($(Y)+(3.5em,1ex)$) -- ($(U)+(3.5em,-1ex)$);
由于标签和需要获得额外的高度,因此需要此处的偏移量。我已根据ex
和指定了这些em
,因为这些是取决于字体大小的单位。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,calc}
\begin{document}
\tikzstyle{level 1}=[level distance=3.5cm, sibling distance=3.5cm]
\tikzstyle{level 2}=[level distance=3.5cm, sibling distance=2cm]
\begin{figure}
\centering
\begin{tikzpicture}[grow=right, sloped]
\node[draw] {ppp\textsuperscript{p}}
child {
node[draw, circle, label=right:
{$xxxx$}]
{}
edge from parent
node[above] {xx}
node[below] {$xxxx$}
}
child {
node[draw, circle, label=right:
{$uuuu$}] (U)
{}
edge from parent
node[above] {uu}
node[below] {$uuuu$}
}
child {
node[draw, circle,label=right:
{$yyyy$}] (Y)
{}
edge from parent
node[above] {yy}
node[below] {$yyyy$}
};
\draw [decoration={brace,amplitude=8pt},decorate] ($(Y)+(3.5em,1ex)$) -- ($(U)+(3.5em,-1ex)$);
\end{tikzpicture}
\end{figure}
\end{document}