3

I have the following chart in tikz. I need to draw an arrow that starts horizontal then goes vertical from the decision shape to the end with label no. I have tried using -| instead of -- but this generated an error.

1) How to draw the arrow (like the red arrow I added for illustration?

2) How to reduce the width of the io shape (\tikzstyle{io} )?

Here is my shape: enter image description here

And my script:

\documentclass[10pt]{llncs}
\usepackage{tikz} 
\usetikzlibrary{shapes.geometric, arrows} 
\title{title}
\author{Authors here\\
    \small{Department here}\\
    \small{University here, Country}\\
}
\date{}

\begin{document}
\maketitle

\section{Chart}
\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, text width=3cm, 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{tikzpicture}[node distance=2cm]
\node (start) [startstop] {Start};
\node (in01) [io, below of = start] {xxxxxxx xxxx};
\node (proc01) [process, below of = in01] {aaaaaaa aaaaaaa aaaaaaa};
\node (proc02) [process, below of = proc01] {ccccccc};
\node (dec01) [decision, below of = proc02] {bbb-bb?};
\node (proc03) [process, below of = dec01, , yshift=-0.5cm] {aaaaaaa aaaaaaa aaaaaaa};
\node (proc04) [process, below of = proc03] {ccccccc};
\node (end) [startstop, below of = proc04] {End};

\draw [arrow] (start) -- (in01);
\draw [arrow] (in01) -- (proc01);
\draw [arrow] (proc01) -- (proc02);
\draw [arrow] (proc02) -- (dec01);
\draw [arrow] (dec01) -- node[anchor=east]{Yes} (proc03);
%\draw [arrow] (dec01) -- node[anchor=east]{No} (end);
\draw [arrow] (proc03) -- (proc04);
\draw [arrow] (proc04) -- (end);
\end{tikzpicture}
\end{document}

2 Answers 2

1

You need to add trapezium stretches body. (Also converted \tikzstyle to the more modern syntax.) EDIT: Added No.

\documentclass[border=3.14mm,tikz,x11names,dvipsnames,svgnames]{standalone}
\usetikzlibrary{shapes.geometric, arrows} 
\begin{document}
\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=1cm,   %<- changed
trapezium stretches body,%<- added
 minimum height=1cm, text centered, draw=black, fill=blue!30},
process/.style={rectangle, minimum width=3cm, minimum height=1cm, text centered,
text width=3cm, 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}}

\begin{tikzpicture}[node distance=2cm]
\node (start) [startstop] {Start};
\node (in01) [io, below of = start] {xxxxxxx xxxx};
\node (proc01) [process, below of = in01] {aaaaaaa aaaaaaa aaaaaaa};
\node (proc02) [process, below of = proc01] {ccccccc};
\node (dec01) [decision, below of = proc02] {bbb-bb?};
\node (proc03) [process, below of = dec01, , yshift=-0.5cm] {aaaaaaa aaaaaaa aaaaaaa};
\node (proc04) [process, below of = proc03] {ccccccc};
\node (end) [startstop, below of = proc04] {End};

\draw [arrow] (start) -- (in01);
\draw [arrow] (in01) -- (proc01);
\draw [arrow] (proc01) -- (proc02);
\draw [arrow] (proc02) -- (dec01);
\draw [arrow] (dec01) -- node[anchor=east]{Yes} (proc03);
%\draw [arrow] (dec01) -- node[anchor=east]{No} (end);
\draw [arrow] (proc03) -- (proc04);
\draw [arrow] (proc04) -- (end);
\draw [arrow,rounded corners,red,thick] (dec01.east) -- ++(1cm,0) |- (end)
node[pos=0.1,sloped,above]{No};
\end{tikzpicture}
\end{document}

enter image description here

3
  • Thanks. But how can I add No on the arrow (I updated my figure, plz check). Commented Aug 1, 2018 at 15:00
  • @user9371654 I added the No.
    – user121799
    Commented Aug 1, 2018 at 15:04
  • @user9371654 If you want the text "No" to be black, do node[pos=0.1,sloped,above,text=black]{No};
    – user121799
    Commented Aug 1, 2018 at 15:13
1

as supplement to marmot answer (which solve your problem) mostly as exercise how to write for your simple flowchart shorter code ...

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta, chains, shapes.geometric}

\tikzset{FlowChart/.style = {% for distinguish from other tikz sets used in your document
     base/.style = {rectangle, draw,
                    minimum width=3cm, minimum height=1cm, align=center,
                    text width =\pgfkeysvalueof{/pgf/minimum width}-2*\pgfkeysvalueof{/pgf/inner xsep},
                    on chain, join=by arrow},
startstop/.style = {base, fill=red!30, rounded corners},
       io/.style = {trapezium, trapezium left angle=70, trapezium right angle=110,
                    trapezium stretches body,
                    draw=black, fill=blue!30,
                    minimum width=1cm, minimum height=1cm, align=center,
                    on chain, join=by arrow},
   process/.style = {base, fill=orange!30},
  decision/.style = {diamond, aspect=1.2, draw, fill=green!30,
                     minimum width=3cm, minimum height=1cm, align=center,
                     on chain, join=by arrow},
     arrow/.style = {thick,-Stealth}}
        }

\begin{document}
    \begin{tikzpicture}[FlowChart,
  node distance = 6mm and 12mm,
    start chain = going below]
% nodes
\node (start)   [startstop] {Start};
\node (in01)    [io]        {xxxxxxx xxxx};
\node (proc01)  [process]   {aaaaaaa aaaaaaa aaaaaaa};
\node (proc02)  [process]   {ccccccc};
\node (dec01)   [decision]  {bbb-bb?};
\node (proc03)  [process]   {aaaaaaa aaaaaaa aaaaaaa};
\node (proc04)  [process]   {ccccccc};
\node (end)     [startstop] {End};
% extra paths
\path           (dec01) -- node[right] {Yes} (proc03);
\draw [arrow]   (dec01.east) -- node[above] {No} ++(1cm,0) |- (end);
    \end{tikzpicture}
\end{document}

enter image description here

You must log in to answer this question.

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