![如何在 Tikz 思维导图中排序节点](https://linux22.com/image/331774/%E5%A6%82%E4%BD%95%E5%9C%A8%20Tikz%20%E6%80%9D%E7%BB%B4%E5%AF%BC%E5%9B%BE%E4%B8%AD%E6%8E%92%E5%BA%8F%E8%8A%82%E7%82%B9.png)
我刚刚尝试使用 tikz 思维导图,但出现了问题。我不知道如何设置节点 (1) 的两个子节点的左右两侧。它们之间始终有 60° 的间距,我希望它们相隔 180°。
我尝试了水平距离等,grow=left
但right
都不起作用。我不想改变整个子节点的顺序,只想改变顶部节点的顺序。
这是我的代码:
\documentclass[margin=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes}
\usetikzlibrary{mindmap,trees}
\begin{document}
\pagestyle{empty}
\begin{tikzpicture}
\path[mindmap,concept color=black,text=white]
node[concept] {\normalsize{Reibungsreduktion am Ventiltrieb}}
[clockwise from=30]
child[concept color=blue] {
node[concept] {5}
[clockwise from=60]
child { node[concept] {\scriptsize{a}} }
child { node[concept] {\scriptsize{b} }}
child { node[concept] {\scriptsize{c} }}
}
child[concept color=blue] {
node[concept] {4}
[clockwise from=0]
child { node[concept] {\scriptsize a} }
child { node[concept] {\scriptsize{b} } }
child { node[concept] {\scriptsize{c}} }
}
child[concept color=blue] {
node[concept] {3}
[clockwise from=-60]
child { node[concept] {\scriptsize{a} }}
child { node[concept] {\scriptsize{b} }}
child { node[concept] {\scriptsize{c} }}
}
child[concept color=blue] {
node[concept] {2}
[clockwise from=240]
child { node[concept] {\scriptsize{a}} }
child { node[concept] {\scriptsize{b}} }
}
child[concept color=blue] {
node[concept] {6}
[clockwise from=240]
child { node[concept] {\scriptsize{a}} }
child { node[concept] {\scriptsize{b}} }
}
child[concept color=blue] {
node[concept] {1}
[clockwise from=0]
child { node[concept] {\scriptsize{a}} }
child { node[concept] {\scriptsize{b} }}
};
\end{tikzpicture}
\end{document}
答案1
像这样添加[main/.style={sibling angle=180}]
到您的:tikzpicture
\begin{tikzpicture}[main/.style={sibling angle=180}]
然后你可以用节点来编写部分,1
如下:
...
child[concept color=blue] {
node[concept] {1}
[clockwise from =0]
child[main] { node[concept] {\scriptsize{a}} }
child[main] { node[concept] {\scriptsize{b} }}
};
...
结果如下:
答案2
我谦虚地提出了一个小的替代方案:
child[grow=0] { node {a} }
child[grow=180] { node {b }}
和...一起
\begin{tikzpicture}[
every node/.append style={concept},
level 2 concept/.append style={node font=\scriptsize}]
这样,您就不必指定每个节点node
,也不必在每次位于节点时concept
都进行指定。scriptsize
level 2
完整代码如下:
% arara: pdflatex
% !arara: indent: {overwrite: yes}
\documentclass[margin=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{mindmap}
\begin{document}
\begin{tikzpicture}[
every node/.append style={concept},
level 2 concept/.append style={node font=\scriptsize}]
\path[mindmap,concept color=black,text=white]
node {\normalsize{Reibungsreduktion am Ventiltrieb}}
[clockwise from=30]
child[concept color=blue] {
node {5}
[clockwise from=60]
child { node {a} }
child { node {b}}
child { node {c}}
}
child[concept color=blue] {
node {4}
[clockwise from=0]
child { node {a} }
child { node {b} }
child { node {c} }
}
child[concept color=blue] {
node {3}
[clockwise from=-60]
child { node {a}}
child { node {b}}
child { node {c}}
}
child[concept color=blue] {
node {2}
[clockwise from=240]
child { node {a} }
child { node {b} }
}
child[concept color=blue] {
node {6}
[clockwise from=240]
child { node {a} }
child { node {b} }
}
child[concept color=blue] {
node {1}
child[grow=0] { node {a} }
child[grow=180] { node {b}}
};
\end{tikzpicture}
\end{document}