0

enter image description here

I just want to know how should i draw this graph? should i use forest package? the respective codes would be much of a help if available, thanks in advance.

4
  • 5
    Welcome to TeX.SX. Questions about how to draw specific graphics that just post an image of the desired result are really not reasonable questions to ask on the site. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document. May 19, 2016 at 22:19
  • You could use Forest, but it is not especially well suited. Forest is designed to draw trees and this isn't a tree.
    – cfr
    May 19, 2016 at 22:54
  • @MartinSchröder I think, this question is legit, since it has a title which can be found by google by people with similar problems. So it leads others to a solution or nearer to it. May 19, 2016 at 23:11
  • 1
    @MaestroGlanz the question itself can be legit, in another context eg: google, but still not be quite right in this context.
    – A Feldman
    May 19, 2016 at 23:21

3 Answers 3

5

As starting point can serve the following pure TikZ code with libraries arrows.meta, chains and positioning:

\documentclass[border=3mm,
               multi,
               tikz]{standalone}
\usetikzlibrary{arrows.meta, chains, positioning}

    \begin{document}
\begin{tikzpicture}[
    node distance = 12mm and 2mm,
      start chain = going right,
every node/.style = {draw, inner sep=2mm, align=center,
                     text width=32mm, minimum height=12mm,
                     on chain},
Arr/.style = {-{Straight Barb[length=5pt,width=5pt]},thick}
                    ]
\node (n1) {Data gathering through interviews};
\node (n2) [below=3mm of n1]    {B};
%
\node (n31)[below left=12mm and 2mm of n2]
                                {C1};
\node (n32)                     {C2};
\node (n33)                     {C3};
%
\node (n41)[below left=18mm and 2mm of n31]
                                {D1};
\node (n42)                     {D2};
\node (n43)                     {D3};
\node (n44)                     {D4};
\node (n45)                     {D5};
%
\node (n5) [below=of n43]       {E1};
% arrows
\draw[Arr] (n1) -- (n2);
\foreach \i in {1, 2, 3}    \draw[Arr] (n2.south) -- (n3\i.north);
\foreach \i in {1, 2, 3}
{   \foreach \j in {1,...,5}
    \draw[Arr] (n3\i.south) -- (n4\j.north);
}
\foreach \i in {1,...,5}    \draw[Arr] (n4\i.south) -- (n5.north);
\end{tikzpicture}
    \end{document}

Fill free to edit above example and add right text in nodes. Code gives similar result as you shown in your question:

enter image description here

2
  • This doesn't really seem to make full use of chains, does it?
    – cfr
    May 19, 2016 at 23:21
  • No, it is used only partially (for grow from left to right). Also Is not used chains node naming for more simple (in sense of comprehensives) construction lines between them.
    – Zarko
    May 19, 2016 at 23:55
2

chains, loops and scopes can help:

\documentclass[tikz,border=10pt,multi]{standalone}
\usetikzlibrary{chains,scopes}
\begin{document}
\begin{tikzpicture}
  [
  start chain=main going below, every on chain/.append style={text width=15mm, text centered, minimum height=7.5mm, draw}, every join/.append style={->}
  ]
  \node [on chain, join] {A};
  \node [on chain, join] {B};
  \node [on chain, join] {C};
  {[start branch=this going right]
    \node [on chain] {F};
    \node [on chain=going below, join] {G};
    \node [on chain=going right] {H};
  }
  {[start branch=that going left]
    \node [on chain] {I};
    \node [on chain=going below, join] {J};
    \node [on chain=going left] {K};
  }
  \node [on chain, join] {D};
  \node [on chain, join] {E};
  \foreach \i in {this,that} \draw [->] (main-2) -- (main/\i-2);
  \foreach \i in {{main/this-4},{main/this-3},main-4,{main/that-3},{main/that-4}}
  {
    \foreach \j in {main-3,{main/this-2},{main/that-2}} \draw [->] (\j.south) -- (\i.north);
    \draw [->] (\i.south) -- (main-5.north);
  }
\end{tikzpicture}
\end{document}

chains, scopes and loops

4
  • (+1), for full exploitation of chains and loop. Latter I need to test, from reading of code I cant figured out, how they works.
    – Zarko
    May 20, 2016 at 0:01
  • You are right in the sense of yours being more comprehensible to somebody unfamiliar with chains, though, because everything is explicitly named. I just eschew typing!
    – cfr
    May 20, 2016 at 0:16
  • Beware(!): If there is an error in the \loop, it always says, the error is in the \repeat line, though it might be anywhere within the loop. So finding errors in loop can be a bit complicated. There is \foreach used here, but I assume, that it behaves similar. May 20, 2016 at 6:36
  • @MaestroGlanz This is a common issue in TeX. Not specific to loops.
    – cfr
    May 20, 2016 at 12:15
1

My answer isn't TeX-style, but how I prefer to do it: Use inkscape (external, but free software) and \includegraphics the exported pdf.

The main advantage of this method is, that it is very simple and easy to use. If you dont want to use Tex by any means for Tex's sake, I would recommend this to a beginner.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .