6

Can someone help me moving "No" to the red circle in the following picture:

enter image description here

My LaTeX-code is like this:

\node (pro1) [process] {Send out tenders};
\node (pro3) [process, below of=pro1, fill=gray!30] {Run model with updated estimates of waiting times};
\node (out1) [io, below of=pro3] {Obtain new optimal route};
\node (pro4) [process, below of=out1] {Serve customer};
\node (dec1) [decision, below of=pro4, aspect = 3, yshift=-1cm] {Are all customers served?};
\node (pro5) [process, below of=dec1, yshift=-1cm] {Leave port};
\draw[arrow] (pro1) -- (pro3);
\draw[arrow] (pro3) -- (out1);
\draw[arrow] (out1) -- (pro4);
\draw[arrow] (pro4) -- (dec1);
\draw [arrow] (dec1) -- node[anchor=east] {Yes} (pro5);
\draw [arrow] (dec1) -| node[anchor=north ] {No} ([xshift=-4.50cm]pro1.south west)  |- (pro1);
7

anchor=north is the same as below, so that node is placed below the current position. When using the syntax (coord1) -- node{a} (coord2), the default is to place the node halfway along the path between the two points. This position of the node along the path can be changed with pos=<fraction>, so for example pos=0.25 places the node a quarter of the way along the path.

When using -| or |- this is slightly different. The default position, equal to pos=0.5, is at the corner of the path. This is why, with your original code, the No-node was placed below the corner. Further, 0.25 in this case is halfway along the first segment.

Hence, for this case node[above,pos=0.25] {No} does what you want.

(In the code below I defined all your custom styles as empty styles. It is always nicer if you provide such definitions, as it makes it easier for us. Ideally, create a complete example such as the one below, so that we can just copy-paste the entire code block and test it directly.)

enter image description here

\documentclass[tikz,border=2mm]{standalone}

\begin{document}
\begin{tikzpicture}[process/.style={},decision/.style={},arrow/.style={},io/.style={}]
\node (pro1) [process] {Send out tenders};
\node (pro3) [process, below of=pro1, fill=gray!30] {Run model with updated estimates of waiting times};
\node (out1) [io, below of=pro3] {Obtain new optimal route};
\node (pro4) [process, below of=out1] {Serve customer};
\node (dec1) [decision, below of=pro4,, yshift=-1cm] {Are all customers served?};
\node (pro5) [process, below of=dec1, yshift=-1cm] {Leave port};
\draw[arrow] (pro1) -- (pro3);
\draw[arrow] (pro3) -- (out1);
\draw[arrow] (out1) -- (pro4);
\draw[arrow] (pro4) -- (dec1);
\draw [arrow] (dec1) -- node[anchor=east] {Yes} (pro5);
\draw [arrow] (dec1) -| node[above,pos=0.25] {No} ([xshift=-4.50cm]pro1.south west)  |- (pro1);
\end{tikzpicture}
\end{document}

Your Answer

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