2

Please can anyone help, I have a problem to correctly connecting block9 to block 10 Also, block 19 to block 6.

\documentclass[border=3mm]{standalone}
% Required package
\usepackage{tikz}
\usetikzlibrary{shapes,positioning}
\usetikzlibrary{shapes,arrows}

\begin{document}
\begin{tikzpicture}[node distance = 0.3cm,auto][t]

\node[draw,
    rounded rectangle,
    minimum width=2.5cm,
    minimum height=1cm] (block1) {START};


\node[draw,
    below=of block1,
    minimum width=3.5cm,
    minimum height=0.75cm
] (block2) {block1};
        

\node[draw,
    below=of block2,
    minimum width=1.0cm,
    minimum height=1cm
] (block3) {block2};
       

\node[draw,
    diamond,
    below=of block3,
    minimum width=2.5cm,
    inner sep=0] (block4) {block3};
 
\node[draw,
    draw,
    left=of block4,
    minimum width=3.5cm,
    minimum height=0.75cm
] (block5) {block4};
 
\node[draw,
    draw,
    below=of block4,
    minimum width=3.5cm,
    minimum height=0.75cm
] (block6) {block5};

\node[draw,
    draw,
    below=of block6,
    minimum width=3.5cm,
    minimum height=0.75cm
] (block7) {block6};
    
  \node[draw,
    diamond,
    below=of block7,
    minimum width=2.5cm,
    inner sep=0] (block8) {block7};
 
\node[draw,
    draw,
    left=of block8,
    minimum width=3.5cm,
    minimum height=0.75cm
] (block9) {block8};

\node[draw,
    draw,
    below=of block8,
    minimum width=3.5cm,
    minimum height=0.75cm
] (block10) {block9};      

\node[draw,
    draw,
    right=of block2,
    minimum width=3.5cm,
    minimum height=0.75cm
] (block11) {block10};      

\node[draw,
    draw,
    below=of block11,
    minimum width=3.5cm,
    minimum height=0.75cm
] (block12) {block11}; 

\node[draw,
    draw,
    below=of block12,
    minimum width=3.5cm,
    minimum height=0.75cm
] (block13) {block12}; 

\node[draw,
    draw,
    below=of block13,
    minimum width=3.5cm,
    minimum height=0.75cm
] (block14) {block13}; 

\node[draw,
    draw,
    below=of block14,
    minimum width=3.5cm,
    minimum height=0.75cm
] (block15) {block14}; 

\node[draw,
    draw,
    below=of block15,
    minimum width=3.5cm,
    minimum height=0.75cm
] (block16) {block15}; 

\node[draw,
    draw,
    below=of block16,
    minimum width=3.5cm,
    minimum height=0.75cm
] (block17) {block16}; 

\node[draw,
    draw,
    below=of block17,
    minimum width=3.5cm,
    minimum height=0.75cm
] (block18) {block17}; 

\node[draw,
    diamond,
    below=of block18,
    minimum width=2.5cm,
    inner sep=0] (block19) {block18};
    
 \node[draw,
    draw,
    left=of block19,
    minimum width=3.5cm,
    minimum height=0.75cm
] (block20) {block19};
 
\node[draw,
    draw,
    below=of block19,
    minimum width=3.5cm,
    minimum height=0.75cm
] (block21) {END};   
    
% Arrows
\draw[-latex] (block1) edge (block2);
\draw[-latex] (block2) edge (block3);
\draw[-latex] (block3) edge (block4);
\draw[-latex] (block4) edge node[pos=0.3,inner sep=0pt]{Yes}(block6)
     (block4) edge node[pos=0.15,inner sep=0pt]{No}(block5);
 \draw[-latex] (block6) edge (block7);  
  \draw[-latex] (block7) edge (block8);        
\draw[-latex] (block8) edge node[pos=0.3,inner sep=0pt]{Yes}(block9)
     (block8) edge node[pos=0.25,inner sep=0pt]{No}(block10);
 \draw[->] (block10) -| (block11);  
  \draw[-latex] (block11) edge (block12);  
  \draw[->] (block12) edge (block13);
  \draw[->] (block13) edge (block14);
  \draw[->] (block14) edge (block15);
  \draw[->] (block15) edge (block16);
  \draw[->] (block16) edge (block17);
  \draw[->] (block17) edge (block18);
  \draw[->] (block18) edge (block19);
  \draw[-latex] (block19) edge node[pos=0.3,inner sep=0pt]{Yes}(block20)
     (block19) edge node[pos=0.25,inner sep=0pt]{No}(block21);
     \draw[->] (block20) |- (block7);
\end{tikzpicture}
    \end{document}
3
  • Welcome. // Please enter a screenshot from your codes result.
    – MS-SPO
    Jun 23 at 15:53
  • 1
    Your code is not complete and has mismatch on nodes name. Please correct this errors.
    – Zarko
    Jun 23 at 16:34
  • Hi I have inserted \draw [->] (block10) edge (block11); \draw [->] (block20) edge (block7); into line 163 and line 164. not sure if this helps as you seem to have all the other code the same, its just the numbering of the blocks that is puzzling me.
    – Paul A
    Jun 23 at 16:37

3 Answers 3

2

Here's a way to do it:

  • introduced styles fmt and fmtw for simplification
  • deleted duplicate draw, removed min width and min height
  • cleaned up code a little
  • shifted some blocks a bit to the left
  • introduced Tom's proposal for the connectors

xxx

\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes,positioning}
\usetikzlibrary{shapes,arrows}

\begin{document}
\begin{tikzpicture}[node distance = 0.3cm,auto, 
fmt/.style={draw, minimum width=2.5cm},
fmtw/.style={draw, minimum width=3.5cm, minimum height=0.75cm}][t]% introducing fmt for simplification

% deleted duplicate draw options
% cleaning up the code a little bit

\node[fmt,
    rounded rectangle,
    minimum height=1cm]         (block1) {START};

\node[fmtw,
    below=of block1,
    minimum height=0.75cm]      (block2) {block1};
        
\node[fmt,
    below=of block2,
    minimum width=1.0cm,
    minimum height=1cm]         (block3) {block2};     

\node[fmt,
    diamond,
    below=of block3,
    inner sep=0]                (block4) {block3};
 
\node[fmtw, left=of block4, 
        xshift=-5mm]            (block5) {block4};% shift to left
 
\node[fmtw,  below=of block4]   (block6) {block5};

\node[fmtw, below=of block6]    (block7) {block6};
    
\node[fmt, diamond, 
  below=of block7, inner sep=0] (block8) {block7};
 
\node[fmtw, left=of block8, 
            xshift=-5mm]        (block9) {block8};% shift to left

\node[fmtw, below=of block8]    (block10) {block9};      

\node[fmtw, right=of block2]    (block11) {block10};      

\node[fmtw, below=of block11]   (block12) {block11}; 

\node[fmtw, below=of block12]   (block13) {block12}; 

\node[fmtw, below=of block13]   (block14) {block13}; 

\node[fmtw, below=of block14]   (block15) {block14}; 

\node[fmtw, below=of block15]   (block16) {block15}; 

\node[fmtw, below=of block16]   (block17) {block16}; 

\node[fmtw, below=of block17]   (block18) {block17}; 

\node[fmt, diamond,
    below=of block18, 
    inner sep=0]                (block19) {block18};
    
\node[fmtw, left=of block19, 
        xshift=-5mm]            (block20) {block19};% moving a little to left

 
\node[fmtw, below=of block19]   (block21) {END};   
    
% Arrows
  \draw[-latex] (block1) edge (block2);
  \draw[-latex] (block2) edge (block3);
  \draw[-latex] (block3) edge (block4);
  \draw[-latex] (block4) edge node[pos=0.3,inner sep=0pt]{Yes}(block6)
     (block4) edge node[pos=0.15,inner sep=0pt]{No}(block5);
  \draw[-latex] (block6) edge (block7);  
  \draw[-latex] (block7) edge (block8);        
  \draw[-latex] (block8) edge node[pos=0.3,inner sep=0pt]{Yes}(block9)
     (block8) edge node[pos=0.25,inner sep=0pt]{No}(block10);
% \draw[->] (block10) -| (block11);  
  \draw[-latex] (block11) edge (block12);  
  \draw[->] (block12) edge (block13);
  \draw[->] (block13) edge (block14);
  \draw[->] (block14) edge (block15);
  \draw[->] (block15) edge (block16);
  \draw[->] (block16) edge (block17);
  \draw[->] (block17) edge (block18);
  \draw[->] (block18) edge (block19);
  \draw[-latex] (block19) edge node[pos=0.3,inner sep=0pt]{Yes}(block20)
     (block19) edge node[pos=0.25,inner sep=0pt]{No}(block21);
%     \draw[->] (block20) |- (block7);
     
  % Tom's comment
  \draw[->] (block10.east) --++(0.15cm,0cm) |- (block11.west); 
  \draw[->] (block20.west) --++(-4cm,0cm) |- (block7.west);
 \end{tikzpicture}
\end{document}

Result:

enter image description here

1
  • 1
    Thanks you so much. it works Jun 23 at 17:59
3

With use of the chain library and in picture picture preamble defined styles for nodes, arrows and labels:

Edit. Now I observe that I lost node block2 in the main branch and that first block in branch "B" should start at level of node A-2. Now I correct this.

\documentclass[margin=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows, arrows.meta,
                chains,
                positioning,
                quotes,
                shapes}

\begin{document}
    \begin{tikzpicture}[
    node distance = 3mm and 5mm,
      start chain = A going below,
      start chain = B going below,
       arr/.style = {draw, -Straight Barb},
       box/.style = {draw, minimum width=21mm, minimum height=7mm},
  decision/.style = {diamond, draw, minimum width=24mm, inner sep=0},
every edge/.style = {arr},
every edge quotes/.style={auto=right, font=\footnotesize},
                        ]
    \begin{scope}[nodes={on chain=A, join=by arr}]
\node[box, rounded rectangle]   {START};    % A-1
\node[box]      {block1};
\node[box]      {block2};
\node[decision] {block3};                   % A-4
\node[box]      {block5};
\node[box]      {block6};
\node[decision] {block7};                   % A-7
\node[box]      {block9};
    \end{scope}
\node (C-1)     [box, left=of A-4]  {block4};
\node (C-2)     [box, left=of A-7]  {block8};
    \draw   (A-4) edge ["Yes"] (C-1)
            (A-7) edge ["Yes"] (C-2);
    \begin{scope}[nodes={on chain=B, join= by arr}]
\node[box,
      right=of A-2] {block10};  % B-1
\node[box]      {blocj11)};
\node[box]      {block12};
\node[box]      {block13};
\node[box]      {block14};
\node[box]      {block15};
\node[box]      {block16};
\node[box]      {block17};
\node[decision] {block18};                  % B-9
\node[box]      {END};
    \end{scope}
\node (B-11)    [box, left=of B-9] {block19};
% Arrows
\coordinate[left=of C-2] (aux);
\draw[arr]  (A-8.east) -- ++ (0.2,0) |- (B-1);
\draw[arr]  (B-9)  edge ["Yes"] (B-11);
\draw[arr]  (B-11) -| (aux) |- (A-5);
    \end{tikzpicture}
\end{document}

enter image description here

1
2

Try use this two path instead:

\draw[->] (block10.east) --++(0.15cm,0cm) |- (block11.west); 
\draw[->] (block20.west) --++(-4cm,0cm) |- (block7.west);

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.