I have the following standalone class file to create a figure for a journal paper:



            \SetUpEdge[lw = 1pt, color = black]
            \tikzset{VertexStyle/.append  style={fill}}
            \Vertex[L=$ x~{+\!\!=}~\delta x $]{Begin}
            \NO[unit=3,L=$ y~{+\!\!=}~\delta y $](Direction){Up}
            \SO[unit=3,L=$ y~{-\!\!=}~\delta y $](Direction){Down}
            \WE[unit=4,L=$ x {=} 0${,~}$y {=} 0$](Begin){Start}

            \Edge[label=$ p_{\mathrm{straight} } $](Start)(Begin)
            \Loop[dir=NO, dist=80,label=$ 1- p_{\mathrm{straight}} $](Start)
            \Edge[style={bend left=15}, label = $ 1 $](Begin)(Turn)
            \Edge[style={bend left=15},label=$ 1-p_{\mathrm{turn}} $](Turn)(Begin)
            \Edge[label=$ p_{\mathrm{turn}}$](Turn)(Direction)
            \Edge[label=$ p_{\mathrm{up}} $](Direction)(Up)
            \Edge[label=$ 1-p_{\mathrm{up}} $](Direction)(Down)
            \Edge[style={bend right=20},label=$ 1 $](Up)(Begin)
            \Edge[style={bend left=20}, label = $ 1 $](Down)(Begin)

which produces the following image:

Graph of corrosion model

However, I would like to move the label at the left that is cut through by the loop so that it sits just above the loop. So far I have not been able to do so and cannot find documentation for the \Loop command I have used.

Any suggestions or resources to fix this would be much appreciated.

  • 1
    Try replacing label=$ 1- p_{\mathrm{straight}} $ with label=above:$ 1- p_{\mathrm{straight}} $. – cfr Nov 2 '17 at 4:17
  • That did not work but: \Loop[dir=NO, dist=80,labelstyle = above, label=$ 1- p_{\mathrm{straight}} $](Start) did – Bruce Crawford Nov 2 '17 at 6:50

Here's the diagram using a matrix of math nodes:

enter image description here

The code:




    \matrix (M)[matrix of math nodes,row sep=10mm,column sep=20mm,
                every node/.append style={circle,draw=black!80!blue, thick, minimum size=12mm}]{
                &             &             & y\pe\delta y\\
       \substack{x=0\\ y=0}& x \pe\delta x & \text{Turn} & \text{Direction}\\
                &             &             & y\me\delta y\\
     \draw(M-2-1) --node[overwrite]{$p_{\text{straight}}$} (M-2-2);
     \draw(M-2-1) to [out=145,in=35,min distance=18mm]
                       node[above]{$1-p_{\text{straight}}$} (M-2-1);
     \draw(M-2-2) to [out=20,in=160] node[overwrite]{$1$}(M-2-3);
     \draw(M-2-3) to [out=200,in=340]node[overwrite]{$1-p_{\text{turn}}$}(M-2-2);
     \draw(M-2-3) --node[overwrite]{$p_{\text{turn}}$} (M-2-4);
     \draw(M-2-4) --node[overwrite]{$p_{\text{up}}$} (M-1-4);
     \draw(M-2-4) --node[overwrite]{$1-p_{\text{up}}$} (M-3-4);
     \draw(M-1-4.west) to [out=180, in=65]node[overwrite]{$1$} (M-2-2);
     \draw(M-3-4.west) to [out=180, in=295]node[overwrite]{$1$} (M-2-2);


You can easily adjust the row and column spacing by changing row sep=10mm,column sep=20mm. I have defined operators \pe and \me and made the circles around the nodes thick, rather than the arrows, but otherwise this is much the same.

  • @BruceCrawford Glad it was useful. I find matrix of nodes to be invaluable! – Andrew Nov 3 '17 at 15:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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