Graphics, Figures & TablesTikz | Simple flow chart

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
bkarpuz
Posts: 124
Joined: Thu Dec 18, 2008 4:53 pm

Tikz | Simple flow chart

Post by bkarpuz »

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 12227 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10328
Joined: Mon Mar 10, 2008 9:44 pm

Tikz | Simple flow chart

Post by Stefan Kottwitz »

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.org admin
bkarpuz
Posts: 124
Joined: Thu Dec 18, 2008 4:53 pm

Tikz | Simple flow chart

Post by bkarpuz »

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

Code, edit and compile here:
\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}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
This one also looks as the distance between the elements are not spaced good.

Thank you.
bkarpuz
User avatar
Stefan Kottwitz
Site Admin
Posts: 10328
Joined: Mon Mar 10, 2008 9:44 pm

Tikz | Simple flow chart

Post by Stefan Kottwitz »

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

\path [line] (question) -- ++(-4,0) |- (operationb);
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
which means going 4 to the left and connecting to operationb horizontally and then vertically.
flowchart.png
flowchart.png (5.14 KiB) Viewed 12220 times
Stefan
LaTeX.org admin
bkarpuz
Posts: 124
Joined: Thu Dec 18, 2008 4:53 pm

Tikz | Simple flow chart

Post by bkarpuz »

Stefan_K wrote: The missing path can be done like

Code: Select all

\path [line] (question) -- ++(-4,0) |- (operationb);
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
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

\path [line] (question) -- node {No} ++(-4,0) |- (operationb);
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
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 21, 2012 7:51 am, edited 1 time in total.
bkarpuz
Posts: 124
Joined: Thu Dec 18, 2008 4:53 pm

Tikz | Simple flow chart

Post by bkarpuz »

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

\node [input] (input) {$h,n_{0},t_{0},y_{0}$};
\node [operation, below=2cm of input] (operationa) {$n=0$};
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
What is the problem with this line?

Thank you.
bkarpuz
Post Reply