Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have to write a flow chart given by figure below

enter image description here

I have used the packages,

\usepackage{tikz}

\usetikzlibrary{shapes,arrows}

But I couldn't get what I want. I hope some LaTeX experts here can help me with this.

Other option is using algorithm2e package, Is that possible to have both codes?

When I use the half commands it goes to other page? How to I write complete flow chart in one page ?

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{matrix,shapes,arrows,positioning,chains}

\begin{document}

% Define block styles
\tikzset{
desicion/.style={
    diamond,
    draw,
    text width=4em,
    text badly centered,
    inner sep=0pt
},
block/.style={
    rectangle,
    draw,
    text width=10em,
    text centered,
    rounded corners
},
cloud/.style={
    draw,
    ellipse,
    minimum height=2em
},
descr/.style={
    fill=white,
    inner sep=2.5pt
},
connector/.style={
    -latex,
    font=\scriptsize
},
rectangle connector/.style={
    connector,
    to path={(\tikztostart) -- ++(#1,0pt) \tikztonodes |- (\tikztotarget) },
    pos=0.5
},
rectangle connector/.default=-2cm,
straight connector/.style={
    connector,
    to path=--(\tikztotarget) \tikztonodes
}
}

\begin{tikzpicture}
\matrix (m)[matrix of nodes, column  sep=2cm,row  sep=8mm, align=center, nodes={rectangle,draw, anchor=center} ]{
    |[block]| {Start};               &  \\
    |[block]| {Assume that $a=c$ the optimilalty cretierin given by }               &                                            \\
    |[desicion]| {Locally optimal}          &                                             \\
   |[block]| {Assume that $a=d$ the optimilalty cretierin given by}    &                                             \\
    |[desicion]| {Locally optimal}         &                                             \\
         |[block]| {Assume that $a=e$ the optimilalty cretierin given by}    &                                             \\
            |[desicion]| {Locally optimal}         &                                             \\
                 |[block]| {Assume that $a=f$ the optimilalty cretierin given by}    &                                             \\
                    |[desicion]| {Locally optimal}         &                                             \\
                         |[block]| {Assume that $a=k$ the optimilalty cretierin given by}    &                                             \\
                            |[desicion]| {Locally optimal}         &                                             \\
    |[block]| {Stop};                           &                                             \\
};
\path [>=latex,->] (m-1-1) edge (m-2-1);
\path [>=latex,->] (m-2-1) edge (m-3-1);
\path [>=latex,->] (m-3-1) edge (m-4-1);
\path [>=latex,->] (m-4-1) edge (m-5-1);
\path [>=latex,->] (m-5-1) edge (m-6-1);
\path [>=latex,->] (m-6-1) edge (m-7-1);
\path [>=latex,->] (m-7-1) edge (m-8-1);
\path [>=latex,->] (m-8-1) edge (m-9-1);
\path [>=latex,->] (m-9-1) edge (m-10-1);
\path [>=latex,->] (m-10-1) edge (m-11-1);
\path [>=latex,->] (m-11-1) edge (m-12-1);

\end{tikzpicture}

\end{document}

enter image description here

share|improve this question
1  
Can you show us what you've tried so far? –  Paul Gessler Mar 28 at 23:52
    
@PaulGessler the one I wrote terrible, code doesn't compile either –  Harry Mar 29 at 0:05
    
possible starting point: Arrows at right angles on a tikzpicture matrix –  cmhughes Mar 29 at 0:42
3  
Note that even code which doesn't compile or is 'terrible' will save people time in trying to help if only because you provide at least a minimal framework for the document. –  cfr Mar 29 at 3:30
1  
@Harry I updated Jake's answer, you should be able to compile it now ;) –  cmhughes Mar 29 at 15:38

1 Answer 1

For example:

Flowchart diversion to right

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{matrix,shapes,arrows,positioning,chains}

\begin{document}

% Define block styles
\tikzset{
desicion/.style={
    diamond,
    draw,
    text width=4em,
    text badly centered,
    inner sep=0pt
},
block/.style={
    rectangle,
    draw,
    text width=10em,
    text centered,
    rounded corners
},
cloud/.style={
    draw,
    ellipse,
    minimum height=2em
},
descr/.style={
    fill=white,
    inner sep=2.5pt
},
connector/.style={
    -latex,
    font=\scriptsize
},
rectangle connector/.style={
    connector,
    to path={(\tikztostart) -- ++(#1,0pt) \tikztonodes |- (\tikztotarget) },
    pos=0.5
},
rectangle connector/.default=-2cm,
straight connector/.style={
    connector,
    to path=--(\tikztotarget) \tikztonodes
}
}

\begin{tikzpicture}
\matrix (m)[matrix of nodes, column  sep=2cm,row  sep=8mm, align=center, nodes={rectangle,draw, anchor=center} ]{
    |[block]| {Start}              &  \\
    |[block]| {Assume that $a=c$ the optimilalty cretierin given by }               &                                            \\
    |[desicion]| {Locally optimal}          &                                             \\
   |[block]| {Assume that $a=d$ the optimilalty cretierin given by}    &                                             \\
    |[desicion]| {Locally optimal}         &           |[block]| {Stop}                                   \\
         |[block]| {Assume that $a=e$ the optimilalty cretierin given by}    &    |[desicion]| {Locally optimal}                                          \\
            |[desicion]| {Locally optimal}         &       |[block]| {Assume that $a=k$ the optimilalty cretierin given by}                                      \\
                 |[block]| {Assume that $a=f$ the optimilalty cretierin given by}    &   |[desicion]| {Locally optimal}                                         \\
};
\path [>=latex,->] (m-1-1) edge (m-2-1);
\path [>=latex,->] (m-2-1) edge (m-3-1);
\path [>=latex,->] (m-3-1) edge (m-4-1);
\path [>=latex,->] (m-4-1) edge (m-5-1);
\path [>=latex,->] (m-5-1) edge (m-6-1);
\path [>=latex,->] (m-6-1) edge (m-7-1);
\path [>=latex,->] (m-7-1) edge (m-8-1);
\path [>=latex,->] (m-8-1) edge (m-8-2);
\path [>=latex,->] (m-8-2) edge (m-7-2);
\path [>=latex,->] (m-7-2) edge (m-6-2);
\path [>=latex,->] (m-6-2) edge (m-5-2);

\end{tikzpicture}

\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.