how to reproduce this diagram
There are three things that create errors, as mentioned by Phelype as well:
You've forgotten the closing
]
for the options to thetikzpicture
, i.e. you have\begin{tikzpicture}[...
instead of\begin{tikzpicture}[...]
You've forgotten the mandatory semicolon at the end of each
\node
statement.You've used a style called
block
for all the nodes, but you haven't actually defined that style.
Here is a slightly different approach to Phelype's, using a style that takes an argument to set the fill colour of the node, and a loop to draw the arrows. I removed all the tree stuff (e.g. level 1/.style
) as you're not drawing a tree, and the custom distances for the nodes. The default distance (1cm, I think) seems OK here.
\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}
Your code had a few problems. There was an unmatched bracket ([
) and there was no semicolon (;
) after the nodes, that's why it didn't compile.
Edit:
Improved a little with @TeXnician's suggestion.
\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}