I am creating a beamer presentation. I try to create a tikz flow chart. Here is my production. T_T enter image description here

Actually, what I want to do is enter image description here

Be grateful with any help! So frustrated now.

% Define block styles
\tikzstyle{decision} = [diamond, draw, fill=blue!20,
text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt]
\tikzstyle{block} = [rectangle, draw, fill=blue!20,
text width=5em, text centered, rounded corners, minimum height=4em]
\tikzstyle{line} = [draw, -latex']
\begin{tikzpicture}[node distance = 2cm, auto]
% Place nodes
\node [block] (begin) {begin};
\node [block, below of=begin] (input) {input};
\node [block, below of=input] (data) {initdata };
\node [decision, below of=data] (judge) {judge the data};
\node [block, right of=judge, node distance=4cm] (output) {update model};
\node [block, below of=judge] (sum) {s=s+(i-1)};
\node [block, below of=sum, node distance=3cm] (increase) {i=i+1};
% Draw edges
\path [line] (begin) -- (input);
\path [line] (input) -- (data);
\path [line] (data) -- (judge);
\path [line] (sum) -- (increase);
\path [line] (judge) -| node [near start] {no} (output);
\path [line] (judge) |- node [near start]{yes}(sum);
\path [line] (increase)--(judge);
  • 1
    Please show us the code of what you've done so far as well, not just a screenshot. – Torbjørn T. Nov 14 '13 at 13:33
  • In tikz-picture-shapes you will find some missing shapes. – Ignasi Nov 14 '13 at 16:09

This is a solution via TikZ matrix node

enter image description here


\usetikzlibrary{matrix, shapes, arrows, positioning}
decision/.style = {diamond, draw, fill=blue!20, text width=5em, text badly centered, inner sep=0pt},
block/.style = {rectangle, draw, fill=blue!20,text width=6em, text centered, rounded corners, minimum height=4em},
io/.style ={trapezium, draw, minimum width=2.5cm,trapezium left angle=60, trapezium right angle=120},
line/.style = {draw, -stealth},
cloud/.style = {draw, rectangle, fill=red!20, minimum height=2em, minimum width=1.5cm, rounded corners=10pt}}

% Place nodes with matrix nodes
 \matrix[matrix of nodes, column sep=1cm, row sep=1cm]{%
    \node [cloud] (init) {\color{red}begin}; & \\
    \node [io] (identify) {\color{red}input};&\\
    \node [block] (evaluate) {$i=1,s=1$};    & \\
    \node [decision] (decide) {$i \le n$?};  & 
    \node [io] (print) {{\color{red}output}};               \\
    \node [block] (stop) {$s=s+(i-1)$};      & \node [cloud] (end) {\color{red}stop};   \\
    \node [block] (loop) {$i=i+1$};          & \\
% Draw edges
    \path [line] (init) -- (identify);  
    \path [line] (identify) -- (evaluate);
    \path [line] (evaluate) -- (decide);
    \path [line] (decide) -- node[right]{\color{red}Yes} (stop);
    \path [line] (decide) --node[above]{\color{red}No} (print);
    \path [line] (print.south) -- (end);
    \path [line] (stop) --  (loop);
    \path [line] (loop) -- ++(-2,0) |-(decide);
  • Thank you for your reply. I'm sorry to tell you that it fails to compile in my computer. The error shows that "not in outer par mode". The error focus on \begin{center}. Shall we have to use \begin center? Thanks! – Hinn Nov 15 '13 at 9:12
  • 1
    \centering instead of center environment – percusse Nov 15 '13 at 9:33
  • @percusse still shows the same error...... – Hinn Nov 15 '13 at 10:00
  • @Hinn It should go away with article class. Standalone is not meant for floats. – percusse Nov 15 '13 at 10:02
  • 1
    @Hinn -- Sorry I was unavaible when you had questions. Glad to know that it works now. My appreciation also goes to percusse for the helping hand. – Jesse Nov 15 '13 at 11:22

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.