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.

This is my first attempt to create a figure using Tikz package in LaTex. (I am using TexMaker btw). So I have taken example codes here and there and slightly modified to come up with the figure that I want, but the words in my figure is not aligned as I intended.
Here are the corrections that I wish to make:

  1. The wordings are written over the loop arrows -> I would like the wordings cleared away from the loop arrows.
  2. I would like to have words below the symbol. So, the wording 'resisted infection' to appear below the symbol zeta. Same for 'not cured'
  3. Same for the wordings associated with straight arrows. I would prefer to have symbols above the arrow as it is, but the wordings possibly below the arrow. (Or even just below the symbol and above arrow)

enter image description here

Here is my code:

\documentclass[11pt]{article}

\usepackage[margin=0.5in]{geometry}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{arrows}

\title{Discrete Time SIR Model - Stochastic analysis}
\author{Louis Kim}

\begin{document}
\maketitle

\tikzstyle{int}=[circle, draw, fill=blue!20, minimum size=3em, auto]
\tikzstyle{init} = [pin edge={loop,thin,black}]

\begin{tikzpicture}[node distance=5cm,auto,>=latex']
    \node [int, pin={[init] $\zeta_{i,t}$,resisted infection}] (a) {$S$};
    \node [int, pin={[init] $1-\delta$,not cured}] (c) [right of=a] {$I$};
    \node [int] (e) [right of=c] {$R$};
    \path[->] (a) edge node {$1-\zeta_{i,t}$, not resisted infection} (c);
    \draw[->] (c) edge node {$\delta$, cured} (e) ;
\end{tikzpicture}
\end{document}

Any help would be greatly appreciated!! Thanks,

share|improve this question
    
Welcome to TeX.SX! You can have a look on our starter guide to familiarize yourself further with our format. –  Claudio Fiandrino Jun 12 '13 at 18:18
    
Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. –  Qrrbrbirlbel Sep 3 '13 at 18:54

1 Answer 1

  1. The pin solution you chose is an interesting one, though I don’t it doesn’t work perfectly with the loop option (there is also loop above) as the pin distance that places the pin node and the loop itself are independent.

    1. You could manually set a pin distance.
    2. You can use it as a node alongside a looped edge.
  2. Use the align=center option that allows one to manually use line-breaks (\\).

  3. You could use the same but then the two lines are too close to the line (I have introduced a little space).

    I rather would use two nodes, where the second one uses the swap option so that it goes to the other side (swap switches the direction of the auto option).

Code

\documentclass[tikz,convert=false]{standalone}
\usepackage{tikz}
\tikzset{
  int/.style={circle, draw, fill=blue!20, minimum size=3em},
  init/.style={pin distance=1.2cm,pin edge={loop,thin,black}}
}
\usetikzlibrary{arrows}

\begin{document}
\begin{tikzpicture}[node distance=5cm,auto,>=latex',every node/.append style={align=center}]
    \node [int, pin={[init] $\zeta_{i,t}$,\\resisted infection}] (a)              {$S$};
    \node [int, pin={[init] $1-\delta$,\\not cured}]             (c) [right of=a] {$I$};
    \node [int] (e) [right of=c] {$R$};
    \path[->, auto=false] (a) edge node {$1-\zeta_{i,t}$\\[.2em] not resisted infection} (c)
                          (c) edge node {$\delta$       \\[.2em] cured} (e) ;
\end{tikzpicture}
\begin{tikzpicture}[node distance=5cm,auto=right,>=latex',every node/.append style={align=center}]
    \node [int] (a)              {$S$} edge [loop] node {$\zeta_{i,t}$,\\resisted infection} ();
    \node [int] (c) [right of=a] {$I$} edge [loop] node {$1-\delta$,\\not cured} ();
    \node [int] (e) [right of=c] {$R$};
    \path[->, auto=left] (a) edge node {$1-\zeta_{i,t}$} node[swap] {not resisted infection} (c)
                         (c) edge node {$\delta$}        node[swap] {cured} (e) ;
\end{tikzpicture}
\end{document}

Outputs

enter image description here

enter image description here

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.