如何在 tikz-qtree 上的节点内断线?

如何在 tikz-qtree 上的节点内断线?

我想在节点内断线。

下面的代码没有给出期望的结果:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{tikz-qtree} %-----questo è il pacchetto interessante
\tikzset{edge from parent/.style=
{draw,
edge from parent path={(\tikzparentnode.south)
-- +(0,-8pt)
-| (\tikzchildnode)}}}

\begin{document}

\begin{tikzpicture}
\Tree [.CP [.NP \node(wh){what}; ]
[.C$'$ [.I did ]
[.\node[draw]{IP};
[.NP [.Det the ] [.N cat ] ]
[.VP [.V sit ]
[.PP [.P on ]
[.\node[draw]{Comunicaz\\all interesting\\denied of\\activate of....};
[.NP [.Det a ] [.N book ] ]
[.PP [.P about ] [.NP \node(t){$t$}; ] ] ] ] ] ] ] ]
\draw[semithick,->] (t)..controls +(south west:5) and +(south:5)..(wh);
\end{tikzpicture}

\end{document}

我怎样才能获得一个正常的盒子而不扩大它的尺寸来容纳所有的单词?

答案1

正如 Heiko Oberdiek 所评论的,将大型节点放入图表中相当尴尬。如果您想不出更好的表示方法,您可以随时使用\tiny或各种方法缩小大型节点内的文本。可以通过多种方式添加换行符,如果您只想手动添加换行符,则可以使用align

\documentclass{standalone}
\usepackage{tikz}
\usepackage{tikz-qtree} %-----questo è il pacchetto interessante
\tikzset{edge from parent/.style=
{draw,
edge from parent path={(\tikzparentnode.south)
-- +(0,-8pt)
-| (\tikzchildnode)}}}

\begin{document}

\begin{tikzpicture}
\Tree [.CP [.NP \node(wh){what}; ]
[.C$'$ [.I did ]
[.\node[draw]{IP};
[.NP [.Det the ] [.N cat ] ]
[.VP [.V sit ]
[.PP [.P on ]
[.\node[draw, font=\tiny, align=center]{Comunicaz all interesting \\ denied of activate of....};
[.NP [.Det a ] [.N book ] ]
[.PP [.P about ] [.NP \node(t){$t$}; ] ] ] ] ] ] ] ]
\draw[semithick,->] (t)..controls +(south west:5) and +(south:5)..(wh);
\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容