5

I am trying to join to two nodes together following the simple flow chart example. I would like to join two blocks with curved arrows that begin and end in the same places on both blocks (or close enough). Instead, I get weird second arrow heads on the original attachment points. I have tried to change the in and out angles but it does not seem to help...

My MWE:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.arrows,arrows}   
\makeatother
\tikzstyle{block} = [rectangle, draw, fill=blue!50!black!20, 
text width=2cm, text centered, rounded corners, minimum height=2cm, minimum    width=4cm]
\tikzstyle{sblock} = [rectangle, draw, fill=blue!50!black!20, 
text width=2cm, text centered, rounded corners, minimum height=2cm, minimum     width=2cm]
\tikzstyle{line} = [draw, -latex']

\begin{document}
\begin{tikzpicture}[x=1cm,y=1cm]
 % This is the "base case"
   \node [block] at (6,7) (A) {A};  
   \node [sblock] at (1,6) (B) {B};   
   \path [line,thick] (B) edge [ bend right] node {} (A);
   \path [line,thick] (A) edge [bend right] node {} (B);

% This is closer to what I want, but a mess...
   \node [block] at (6,3) (C) {C};  
   \node [sblock] at (1,2) (D) {D};   
   \path [line,thick] (C.west) edge [bend right] node {} (D.east);
   \path [line,thick] (D.east) edge [bend right] node {} (C.west);   

 % No better
   \node [block] at (6,-1) (E) {E};  
   \node [sblock] at (1,-2) (F) {F};   
   \path [line,thick] (E.west) edge [bend right =60] node {} (F.east);
   \path [line,thick] (F.east) edge [bend right=60] node {} (E.west);   
\end{tikzpicture}}
\end{document}

Silly output

As you can see, there is a second arrowhead on the lower block (there is one on the upper block too, it is just obscured). Basically I want the arrows to start on the west/east anchor point.

7

One way would be to use a to path, e.g.

\path [line,thick] (E.west) to[out=180,in=60] (F.east);

You can also use edge, but in that case you need to specify the arrow tip for only the edge, not the entire path, e.g.

\path [thick] (C.west) edge [line,bend left] (D.east);

To explain why, I first quote the manual (the second tutorial):

It is now time for Hagen to learn about yet another way of specifying edges: Using the edge path operation. This operation is very similar to the to operation, but there is one important difference: Like a node the edge generated by the edge operation is not part of the main path, but is added only later. This may not seem very important, but it has some nice consequences. For example, every edge can have its own arrow tips and its own color and so on and, still, all the edges can be given on the same path.

While I do not know the details, I guess this is the reason for the double arrow tips. You get one arrow tip from the main path, and another one for the edge, as that is added after the first path.

enter image description here

\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.arrows,arrows}   

\tikzset{block/.style={rectangle, draw, fill=blue!50!black!20, 
text width=2cm, text centered, rounded corners, minimum height=2cm, minimum    width=4cm},
sblock/.style={rectangle, draw, fill=blue!50!black!20, 
text width=2cm, text centered, rounded corners, minimum height=2cm, minimum     width=2cm},
line/.style={draw, -latex'}}

\begin{document}
\begin{tikzpicture}
   \node [block] at (6,3) (C) {C};  
   \node [sblock] at (1,2) (D) {D};   
   \path [thick] (C.west) edge [line,bend left] (D.east);
   \path [thick] (D.east) edge [line,bend left] (C.west);   


   \node [block] at (6,-1) (E) {E};  
   \node [sblock] at (1,-2) (F) {F};   
   \path [line,thick] (E.west) to[out=180,in=60] (F.east);
   \path [line,thick] (F.east) to[out=0,in=240] (E.west);   
\end{tikzpicture}
\end{document}
  • Thank you, works like a charm. What is the difference between edge and to? – JP Janet Jul 8 '15 at 20:05
  • 1
    @JPJanet I had a quick look in the manual and updated my answer a bit. – Torbjørn T. Jul 8 '15 at 21:06
  • thank you for adding this explanation. There is so much going on behind the scenes in Tikz I really battle to make heads or tails of it! – JP Janet Jul 8 '15 at 21:30
  • @JPJanet One more thing: I forgot that you can use to[bend left] as well, which is perhaps easier than using in=X,out=Y. – Torbjørn T. Jul 8 '15 at 22:38

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.