如何重现此图

如何重现此图

我正在尝试重现这个工作流程图在此处输入图片描述

我只是试图重现关系之前的块,但是当我编译这段代码时它冻结了,我被迫杀死pdflatex,有人能帮我吗,我对tikz完全是菜鸟,提前谢谢你

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[francais]{babel}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,positioning,shadows,trees}
\usepackage{capt-of}

\title{a graph}
\author{Author}
\date{Janvier 2018}

\begin{document}

\begin{center}
\tikzset{
basic/.style  = {draw, text width=2cm, drop shadow, font=\sffamily, rectangle},
root/.style   = {basic, thin, align=center,
           fill=gray!45},
level 2/.style = {basic, thin,align=center, fill=gray!30,
           text width=8em},
level 3/.style = {basic, thin, align=left, fill=gray!20, text width=6.5em}
}
\begin{tikzpicture}[
level 1/.style={sibling distance=40mm},
edge from parent/.style={<->,draw},>=
\node[block](1) {"blessed repository"}
\node [block, right=5cm of 1] (2) {public developer}
\node [block, right =5cm of 2] (3) {public developer}
\node [block, below=4cm of 1] (4) {integration manager}
\node [block, below=2cm of 2] (5) {private developer}
\node [block, below =2cm of 3] (6) {private developer}
\end{tikzpicture}
\end{center}

\end{document}

答案1

正如 Phelype 所提到的,有三件事会导致错误:

  1. 您忘记了]选项的结束符,也就是说tikzpicture,您有\begin{tikzpicture}[...\begin{tikzpicture}[...]

  2. 您忘记了每个语句末尾必须有分号\node

  3. 您使用了一种block针对所有节点调用的样式,但实际上并未定义该样式。

这里的方法与 Phelype 的方法略有不同,使用一种样式,该样式接受一个参数来设置节点的填充颜色,并使用一个循环来绘制箭头。我删除了所有树的内容(例如level 1/.style),因为您没有绘制树,以及节点的自定义距离。默认距离(我认为是 1 厘米)在这里似乎没问题。

代码输出

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[francais]{babel}
\usepackage{tikz}
\usetikzlibrary{
  arrows.meta, % supersedes arrows
  positioning,
  shadows,
  babel % fixes some problems that sometimes occur when babel is used
}

\begin{document}
\begin{center}
\begin{tikzpicture}[
  block/.style = {
    draw,
    text width=2cm,
    align=center,
    drop shadow,
    font=\sffamily,
    rectangle,
    fill=#1 % fill color is argument to style
  },
 % set default value for fill
 block/.default={black!20},
]
\node [block=orange!80] (1) {``blessed repository''};
\node [block=blue!80!red!50!white, right=of 1] (2) {public developer};
\node [block=blue!80!red!50!white, right=of 2] (3) {public developer};
\node [block=red!80, below=of 1] (4) {integration manager};
\node [block, below=of 2] (5) {private developer};
\node [block, below=of 3] (6) {private developer};

\foreach \x/\y in {1/5,1/6,2/4,3/4,4/1,5/2,6/3}
  \draw [thick,black!50,-Latex] (\x) -- (\y);

\end{tikzpicture}
\end{center}
\end{document}

答案2

您的代码有几个问题。有一个不匹配的括号 ( ),并且节点后面[没有分号 ( ),这就是它无法编译的原因。;

编辑:

根据@TeXnician 的建议略有改进。

在此处输入图片描述

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[francais]{babel}
\usepackage{tikz}
\usetikzlibrary{%
arrows,
shapes,
positioning,
shadows,
trees,
arrows.meta,
decorations,
decorations.markings,
decorations.text}
\usepackage{capt-of}

\title{a graph}
\author{Author}
\date{Janvier 2018}

\begin{document}

\begin{center}
\tikzset{
myblock/.style = {text width=2cm, text=white, font=\sffamily, rectangle,align=center},
byellow/.style = {myblock, fill=yellow!80!black},
bblue/.style =   {myblock, fill=green!50!blue},
bred/.style =    {myblock, fill=red!90!yellow},
bgray/.style =   {myblock, fill=black!10, text=black},
arrow/.style={>={Stealth},thick,black!50}
}

\begin{tikzpicture}%[level 1/.style={sibling distance=40mm},edge from parent/.style={<->,draw},>=]
\node [byellow, xshift=0cm, yshift=0cm] (1) {``blessed repository''};
\node [bblue  , xshift=3cm, yshift=0cm] (2) {public developer};
\node [bblue  , xshift=6cm, yshift=0cm] (3) {public developer};
\node [bred   , xshift=0cm, yshift=-2cm] (4) {integration manager};
\node [bgray  , xshift=3cm, yshift=-2cm] (5) {private developer};
\node [bgray  , xshift=6cm, yshift=-2cm] (6) {private developer};
\draw [->,arrow] (4.north) -- (1.south);
\draw [->,arrow] (1.south) -- (5.north);
\draw [->,arrow] (1.south) -- (6.north);
\draw [->,arrow] (5.north) -- (2.south);
\draw [->,arrow] (2.south) -- (4.north);
\draw [->,arrow] (3.south) -- (4.north);
\draw [->,arrow] (6.north) -- (3.south);
\end{tikzpicture}
\end{center}

\end{document}

相关内容