![使用边缘样式时水平 tikz-qtree 级别距离太大](https://linux22.com/image/305078/%E4%BD%BF%E7%94%A8%E8%BE%B9%E7%BC%98%E6%A0%B7%E5%BC%8F%E6%97%B6%E6%B0%B4%E5%B9%B3%20tikz-qtree%20%E7%BA%A7%E5%88%AB%E8%B7%9D%E7%A6%BB%E5%A4%AA%E5%A4%A7.png)
在对 tikz-qtree 进行了大量调整后,我最终得到了下面的结果。但我不知道为什么XML
节点后的级别距离太长,即使level distance
为该级别设置了,线条仍然又长又粗。
\documentclass[12pt]{paper}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[francais]{babel}
% tree
\usepackage{tikz}
\usepackage{tikz-qtree}
\usetikzlibrary{positioning,babel,trees}
\begin{document}
\begin{tikzpicture}[grow'=right,level distance=1.2in,sibling distance=.05in]
\tikzset{edge from parent/.style={thick, draw, edge from parent fork right},
every tree node/.style={draw,minimum width=1in,text width=1in,align=center},
level 1/.style={sibling distance=-40mm},
level 2/.style={level distance=10mm}}
\Tree [.SGML {HTML 4.0} [.\node(x) {XML}; [ XHTML XML DOM [.XSL XSLT XSL-FO XPath ] XQuery DTD XSD SOAP WSDL RDF RSS SVG ] ] ]
\end{tikzpicture}
\end{document}
编辑:.\node(x) {XML};
或者.XML
不做任何改变
答案1
如果你不介意更换软件包,你可以使用强大的forest
:
\documentclass[tikz,border=5pt]{standalone}
\usepackage{forest}
\begin{document}
\begin{forest}
for tree={
edge path={
\noexpand\path [draw, thick, \forestoption{edge}] (!u.parent anchor) -- +(5pt,0) |- (.child anchor)\forestoption{edge label};
},
parent anchor=east,
child anchor=west,
grow'=east,
text centered,
draw,
thick,
minimum width=1in,
text width=1in
}
[SGML [HTML 4.0] [XML [XHTML] [XML] [DOM] [XSL [XSLT] [XSL-FO] [XPath]] [XQuery] [DTD] [XSD] [SOAP] [WSDL] [RDF] [RSS] [SVG]]]
\end{forest}
\end{document}