使用 QTree 包,是否可以向节点添加形状?例如,正方形或圆形?
答案1
\documentclass{scrartcl}
\usepackage{tikz,qtree}
\usetikzlibrary{shapes}
\begin{document}
\def\adddiam#1{\tikz\node[draw,shape=diamond]{#1};}
\def\addsquare#1{\tikz\node[draw]{#1};}
\Tree [.CP \addsquare{Spec(CP)} [ C^0 [.IP I^0 \adddiam{Comp(IP)} ] ] ]
\end{document}
答案2
尽管 Altermundus 的解决方案效果很好,但还有一个版本旨在qtree
与 tikz 无缝协作:tikz-qtree
,因此使用它来完成这项任务更有意义。这允许您轻松连接节点、更改节点边缘等。以下是一个例子:
\documentclass[11pt]{article}
\usepackage{tikz-qtree,tikz-qtree-compat}
\begin{document}
\begin{tikzpicture}
\Tree [.CP [.DP \node(wh){who}; ]
[.C\1 [.C \node(c){did}; ]
[.\node[draw]{TP}; [.DP Bill ] [.T\1 [.T \node(T){t}; ]
[.\node[draw,circle]{VP}; [.V see ]
[.DP \node(tr){t}; ]]]]]]
\draw[semithick,->] (tr)..controls +(south west:3) and +(south:3) .. (wh);
\draw[semithick,->] (T)..controls +(south west:2) and +(south:2) .. (c);
\end{tikzpicture}
\end{document}