帮助 tikzpicture 进行 WBS(工作分解结构)

帮助 tikzpicture 进行 WBS(工作分解结构)

我需要你的帮助来提升我的硕士论文 WBS

这是代码:

\usepackage{tikz}
\usetikzlibrary{arrows,shapes,positioning,shadows,trees}
\tikzset{
    basic/.style  = {draw, text width=2cm, drop shadow, font=\sffamily, rectangle},
    root/.style   = {basic, rounded corners=2pt, thin, align=center,
        fill=gray!60},
    level 2/.style = {basic, rounded corners=6pt, thin,align=center, fill=gray!45,
        text width=8em},
    level 3/.style = {basic, thin, align=left, fill=gray!30, text width=6.5em}
}
    
\begin{figure}
    \centering
\resizebox{\columnwidth}{!}{%
\begin{tikzpicture}[
level 1/.style={sibling distance=40mm},
edge from parent/.style={->,draw},
>=latex]

% root of the the initial tree, level 1
\node[draw=none]  {}
% The first level, as children of the initial tree
child {node[level 2] (c1) {Analyse} edge from parent[draw=none]}
child {node[level 2] (c2) {Konzeption} edge from parent[draw=none]}
child {node[level 2] (c3) {Umsetzung} edge from parent[draw=none]}
child {node[level 2] (c4) {Abschluss} edge from parent[draw=none]};

% The second level, relatively positioned nodes
\begin{scope}[every node/.style={level 3}]
\node [below of = c1, xshift=15pt] (c11) {Setting shape};
\node [below of = c11] (c12) {Choosing color};
\node [below of = c12] (c13) {Adding shading};

\node [below of = c2, xshift=15pt] (c21) {Using a Matrix};
\node [below of = c21] (c22) {Relatively};
\node [below of = c22] (c23) {Absolutely};
\node [below of = c23] (c24) {Using overlays};

\node [below of = c3, xshift=15pt] (c31) {Default arrows};
\node [below of = c31] (c32) {Arrow library};
\node [below of = c32] (c33) {Resizing tips};
\node [below of = c33] (c34) {Shortening};
\node [below of = c34] (c35) {Bending};

\node [below of = c4, xshift=15pt] (c41) {Default arrows};
\node [below of = c41] (c42) {Arrow library};
\node [below of = c42] (c43) {Resizing tips};
\node [below of = c43] (c44) {Shortening};
\node [below of = c44] (c45) {Bending};
\end{scope}

% lines from each level 1 node to every one of its "children"
\foreach \value in {1,2,3}
\draw[->] (c1.195) |- (c1\value.west);

%lines von Analyse zu Implementierung
\draw[->] (c1) |- (c2);
\draw[->] (c2) |- (c3);
\draw[->] (c3) |- (c4);

\foreach \value in {1,...,4}
\draw[->] (c2.195) |- (c2\value.west);

\foreach \value in {1,...,5}
\draw[->] (c3.195) |- (c3\value.west);

\foreach \value in {1,...,5}
\draw[->] (c4.195) |- (c4\value.west);
\end{tikzpicture}
}
    \label{fig:ustrategiepsp}
        \caption[Der Projektstrukturplan des Projektes]{Der Projektstrukturplan des Projekts}
\end{figure}

在此处输入图片描述

  1. 问题如您所见,最后一个矩形的箭头比其他矩形的箭头小一点。我该如何解决这个问题?
  2. 问题我想要编辑矩形以使其看起来像图片中所示:具有开始和结束日期以及连续的数字。在此处输入图片描述

感谢您的所有想法和帮助!

答案1

第一个问题或多或少比较简单。Abschluss节点没有像其他节点那样的 y、g、p,因此它不是那么高,.195锚点也与其他节点不同。我建议添加一个,\strut使它们的高度都相等。

\documentclass[border=1mm,tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,positioning,shadows,trees}
\tikzset{
    basic/.style  = {draw, text width=2cm, drop shadow, font=\sffamily, rectangle},
    root/.style   = {basic, rounded corners=2pt, thin, align=center,
        fill=gray!60},
    level 2/.style = {basic, rounded corners=6pt, thin,align=center, fill=gray!45,
        text width=8em},
    level 3/.style = {basic, thin, align=left, fill=gray!30, text width=6.5em}
}
\begin{document}

\begin{tikzpicture}[
level 1/.style={sibling distance=40mm},
edge from parent/.style={->,draw},
>=latex]

% root of the the initial tree, level 1
\node[draw=none]  {}
% The first level, as children of the initial tree
child {node[level 2] (c1) {Analyse\strut} edge from parent[draw=none]}
child {node[level 2] (c2) {Konzeption\strut} edge from parent[draw=none]}
child {node[level 2] (c3) {Umsetzung\strut} edge from parent[draw=none]}
child {node[level 2] (c4) {Abschluss\strut} edge from parent[draw=none]};

% The second level, relatively positioned nodes
\begin{scope}[every node/.style={level 3}]
\node [below of = c1, xshift=15pt] (c11) {Setting shape};
\node [below of = c11] (c12) {Choosing color};
\node [below of = c12] (c13) {Adding shading};

\node [below of = c2, xshift=15pt] (c21) {Using a Matrix};
\node [below of = c21] (c22) {Relatively};
\node [below of = c22] (c23) {Absolutely};
\node [below of = c23] (c24) {Using overlays};

\node [below of = c3, xshift=15pt] (c31) {Default arrows};
\node [below of = c31] (c32) {Arrow library};
\node [below of = c32] (c33) {Resizing tips};
\node [below of = c33] (c34) {Shortening};
\node [below of = c34] (c35) {Bending};

\node [below of = c4, xshift=15pt] (c41) {Default arrows};
\node [below of = c41] (c42) {Arrow library};
\node [below of = c42] (c43) {Resizing tips};
\node [below of = c43] (c44) {Shortening};
\node [below of = c44] (c45) {Bending};
\end{scope}

% lines from each level 1 node to every one of its "children"
\foreach \value in {1,2,3}
\draw[->] (c1.195) |- (c1\value.west);

%lines von Analyse zu Implementierung
\draw[->] (c1) |- (c2);
\draw[->] (c2) |- (c3);
\draw[->] (c3) |- (c4);

\foreach \value in {1,...,4}
\draw[->] (c2.195) |- (c2\value.west);

\foreach \value in {1,...,5}
\draw[->] (c3.195) |- (c3\value.west);

\foreach \value in {1,...,5}
\draw[->] (c4.195) |- (c4\value.west);
\end{tikzpicture}

\end{document}

在此处输入图片描述

第二个问题不太容易回答。我建议换一个新的。

但作为初步解决方案,如果您之前知道盒子主要部分的尺寸,则可以添加日期和数字labels

\begin{tikzpicture}[
    dates/.style={draw, minimum width=15mm, minimum height=6mm, inner sep=1pt, draw, font=\small},
    start/.style={dates, anchor=north west, yshift=\pgflinewidth},
    end/.style={dates, anchor=north east, yshift=\pgflinewidth},
    number/.style={draw,minimum width=26mm, minimum height=7mm, rotate=90, anchor=south east,yshift=-\pgflinewidth}]
    
\node[minimum height=2cm, minimum width=3cm, label={[start]south west:12/12/22},
label={[end]south east:20/12/22},label={[number]north west:1.1}, draw]{Something};
\end{tikzpicture}

在此处输入图片描述

相关内容