## LaTeX forum ⇒ Graphics, Figures & Tables ⇒ problem with creating flow chart Topic is solved

Information and discussion about graphics, figures & tables in LaTeX documents.
cat123
Posts: 2
Joined: Thu Sep 01, 2016 9:39 pm

### problem with creating flow chart

I'm trying to make a flow chart similar / the same as in that PNG image.

I tried with following but it didn't go well

\begin{tikzpicture}[node distance=2 cm,auto,>=latex']     \node [int, pin={[init]above:$\mu$}] (a) {$S$};     \node (b) [left of=a,node distance=2cm, coordinate] {a};     \node [int, pin={[init]above:$\mu$}] (c) [right of=a] {$I$};     \node [coordinate] (end) [right of=c, node distance=2cm]{};     \path[->] (b) edge node {$a$} (a);     \path[->] (a) edge node {$v$} (c);     \draw[->] (c) edge node {$p$} (end) ;\end{tikzpicture}
Attachments
SIRC.png (3.7 KiB) Viewed 2177 times
Last edited by Stefan Kottwitz on Thu Sep 08, 2016 1:19 pm, edited 2 times in total.
Reason: code marked

Tags:

Stefan Kottwitz
Posts: 9572
Joined: Mon Mar 10, 2008 9:44 pm
Welcome to the forum!

If you would post a minimal working example, it would be much easier. The code doesn't contain the styles int and init, so it brings errors.

The drawing is not difficult, I can take a look tomorrow (here it's after midnight), perhaps post the missing styles in the meantime.

Stefan

Stefan Kottwitz
Posts: 9572
Joined: Mon Mar 10, 2008 9:44 pm
Here is a start. I used a loop with the fancy TikZ syntax for counting and evaluating, to not repeat commands for nodes and edges so much.

\documentclass[border=80pt]{standalone}\usepackage{tikz}\usetikzlibrary{arrows, positioning}\tikzset{    rect/.style = { draw, minimum width = 2em, minimum height = 2ex },   label/.style = { font=\scriptsize },}\begin{document}\begin{tikzpicture}[     node distance = 1cm, auto, >=latex',     nodes = { execute at begin node=$, execute at end node=$ },   ]   \coordinate (0);   \foreach \txt/\label [ count=\current,       evaluate = \current as \previous using int(\current-1) ]       in {S/\mu,I/\beta,R/\alpha,C/\delta} {     \node [rect, right = of \previous] (\current) {\txt};     \draw [->] (\previous) -- node [label] {\label} (\current);     \draw [->] (\current)  -- node [label] {\mu} ++(0,1);   }   \draw [->] (4) to ++(0,-1) -| node [label, near end] {\gamma} (1);\end{tikzpicture}\end{document}

flowchart.png (7.47 KiB) Viewed 2144 times

Stefan