Featured Book

LaTeX Beginners Guide

Who is online

In total there are 5 users online :: 1 registered, 0 hidden and 4 guests (based on users active over the past 5 minutes)
Most users ever online was 1327 on Tue Nov 05, 2013 7:11 pm

Users browsing this forum: Bing [Bot] and 4 guests

Partner Sites

TeXwelt - Fragen und Antworten goLaTeX
TeXblog
TeXnicCenter
TeXample

Tikz | Simple flow chart

flowchartspathsshapesTikZAdd tags Information and discussion about graphics, figures & tables in LaTeX documents.

Tikz | Simple flow chart

Postby bkarpuz on Wed Dec 19th, 2012

Dear LC members,

I have a flow chart which consists of a parallelogram, a rectangle, a diamond and a trapezoid as attached. I tried myself but could not get any successful results and I couldn't combine with No line Query and Operations box. I would really appreciate your help on giving me a flow chart sample.

Thank you very much.
bkarpuz
Attachments
FlowChart.JPG
FlowChart.JPG (11.26 KiB) Viewed 2404 times
bkarpuz
 
Posts: 124
Joined: Thu Dec 18th, 2008

Re: Tikz | Simple flow chart

Postby Stefan_K on Wed Dec 19th, 2012

Hello,

bkarpuz wrote:I tried myself but could not get any successful results


what did you try? Perhaps we can continue that instead that reader start from scratch.

bkarpuz wrote:I couldn't combine with No line Query and Operations box.


It should be no problem. Once we see your code I guess we are able to show how to do the connection.

Stefan
LaTeX Community Administrator
User avatar
Stefan_K
Site Admin
 
Posts: 6312
Joined: Mon Mar 10th, 2008
Location: Hamburg, Germany

Re: Tikz | Simple flow chart

Postby bkarpuz on Wed Dec 19th, 2012

Stefan_K wrote:Hello,

bkarpuz wrote:I tried myself but could not get any successful results


what did you try? Perhaps we can continue that instead that reader start from scratch.

bkarpuz wrote:I couldn't combine with No line Query and Operations box.


It should be no problem. Once we see your code I guess we are able to show how to do the connection.

Stefan


Thank you Stefan_K.
Here is my code.
Code: Select all  •  Open in writeLaTeX
\documentclass{article}

\usepackage{tikz}

\usetikzlibrary{shapes,arrows,shapes.multipart}

\begin{document}

\tikzset{
startend/.style = {draw, circle},
input/.style = {draw, trapezium, trapezium left angle=70, trapezium right angle=-70, minimum height=4em},
print/.style = {draw, trapezium, trapezium left angle=-70, trapezium right angle=-70, minimum height=4em},
operation/.style = {rectangle, draw, text width=17em, text centered, minimum height=4em},
question/.style = {diamond, draw, text width=8em, text centered, inner sep=0pt},
line/.style = {draw, -latex'}
}

\begin{tikzpicture}[node distance = 3cm, auto]
    \node [startend] (start) {Start};
    \node [input, below of=start] (input) {$h,n_{0},x_{0},y_{0}$};
    \node [operation, below of=input] (operationa) {$n=0$};
    \node [operation, below of=operationa] (operationb) {$n=n+1$\\ $x_{n}=x_{n-1}+h$\\ $y_{n}=y_{n-1}+hf(x_{n-1},y_{n-1})$};
    \node [question, below of=operationb] (question) {$x_{n}\geq{}x_{0}+n_{0}h$};
    \node [print, below of=question] (print) {$x_{0},y_{0}$};
    \node [startend, below of=print] (end) {End};

    \path [line] (start) -- (input);
    \path [line] (input) -- (operationa);
    \path [line] (operationa) -- (operationb);
    \path [line] (operationb) -- (question);
    \path [line] (question) -- node {No} (operationb);
    \path [line] (question) -- node {Yes} (print);
    \path [line] (print) -- (end);
\end{tikzpicture}

\end{document
}

This one also looks as the distance between the elements are not spaced good.

Thank you.
bkarpuz
bkarpuz
 
Posts: 124
Joined: Thu Dec 18th, 2008

Re: Tikz | Simple flow chart

Postby Stefan_K on Wed Dec 19th, 2012

I guess the spacing is between the anchors / centers of the nodes, and they have a different height. You could specify an yshift value, or use relative positioning such as below =4cm of nodename.

The missing path can be done like

Code: Select all  •  Open in writeLaTeX
\path [line] (question) -- ++(-4,0) |- (operationb);


which means going 4 to the left and connecting to operationb horizontally and then vertically.

flowchart.png
flowchart.png (5.14 KiB) Viewed 2397 times


Stefan
LaTeX Community Administrator
User avatar
Stefan_K
Site Admin
 
Posts: 6312
Joined: Mon Mar 10th, 2008
Location: Hamburg, Germany

Re: Tikz | Simple flow chart

Postby bkarpuz on Thu Dec 20th, 2012

Stefan_K wrote:The missing path can be done like
Code: Select all  •  Open in writeLaTeX
\path [line] (question) -- ++(-4,0) |- (operationb);

which means going 4 to the left and connecting to operationb horizontally and then vertically.

Thank you Stefan_K, I have modified it as follows for my purpose
Code: Select all  •  Open in writeLaTeX
\path [line] (question) -- node {No} ++(-4,0) |- (operationb);

On the other hand, why there letters are scattered in the equation $n=n+1$ and the others? How can I make them look like as in the mathematical text.
Also it is possible to edit the lines so that I adjust manually the distance between each object?

Thanks once more.
bkarpuz
Last edited by bkarpuz on Fri Dec 21st, 2012, edited 1 time in total.
bkarpuz
 
Posts: 124
Joined: Thu Dec 18th, 2008

Re: Tikz | Simple flow chart

Postby bkarpuz on Fri Dec 21st, 2012

Stefan_K wrote:You could specify an yshift value, or use relative positioning such as below =4cm of nodename.

The following line does not compile.
Code: Select all  •  Open in writeLaTeX
    \node [input] (input) {$h,n_{0},t_{0},y_{0}$};
    \node [operation, below=2cm of input] (operationa) {$n=0$
};

What is the problem with this line?

Thank you.
bkarpuz
bkarpuz
 
Posts: 124
Joined: Thu Dec 18th, 2008


Topic Tags

flowchartspathsshapesTikZ

Return to Graphics, Figures & Tables

Who is online

Users browsing this forum: Bing [Bot] and 4 guests