TransWikia.com

Improve A Tikz Flowchart

TeX - LaTeX Asked by OOzy Pal on December 5, 2020

Flowchart

How can I add the circles as shown in the above flowchart so I can number each process? Now my optimum goal is to show a process using a flowchart and describe each box under the flowchart so I came up with the idea of putting a number on each box then describe it below.

If possible help me putting these circles or if possible propose another way.

The code:

                documentclass{standalone}
            usepackage{tikz}
            
            usetikzlibrary{shapes.geometric, arrows}
            tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, fill=red!30]
            tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30]
            tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=orange!30]
            tikzstyle{decision} = [diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30]
            tikzstyle{arrow} = [thick,->,>=stealth]
            
            
            begin{document}
            
                begin{tikzpicture}[node distance=2cm]
                small
                node (start) [startstop] {Start};
                node (dec1) [decision, right of=start, xshift=1.5cm,align=center] {Decision1};
                draw [arrow] (start) -- (dec1);
                node (pro1) [process, right of=dec1, xshift=1.75cm,align=center] {Process};
                draw [arrow] (dec1) -- node[anchor=south] {No} (pro1);
                node (dec2) [decision, below of=dec1, yshift=-0.95cm,align=center] {Decision2};
                draw [arrow] (dec1) -- node[anchor=west] {Yes} (dec2);
            end{tikzpicture}
            
            end{document}

2 Answers

You can use append after command to define a style that adds these circles. For instance,

clabel=1 between north west and north east

places the node at the upper edge, and

clabel=2 between north and east

puts it on the upper right diagonal. Please note that tikzstyle is deprecated, and so is your method of positioning nodes.

documentclass[tikz,border=3mm]{standalone}
usetikzlibrary{positioning,shapes.geometric}
tikzset{startstop/.style={rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, fill=red!30},
io/.style={trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30},
process/.style={rectangle, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=orange!30},
decision/.style={diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30},
arrow/.style={thick,->,>=stealth},
clabel/.style args={#1 between #2 and #3}{append after command={
(tikzlastnode.#2) -- (tikzlastnode.#3) 
node[pos=0.5,circle,draw,font=sffamily,fill=white,inner sep=1pt]{#1}
}}}


begin{document}

begin{tikzpicture}[node distance=3em and 2.5em,nodes={font=smallsffamily,align=center}]
    node (start) [startstop,clabel=1 between north west and north east] {Start};
    node (dec1) [decision, right=of start,clabel=2 between north and east] {Decision1};
    draw [arrow] (start) -- (dec1);
    node (pro1) [process, right=of dec1,clabel=3 between north west and north east] {Process};
    draw [arrow] (dec1) -- node[anchor=south] {No} (pro1);
    node (dec2) [decision, below=of dec1,clabel=4 between north and east] {Decision2};
    draw [arrow] (dec1) -- node[anchor=west] {Yes} (dec2);
end{tikzpicture}
end{document}

enter image description here

Correct answer by user229669 on December 5, 2020

Do you mean just adding cricles like this:

documentclass{standalone}
            usepackage{tikz}
            
            usetikzlibrary{shapes.geometric, arrows}
            tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, fill=red!30]
            tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30]
            tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=orange!30]
            tikzstyle{decision} = [diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30]
            tikzstyle{arrow} = [thick,->,>=stealth]
            
            
            begin{document}
            
                begin{tikzpicture}[node distance=2cm]
                small
                node (start) [startstop] {Start};
                node (dec1) [decision, right of=start, xshift=1.5cm,align=center] {Decision1};
                draw [arrow] (start) -- (dec1);
                node (pro1) [process, right of=dec1, xshift=1.75cm,align=center] {Process};
                draw [arrow] (dec1) -- node[anchor=south] {No} (pro1);
                node (dec2) [decision, below of=dec1, yshift=-0.95cm,align=center] {Decision2};
                draw [arrow] (dec1) -- node[anchor=west] {Yes} (dec2);
                
                %adds circles
                draw [thick] (0,0.5) circle (4pt);
                draw [thick] (4.3,0.5) circle (4pt);
                draw [thick] (7,0.5) circle (4pt);
                draw [thick] (2.7,-2.5) circle (4pt);
            end{tikzpicture}
            
            end{document}

enter image description here

With numbers inside:

               draw [thick] (0,0.5) circle (4pt);
                node at (0,0.5) {1};
                draw [thick] (4.3,0.5) circle (4pt);
                node at (4.3,0.5) {2};
                draw [thick] (7,0.5) circle (4pt);
                node at (7,0.5) {3};
                draw [thick] (2.7,-2.5) circle (4pt);
                node at (2.7,-2.5) {4};

enter image description here

Answered by Roland on December 5, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP