21

I'm trying to create a fine flowchart that is a bit complicated. Therefore I need a block for a predefined process and a connector block as well as a data block.
Can someone help me? In comment is what I'd like to see in my code to keep my code nicely arranged. The rest of the code is a simple example for the Tikz site.

\documentclass{article}

\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\begin{document}
\pagestyle{empty}


% 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']
\tikzstyle{cloud} = [draw, ellipse,fill=red!20, node distance=3cm,
    minimum height=2em]

%\tikzstyle{subroutine} = [draw,rectangle split, rectangle split         horizontal,rectangle split parts=3,minimum height=1cm] 
%\tikzstyle{connector} = [draw,circle,...]
%\tikzstyle{data} = [draw, trapezium, ...]

\begin{tikzpicture}[node distance = 2cm, auto]
    % Place nodes
    \node [block] (init) {initialize model};
    \node [cloud, left of=init] (expert) {expert};
    \node [cloud, right of=init] (system) {system};
    \node [block, below of=init] (identify) {identify candidate models};
    \node [block, below of=identify] (evaluate) {evaluate candidate models};
    \node [block, left of=evaluate, node distance=3cm] (update) {update     model};
    \node [decision, below of=evaluate] (decide) {is best candidate     better?};
    \node [block, below of=decide, node distance=3cm] (stop) {stop};
    % Draw edges
    \path [line] (init) -- (identify);
    \path [line] (identify) -- (evaluate);
    \path [line] (evaluate) -- (decide);
    \path [line] (decide) -| node [near start] {yes} (update);
    \path [line] (update) |- (identify);
    \path [line] (decide) -- node {no}(stop);
    \path [line,dashed] (expert) -- (init);
    \path [line,dashed] (system) -- (init);
    \path [line,dashed] (system) |- (evaluate);
\end{tikzpicture}


\end{document}

enter image description here

0

1 Answer 1

21

I am not sure if something like this is what you need; I changed from the old \tikzstyle to \tikzset:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,shapes.multipart}

\begin{document}
\pagestyle{empty}


% Define block styles
\tikzset{
decision/.style = {diamond, draw, fill=blue!20, 
  text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt},
block/.style = {rectangle, draw, fill=blue!20, 
  text width=5em, text centered, rounded corners, minimum height=4em},
line/.style = {draw, -latex'},
cloud/.style = {draw, ellipse,fill=red!20, node distance=3cm,
  minimum height=2em},
subroutine/.style = {draw,rectangle split, rectangle split horizontal,
  rectangle split parts=3,minimum height=1cm,
  rectangle split part fill={red!50, green!50, blue!20, yellow!50}},
connector/.style = {draw,circle,node distance=3cm,fill=yellow!20},
data/.style = {draw, trapezium,node distance=3cm,fill=olive!20}
}

\begin{tikzpicture}[node distance = 2cm, auto]
    % Place nodes
    \node [block] (init) {initialize model};
    \node [data, left of=init] (expert) {expert};
    \node [connector, right of=init] (system) {system};
    \node [block, below of=init] (identify) {identify candidate models};
    \node [block, below of=identify] (evaluate) {evaluate candidate models};
    \node [block, left of=evaluate, node distance=3cm] (update) {update     model};
    \node [decision, below of=evaluate] (decide) {is best candidate     better?};
    \node [block, below of=decide, node distance=3cm] (test) {test};
    \node [subroutine, below of=test, node distance=3cm] (sub) {part1\nodepart{two}part2\nodepart{three}part3};
    % Draw edges
    \path [line] (init) -- (identify);
    \path [line] (identify) -- (evaluate);
    \path [line] (evaluate) -- (decide);
    \path [line] (decide) -| node [near start] {yes} (update);
    \path [line] (update) |- (identify);
    \path [line] (decide) -- node {no}(test);
    \path [line,dashed] (test) -- (sub);
    \path [line,dashed] (expert) -- (init);
    \path [line,dashed] (system) -- (init);
    \path [line,dashed] (system) |- (evaluate);
\end{tikzpicture}

\end{document}

enter image description here

3
  • ! Package pgfkeys Error: I do not know the key '/tikz/rectangle split horizonta l' and I am going to ignore it. Perhaps you misspelled it. This is the error that I get when I run your code, any ideas what the problem in my version/packages may be? Oct 22, 2012 at 18:40
  • 1
    @JasperLammens sound like your version of PGF is outdated. Which version do you use? Process \documentclass{article} \usepackage{tikz} \begin{document} \pgfversion \end{document} to get your version; if it's less than 2.10, you'll need to update the package. Oct 22, 2012 at 18:42
  • @GonzaloMedina While using your code with the removal of spilt rectangular part i am getting compressed flow chart. Any suggestion? tex.stackexchange.com/questions/113476/… May 9, 2013 at 17:12

You must log in to answer this question.

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