我正在使用tikz-qtree
包绘制一棵树。节点中有很多文本。我发现很难让边缘与节点的边缘相遇。对于一些包含大量文本的节点,边缘太远了。代码是
\documentclass{minimal}
\usepackage{graphicx}
\usepackage{a4wide}
\usepackage{fullpage}
\usepackage{tikz}
\usetikzlibrary{shapes, positioning, shadows, trees}
\usepackage{tikz-dependency}
\usepackage{tikz-qtree}
\begin{document}
%===================================================
\centering
\begin{tikzpicture}
\tikzset{font=\small,
edge from parent fork down,
level distance=2.7cm,
every node/.style=
{top color=white,
bottom color=blue!10,
rectangle,rounded corners,
%minimum height=8mm,
draw=black,
thick,
align=center,
sibling distance = 4ex,
%text depth = 0pt
},
edge from parent/.style=
{draw=black,
thick
}}
\Tree [.Morphemes [.Free-standing [.Open-class {cat, chase, dog} ] [.Closed-class {(1) Pronouns; she, him\\(2) Determiners; the, this\\(3) Prepositions; on, at\\(4) Auxilary verbs;\\ \textit{have} done, \textit{is} doing} ] ]
[.Bound [.Open-class NONE ] [.Closed-class
[.Derivational {care-less\\un-wind} ] [.Inflectional {(1) Tense/Agreement marking on verbs;\\He go-es, They laugh-ed\\(2) Plural marking on nouns;\\dog-s, cat-s} ]
]]
]
\end{tikzpicture}
%====================================================
\end{document}
重叠部分如下。欢迎提供任何提示。
答案1
parent
您需要描述从节点到的路径child node
。我参考了文档第 4 页的最后一个示例tikz-qtree
。
代码:
\documentclass{article}
\usepackage{tikz-qtree}
\usetikzlibrary{trees}
\begin{document}
%===================================================
\centering
\begin{tikzpicture}
\tikzset{font=\small,
edge from parent fork down,
level distance=2.7cm,
every node/.style=
{top color=white,
bottom color=blue!10,
rectangle,rounded corners,
%minimum height=8mm,
draw=black,
thick,
align=center,
sibling distance = 4ex,
%text depth = 0pt
},
edge from parent/.style=
{draw=black,
thick,
% |-|-| here starts the new part
edge from parent path={(\tikzparentnode.south)
-- +(0,-8pt)
-| (\tikzchildnode)}
}}
\Tree [.Morphemes [.Free-standing [.Open-class {cat, chase, dog} ] [.Closed-class {(1) Pronouns; she, him\\(2) Determiners; the, this\\(3) Prepositions; on, at\\(4) Auxilary verbs;\\ \textit{have} done, \textit{is} doing} ] ]
[.Bound [.Open-class NONE ] [.Closed-class
[.Derivational {care-less\\un-wind} ] [.Inflectional {(1) Tense/Agreement marking on verbs;\\He go-es, They laugh-ed\\(2) Plural marking on nouns;\\dog-s, cat-s} ]
]]
]
\end{tikzpicture}
%====================================================
\end{document}
结果: