目标:我想要一种更系统的方法来围绕多个节点绘制形状tikz-qtree
,其中节点通过边连接。
- 目前,我手动调整
inner xsep
每个inner ysep
形状的旋转,直到它刚好围绕我想要的节点。 - 否则,默认情况下
fit
会制作一个大的规则形状(正方形或圆形),倾向于舀起一些我不想要的节点或标签。 - 我怎样才能一劳永逸地定义一种形状,而不必每次都手动
xsep
调整?ysep
rotate
\documentclass{standalone}
\usepackage{tikz,tikz-qtree}
\begin{document}
\begin{tikzpicture}
\Tree[.\node(T){T}; Subject [.\node(Aux){Aux}; Aux [.\node(Asp){Asp}; Adverb [.\node(V){V}; Verb Object ] ] ] ]
\node[draw,fit=(T)(Aux),style={ellipse,draw,red,inner xsep=0pt,inner ysep=-10pt,rotate=-40}](maa){};
\node[draw,fit=(Asp)(V),style={rounded corners,inner ysep=-8pt,rotate=-28}]{};
\end{tikzpicture}
\end{document}
答案1
Torbjørn T. 帮我找到了解决方案!谢谢!
\documentclass{standalone}
\usepackage{tikz,tikz-qtree}
\usetikzlibrary{matrix}
\pgfdeclarelayer{background}
\pgfsetlayers{background,main}
\tikzset{
my box/.style = {
, line cap = round
, line join = round
}
}
\newcommand{\highlight}[3]{
\path [my box, line width = 1.15 * #1, draw = #2] #3;
\pgfmathsetmacro{\innerlinewidth}{1.1 * #1}
\path [my box, line width = \innerlinewidth, draw = #2!10] #3;
}
\begin{document}
\begin{tikzpicture}
\Tree[.\node(T){T}; Subject [.\node(Aux){Aux}; Aux [.\node(Asp){Asp}; Adverb [.\node(V){V}; Verb Object ] ] ] ]
\begin{pgfonlayer}{background}
\highlight{12mm}{blue}{(Asp) -- (V)}
\end{pgfonlayer}
\end{tikzpicture}
\begin{tikzpicture}
\Tree[.\node(T){T}; Subject [.\node(Aux){Aux}; Aux [.\node(Asp){Asp}; Adverb [.\node(V){V}; Verb Object ] ] ] ]
\begin{pgfonlayer}{background}
\highlight{12mm}{red}{(T) -- (V)}
\end{pgfonlayer}
\end{tikzpicture}
\end{document}