3

I am trying to construct this in TikZ but I am having a terrible time doing it. I was hoping someone can improve the code, I have below and make it look similar to the picture.

\begin{tikzpicture}
\draw  (-0.5,1.5) rectangle (2,0);
\draw  (-9.5,1.5) rectangle (-7,0);

\draw  (-4.5,5) rectangle (-2,3.5);
\draw  (-4.5,-2) rectangle (-2,-3.5);
\draw  (4,1.5) rectangle (6.5,0);
\draw [-latex](-4.5,4.5) -- (-8,1.5);
\draw [-latex] (-8,0) -- (-4.5,-3);
\draw  [-latex](-2,-3) -- (1,0);
\draw [-latex] (-2,4.5) -- (1,1.5);
\draw  [-latex](2,0.5) -- (4,0.5);
\end{tikzpicture}

I tried adding text inside the rectangles but I couldn't figure out how to. If someone has a solution other than TikZ then that also works.

percusse
  • 157,807
Jeel Shah
  • 3,794

3 Answers3

6
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\tikzset{
block/.style = {draw,rectangle,text width = 4em,align=left, rounded corners=0ex,     minimum height=2.0em}
}
\begin{document}
  \begin{tikzpicture}
\node[block] at (0,0) (a) {A. Some text};
\node[block,above right = .15cm and 1cm of a,] (b) {B. Some text};
\node[block, below right = .15cm and 1cm of a,] (c) {c. Some text};
\node[block, below right = .15cm and 1cm of b,]  (d) {D. Some text};
\node[block,  right = 1cm of d]  (e) {E. Some text};
%% lines
\draw[-latex] (a.10) -- (b.185);
\draw[-latex] (a.-10) -- (c.175);
\draw[-latex] (b.-10) -- (d.175);
\draw[-latex] (c.10) -- (d.185);
\draw[-latex] (d) -- (e);
\end{tikzpicture}
\end{document}

enter image description here

  • That works! I made a minor change however to your code. I changed 4em to 6em to change the text width but other then that it's great! – Jeel Shah Oct 30 '13 at 00:19
6

The new CVS graphdrawing library can do stuff like this quite easily, but must be compiiled with luatex:

\documentclass[border=0.125cm]{standalone}

\usepackage{tikz}
\usetikzlibrary{graphdrawing}
\usetikzlibrary{graphs}
\usegdlibrary{layered}

\begin{document}

\begin{tikzpicture}[every node/.style={draw, text width=4em}, >=stealth]

\graph [layered layout,grow=right, level distance=1in, sibling distance=0.5in, 
  tail anchor=east, head anchor=west]
    {
        "A. Some text" -> {" B. Some text", "C. Some text"} 
        -> "D. Some text" -> "E. Some text"
    };

\end{tikzpicture}

\end{document}

enter image description here

Mark Wibrow
  • 70,437
  • Wow this makes drawing flowcharts so much easier! Amazing. Thanks for pointing this out. – Ingo Jan 11 '14 at 12:07
4

With matrix node, one can achieve this. The blocks separation can be changed via column sep and row sep key. Colors selection are also possible for texts and block borderlines (it is black here)

enter image description here

Code:

\documentclass[]{article}
\usepackage[margin=1cm]{geometry}
\usepackage{tikz}
\usetikzlibrary{matrix,shapes,arrows,positioning}

\begin{document}
\begin{tikzpicture}[boxes/.style={draw, rectangle,%
                thick,minimum height=1cm, rounded corners,
                minimum width=1cm, black, text=black,
                text width=25mm, align=center},scale=2]
  \matrix (mat) [matrix of nodes, nodes=boxes, column sep=1cm, row sep=1cm] 
  {
              &   B. Some Text    &                &                  \\ 
 A. Some Text &                   &  D.Some Text   & E. Some Text     \\
              &   C. Some Text    &                &                  \\ 
  };  
\draw [very thick, black, ->] (mat-2-1.east)--(mat-1-2.west);  
\draw [very thick, black, ->] (mat-2-1.east)--(mat-3-2.west);
\draw [very thick, black, ->] (mat-3-2.east)--(mat-2-3.west);
\draw [very thick, black, ->] (mat-1-2.east)--(mat-2-3.west);
\draw [very thick, black, ->] (mat-2-3.east)--(mat-2-4.west);
\end{tikzpicture}
\end{document}
Jesse
  • 29,686