5

I just started using LaTex and this is my first try on drawing a graph. I've encountered some problems and these are my questions:

  1. May I know how can I position M,Q and E on the arrows "above" and "below" the arrow so that they are visible? (probably shorten the arrows ?)
  2. How can I position the arrow in such a way that the M,Qarrows are going into the left portion of the node(box), and the Earrows are going out from the right portion of the node(box). enter image description here
  3. How can I make a branch after Operation so that I can link it back to Material production.
  4. How to position the Recycling node below and at the center of the two nodes Operation and Treatment Disposal?

MWE:

\documentclass[10pt,twoside,a4paper,fleqn]{report}

\usepackage{tikz}
\usepackage[utf8]{inputenc}
\usetikzlibrary{shapes.geometric,arrows}
\usepackage{varwidth}

\begin{document}
    \tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!20]

    \tikzstyle{arrow} = =[thick,->,>=stealth]

    \begin{tikzpicture}[node distance=2.5cm]
    \node (RMA) [startstop,minimum size=2cm] {\begin{varwidth}{2cm}Raw\\ Material\\ Acquisition\end{varwidth}};
    \node [above of = RMA, node distance = 2cm] (MQ1) {};
    \node [below of = RMA, node distance = 2cm] (E1) {};

    \node (MP) [startstop,minimum size=2cm, right of=RMA] {\begin{varwidth}{2.5cm}Material \\Production\end{varwidth}};
    \node [above of = MP, node distance = 2cm] (MQ2) {};
    \node [below of = MP, node distance = 2cm] (E2) {};


    \node (FD) [startstop,minimum size=2cm, right of=MP] {\begin{varwidth}{2.5cm}Film \\Deposition\end{varwidth}};
    \node [above of = FD, node distance = 2cm] (MQ3) {};
    \node [below of = FD, node distance = 2cm] (E3) {};

    \node (MP1) [startstop,minimum size=2cm, right of=FD] {\begin{varwidth}{2.5cm}Module \\Production\end{varwidth}};
    \node [above of = MP1, node distance = 2cm] (MQ4) {};
    \node [below of = MP1, node distance = 2cm] (E4) {};

    \node (O) [startstop,minimum size=2cm, right of=MP1] {\begin{varwidth}{2.5cm}Operation\end{varwidth}};
    \node [above of = O, node distance = 2cm] (MQ5) {};
    \node [below of = O, node distance = 2cm] (E5) {};

    \node (TD) [startstop,minimum size=2cm, right of=O] {\begin{varwidth}{2.5cm}Treatment\\Disposal\end{varwidth}};
    \node [above of = TD, node distance = 2cm] (MQ6) {};
    \node [below of = TD, node distance = 2cm] (E6) {};

    \node (R) [startstop,minimum size=2cm, below of=TD] {\begin{varwidth}{2.5cm}Recycling\end{varwidth}};



    \draw [arrow] (RMA) -- (MP);
    \draw[arrow, thick, dashed] (MQ1) to node[above] {\small$M,Q$} (RMA);
    \draw[arrow, thick, dashed] (RMA) to node[below] {$E$} (E1);

    \draw [arrow] (MP) -- (FD); 
    \draw[arrow, thick, dashed] (MQ2) to node[above] {\small$M,Q$} (MP);
    \draw[arrow, thick, dashed] (MP) to node[below] {$E$} (E2);

    \draw [arrow] (FD) -- (MP1);
    \draw[arrow, thick, dashed] (MQ3) to node[above] {\small$M,Q$} (FD);
    \draw[arrow, thick, dashed] (FD) to node[below] {$E$} (E3);

    \draw [arrow] (MP1) -- (O);
    \draw[arrow, thick, dashed] (MQ4) to node[above] {\small$M,Q$} (MP1);
    \draw[arrow, thick, dashed] (MP1) to node[below] {$E$} (E4);

    \draw [arrow] (O) -- (TD);
    \draw[arrow, thick, dashed] (MQ5) to node[above] {\small$M,Q$} (O);
    \draw[arrow, thick, dashed] (O) to node[below] {$E$} (E5);

    \draw[arrow, thick, dashed] (MQ6) to node[above] {\small$M,Q$} (TD);
    \draw[arrow, thick, dashed] (TD) to node[below] {$E$} (E6);

    \end{tikzpicture}

\end{document}
  • Welcome to TeX.SX! Please don't post code fragments. Instead, put your fragments into a complete compilable document that shows the problem. – Thruston Jul 24 '18 at 8:42
  • completing your MWE might also attract answers ;) – thymaro Jul 24 '18 at 8:48
  • Just did, didnt know how it works. Sorry! – thesilencer Jul 24 '18 at 8:52
5

like this?

enter image description here

i combine your code and looks of provided image. of course, you can easily change node style (to rounded corners or to white fill):

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta, calc, chains, positioning, shadows}
\makeatletter
\tikzset{suppress join/.code={\def\tikz@lib@on@chain{}}}
\makeatother

\begin{document}
    \begin{tikzpicture}[
node distance=14mm and 6mm,
start chain = going right,
          > = Stealth,
 arr/.style = {thick, - >},
 lbl/.style = {font=\footnotesize, inner sep=1pt, xshift=-0.5pt},
 box/.style = {rectangle, draw, fill=blue!20,
               minimum width=22mm, minimum height=12mm, align=center,
               drop shadow ={shadow xshift=-1ex, shadow yshift=-1ex},
               on chain, join=by arr,
   append after command={\pgfextra{\let\LN\tikzlastnode
        \draw[densely dashed,->] ([xshift= 7mm] \LN.south) -- + (0,-5mm) node[lbl,below] {E};
        \draw[densely dashed,<-] ([xshift=-7mm] \LN.north) -- + (0, 5mm) node[lbl] {M\,Q};
                    }}},
                        ]
\node (RMA) [box]   {Raw Material\\ Acquisition};
\node (MQ1) [box]   {Material \\Production};
\node (FD)  [box]   {Film \\Deposition};
\node (MP1) [box]   {Module \\Production};
\node (O)   [box]   {Operation};
\node (TD)  [box]   {Treatment\\Disposal};
\node (R)   [suppress join,box,
             below=of $(MQ1.south)!0.5!(TD.south)$] {Recycling};
%
\draw[arr]  ($(O.east)!0.5!(TD.west)$) |- (R);
\draw[arr]  (R) -| (MQ1);
\end{tikzpicture}
\end{document}
  • for nodes positioning is used tikz library chains,
  • connection between nodes are done by use of macro join=by ...
  • suppress of the macro join for fit-back node is in preamble defined style suppress join
  • parameters inputs and outputs are drawn as part of box node with

       append after command={\pgfextra{\let\LN\tikzlastnode
            \draw[densely dashed,->] ([xshift= 7mm] \LN.south) -- + (0,-5mm) node[lbl,below] {E};
            \draw[densely dashed,<-] ([xshift=-7mm] \LN.north) -- + (0, 5mm) node[lbl] {M\,Q};
    
  • with all this changes the mwe (minimal working example) with your flowchart become quite shorter
  • Thank you so much! Exactly what i wanted. Can you please let me know how can I change : - the arrow of MQ to going into the node - the arrow of MQ and E to be dashed – thesilencer Jul 24 '18 at 9:25
  • @thesilencer, i edit my answer. added are desired changes. – Zarko Jul 24 '18 at 9:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.