0

I have been trying to draw a big flowchart inside my article. I have managed to draw most of it but got stuck in some places. First, I can't draw the arrow marked in red in the image. I tried to use anchor east, west, but failed. Second, in a previous question similar to this, I was advised that the code I used here is for TikZ 2.0 and the new TikZ 3.0 has syntax = of. When I used this syntax the whole flow chart grew large in size and went out of page. What am I doing wrong? In general, how can I adjust the size of a big flowchart inside my article? (I was trying \linewidth, but it didn't work.) Lastly, I have a doubt: The arrow marked 1 in the pic, how to make it perpendicular? The arrow marked 2 looks tilted, how to make it straight?

The code I used:

\documentclass{article}
\usepackage{tikz}
\usepackage{listings}
\usetikzlibrary{shapes.geometric, arrows}
\usetikzlibrary{positioning}

\tikzstyle{io} = [trapezium, trapezium left angle=80, trapezium right angle=100, minimum width=2.5cm, minimum height=1.5cm, text centered, draw=black, fill=blue!30]
\tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1.5cm, text centered, draw=black, fill=orange!50]
\tikzstyle{arrow} = [thick,->,>=stealth]

\begin{document}

\begin{figure*}[h!] %{\linewidth}
    %\centering
    \begin{tikzpicture}
        \node (A)[io,align=center]{A};
        \node (B)[process, right of = A,xshift=3cm, align=center]{B};
        \node (C)[io,right of = B,xshift=3cm, align=center]{C \\Ready};
        \node (D)[process,right of = C,xshift=3cm, align=center]{Do Calculations};
        
        \node (E)[process,below of = A,yshift=-1.5cm, align=center]{E};
        \node (F)[io,below of = E,xshift=-1cm,yshift=-1.5cm, align=center]{F};
        \node (G)[io,right of = F,xshift=2cm]{G};
        \node(Addition)[process, below of = F,yshift=-1.5cm, align=center]{$F + \sum_{i=1}^{5} G $};
        \node (OP)[io,below of = Addition, yshift = -1.5cm, align=center]{OP};
        
        \node (H)[io,below of = D,yshift=-1.5cm, align=center]{H};
        \node(I)[process, below  of = H,yshift=-1.5cm, align=center]{Calculate $I$};
        \node(J)[process, below of = I,yshift=-1.5cm, align=center]{Jjjj};
        \node(K)[process, below of = J,yshift=-1.5cm, align=center]{Final calc};
        
        \node(L)[process,right of = G,xshift=3.5cm, align=center]{Apply K function\\to get G};
        \node(New G)[io,below of = L,yshift=-1.7cm, xshift=-1cm, align=center]{New G};

        \draw [arrow] (A) -- (B);
        \draw [arrow] (B) -- (C);
        \draw [arrow] (C) -- (D);
        \draw [arrow] (D) -- (H);
        \draw [arrow] (H) -- (I);
        \draw [arrow] (I) -- (J);
        \draw [arrow] (J) -- (K);
        %\draw [arrow] (K)node[anchor=west] -|- node[anchor=east](L);
        \draw [arrow] (G) -- (L);
        \draw [arrow] (L) -- (New G);
        \draw [arrow] (New G) -- (Addition);
        \draw [arrow] (Addition) -- (OP);
        \draw [arrow] (F) -- (Addition);
        \draw [arrow] (E) -- (F);
        \draw [arrow] (E) -- (G);
        \draw [arrow] (A) -- (E);
    \end{tikzpicture}
\end{figure*}
\end{document}

Output of the code I used Output with = of syntax

2
  • 1
    If you use the positioning syntax, which you really should, you can pick a smaller node distance, e.g. node distance=2em and 1.5em. And remove all the manual shifts.
    – user232027
    Commented Jan 3, 2021 at 13:55
  • 1
    @Wave_Rider03 please have a look at the answer below if it suits the requirement
    – js bibra
    Commented Jan 3, 2021 at 14:34

2 Answers 2

3

You should really use the positioning syntax and avoid all these manual extra shifts, you can say something like below right=2em and 1em of .... There are other things like quotes that could be used but it is not really worthwhile in this case.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{positioning}

\tikzset{io/.style={trapezium, trapezium left angle=80, trapezium right angle=100,
minimum width=6em, minimum height=3em, text centered, draw=black, fill=blue!30},
process/.style={rectangle, minimum width=6em, minimum height=4.25em, 
text centered, draw=black, fill=orange!50,inner xsep=1ex},
arrow/.style={thick,->,>=stealth}}

\begin{document}

\begin{figure*}[h!] %{\linewidth}
    %\centering
    \begin{tikzpicture}[node distance=2em and 2em,
        nodes={align=center,font=\sffamily}]
        \node (A)[io]{A};
        \node (B)[process, right =of A]{B};
        \node (C)[io,right =of B]{C \\Ready};
        \node (D)[process,right =of C]{Do Calculations};
        
        \node (E)[process,below = of A]{E};
        \node (F)[io,below left=2em and 1em of E.south]{F};
        \node (G)[io,below right=2em and 1em of E.south]{G};
        \node(Addition)[process, below = of F]{$F + \sum_{i=1}^{5} G $};
        \node (OP)[io,below = of Addition]{OP};
        
        \node (H)[io,below = of D]{H};
        \node(I)[process, below  = of H]{Calculate $I$};
        \node(J)[process, below = of I]{Jjjj};
        \node(K)[process, below = of J]{Final calc};
        
        \node(L)[process,right = of G]{Apply $K$ function\\to get $G$};
        \path (L|-Addition) node(New G)[io]{New $G$};
        
        \draw[arrow]
        (A) edge (B)
        (B) edge (C)
        (C) edge (D)
        (D) edge (H)
        (H) edge (I)
        (I) edge (J)
        (J) edge (K)
        (G) edge (L)
        (L) edge[edge label={$2$}] (New G)
        (New G) edge[edge label={$2$}] (Addition)
        (Addition) edge (OP)
        (F) edge (Addition)
        (E) edge (F)
        (E) edge (G)
        (A) edge (E)
        (K.west) -- ++ (-1.5em,0) |- (L);
    \end{tikzpicture}
\end{figure*}
\end{document}

enter image description here

1

enter image description here

\documentclass{article}
\usepackage{tikz}
\usepackage{listings}
\usetikzlibrary{shapes.geometric, arrows}
\usetikzlibrary{positioning}

\tikzstyle{io} = [trapezium, trapezium left angle=80, trapezium right angle=100, minimum width=1.5cm, minimum height=2cm, text centered, draw=black, fill=blue!30, inner sep=20pt]
\tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=2cm, text centered, draw=black, fill=orange!50, inner sep=0pt]
\tikzstyle{arrow} = [thick,->,>=stealth]

\begin{document}
\noindent\hspace{-0.1\columnwidth}
%\begin{figure*}[h!] %{\linewidth}
    %\centering
    \begin{tikzpicture}
        \node (A)[io,align=center]{A};
        \node (B)[process, right= of A,align=center]{B};
        \node (C)[io,right= of B, align=center]{C \\Ready};
        \node (D)[process,right=of C, align=center]{Do Calculations};
        
        \node (E)[process,below= of A, align=center]{E};
        \node (F)[io,below=of  E, align=center]{F};
        \node (G)[io,right=of F,]{G};
        \node(Addition)[process, below= of F, align=center]{$F + \sum_{i=1}^{5} G $};
        \node (OP)[io,below=of Addition, align=center]{OP};
        
        \node (H)[io,below=of D, align=center]{H};
        \node(I)[process, below=of H,align=center]{Calculate $I$};
        \node(J)[process, below=of I,align=center]{Jjjj};
        \node(K)[process, below=of J,align=center]{Final calc};
        
        \node(L)[process,right= of G, align=center]{Apply K function\\to get G};
        \node(New G)[io,below= of L, align=center]{New G};

        \draw [arrow] (A) -- (B);
        \draw [arrow] (B) -- (C);
        \draw [arrow] (C) -- (D);
        \draw [arrow] (D) -- (H);
        \draw [arrow] (H) -- (I);
        \draw [arrow] (I) -- (J);
        \draw [arrow] (J) -- (K);
        %\draw [arrow] (K)node[anchor=west] -|- node[anchor=east](L);
        \draw [arrow] (G) -- (L);
        \draw [arrow] (L) -- (New G);
        \draw [arrow] (New G) -- (Addition);
        \draw [arrow] (Addition) -- (OP);
        \draw [arrow] (F) -- (Addition);
        \draw [arrow] (E) -- (F);
        \draw [arrow] (E) -- (G);
        \draw [arrow] (A) -- (E);
        \draw [arrow, red] (K.west)--++(-0.5,0)|-(L.east);
        \end{tikzpicture}
%\end{figure*}
\end{document}

You must log in to answer this question.

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