我在重新创建这些工作分解结构时遇到了一些问题。我在 TeXample.net 上看到过一个类似的例子(这里来源),但我仍然没有得到如下图所示的确切结果。
即使我调整了左右移动,箭头仍然发生了移动。
这是我的想法:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,positioning,shadows,trees}
\definecolor{box-up}{HTML}{ffe6cc}
\definecolor{box-down}{HTML}{dae8fe}
\tikzset{
basic/.style = {draw, text width=6cm,text height=4mm,rectangle,rounded corners=4pt},
root/.style = {basic, thin, align=center, fill=box-up!90, double=box-up},
level 1/.style={sibling distance=80mm,text width=6cm, text height=5mm},
level 2/.style = {basic, thin,align=center, fill=box-up!70, text width=8em},
level 3/.style = {basic, thin, align=center, fill=box-up!50, text width=7em}
}
\begin{document}
\begin{tikzpicture}[
align=center,
edge from parent fork down,
edge from parent/.style={->,draw},
>=latex]
\node[root] {Header}
child {node[level 2] (c1) {Element 1}}
child {node[level 2] (c2) {Element 2}};
\begin{scope}[
anchor = south,
every node/.style={level 3},
edge from parent fork down
]
\node [below right of = c1, yshift=-5pt, xshift=5pt] (c11) {Element 11};
%\node [below left of = c1] (c12) {Element 12};
\node [below of = c2, xshift=15pt] (c21) {Element 21};
\node [below of = c21] (c22) {Element 22};
\node [below of = c22] (c23) {Element 23};
\node [below of = c23] (c24) {Element 24};
\end{scope}
% lines from each level 1 node to every one of its "children"
\draw[->] (c1.195) |- (c11.west);
%\draw[->] (c1.195) |- (c12.west);
\draw[->] (c2.195) |- (c21.west);
\draw[->] (c2.195) |- (c22.west);
\draw[->] (c2.195) |- (c23.west);
\draw[->] (c2.195) |- (c24.west);
\end{tikzpicture}
\end{document}
我把所有东西都放在南边,但箭头却指向左边。我该怎么做呢?
答案1
添加——rounded corners
在根级别
编辑正确的语法是below=of...
和不是below of=...
south anchor
编辑了1 级代码
你可能想看下面的树——https://texample.net/tikz/examples/family-tree/
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,positioning,shadows,trees}
\definecolor{box-up}{HTML}{ffe6cc}
\definecolor{box-down}{HTML}{dae8fe}
\tikzset{
basic/.style = {draw, text width=6cm,text height=4mm,rectangle,rounded corners=4pt},
root/.style = {basic, thin, align=center, fill=box-up!90, double=box-up},
level 1/.style= {sibling distance=80mm,text width=6cm, text height=5mm},
level 2/.style = {basic, thin,align=center, fill=box-up!70, text width=8em},
level 3/.style = {basic, thin, align=center, fill=box-up!50, text width=7em}
}
\begin{document}
\begin{tikzpicture}[
align=center,
edge from parent fork down,
edge from parent/.style={->,draw, rounded corners},
>=latex]
\node[root] {Header}
child {node[level 2] (c1) {Element 1}}
child {node[level 2] (c2) {Element 2}};
\begin{scope}[
anchor = south,
every node/.style={level 3},
edge from parent fork down
]
\node [below right=1em and -3em of c1] (c11) {Element 11};
%\node [below left of = c1] (c12) {Element 12};
\node [below right=1em and -3em of c2] (c21) {Element 21};
\node [below of = c21] (c22) {Element 22};
\node [below of = c22] (c23) {Element 23};
\node [below of = c23] (c24) {Element 24};
\end{scope}
% lines from each level 1 node to every one of its "children"
\draw[->] (c1.south) |- (c11.west);
\draw[->] (c2.south) |- (c21.west);
\draw[->] (c2.south) |- (c22.west);
\draw[->] (c2.south) |- (c23.west);
\draw[->] (c2.south) |- (c24.west);
\end{tikzpicture}
\end{document}