2

Consider this example:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{arrows}

\begin{document}
\begin{tikzpicture}
\fill [orange] (0.1,0.1) rectangle (12,8);
  \node[text opacity = 0] (1) at (4,8) {C3};
  \node (2) [below left of = 1] {B2};
  \node (3) at (4,2) {C3};
  \node (4) [below right of = 1] {D4};
  % connect the dots
  \path[->,>=stealth]
  (1) edge [bend right=20]  (2)
  (2) edge [bend right=20]  (3)
  (3) edge [bend right=20]  (4)
  (4) edge [bend right=20]  (1);

\draw[->,>=stealth](5,2) -- (5,4);
\draw[->,>=stealth](3,4) -- (3,2);

\end{tikzpicture}
\end{document}

enter image description here

I have a couple of questions:

Firstly, why is it that when I specify the locations of C3, B2 and D4 do not move automatically i.e. I would hope that B2 and D4 would move to be half way between nodes (1) and (4)? How can I fix this? I know that I can simply specify 'below' for all of them but this makes the diagram too small so I was hoping of specifying the top and bottom coordinate and then have use 'bottom' to do the rest, but obviously this doesn't work.

Secondly, how can I alter the diagram so that the two arrows in the bottom of the diagram to blend into the main cycle i.e. showing that the arrows are either coming out or going into the main process?

KatyB
  • 2,871
  • The node (3) (C3) is not in any relation with the other nodes why should other nodes depend on it? By the way, the keys … of= are deprecated: Difference between "right of=" and "right=of" in PGF/TikZ — Can you show us a sketch of how your diagram should look like? – Qrrbrbirlbel Sep 08 '13 at 11:19
  • The > key is best used on a scope enclosing paths that should use a common arrow tip, otherwise one could just write -stealth instead of ->, >=stealth. In this case, simply use \begin{tikzpicture}[>=stealth] and you can then use -> and <- on the paths. – Qrrbrbirlbel Sep 08 '13 at 13:30

1 Answers1

3

You are not using the positioning library to its best. The syntax is below left = of 1. The below left of = 1 is deprecated. Further you can control the distance by below left = 2cm and 2cm of 1 where the distance can be tweaked at will. You have to load positioning library.

Full code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{arrows,positioning,intersections}

\begin{document}
\begin{tikzpicture}
\fill [orange] (0.1,0.1) rectangle (12,8);
  \node[text opacity = 0] (1) at (4,8) {C3};
  \node (2) [below left = 2cm and 2cm of 1] {B2};
  \node (3) [below right = 2cm and 2cm of  2] {C3};
  \node (4) [below right = 2cm and 2cm of  1] {D4};
  % connect the dots
  \path[->,>=stealth]
  (1) edge [bend right=20]  (2)
  (2) edge [bend right=20]  node[pos=.8,inner sep=0pt,outer sep=0pt] (A) {}  (3) 
  (3) edge [bend right=20]  node[pos=.2,inner sep=0pt,outer sep=0pt] (B) {} (4)
  (4) edge [bend right=20]  (1);

\draw[->,>=stealth](B) to [out=30,in=180] +(2,.5);
\draw[<-,>=stealth](A) to [out=150,in=0] +(-2,.5);

\end{tikzpicture}
\end{document}

enter image description here

Here the position of node 1 is fixed absolutely while all other nodes are relative to it. You can feel free to tweak the distances to your needs. One such tweak will be

\draw[<-,>=stealth](B) to [out=220,in=90] +(-1.5,-2);
\draw[->,>=stealth](A) to [out=310,in=90] +(1.5,-2);

with all [bend right=40].

enter image description here

  • Thats great, and what about the two arrows at the bottom of the diagram, is there a way of making them merge into the main cycle? So, have the right hand arrow join the line connecting C3 and D4, and have the left hand arrow to join the line connecting B2 and C3? – KatyB Sep 08 '13 at 12:03
  • @Kate See the edited answer. –  Sep 08 '13 at 12:52
  • Instead of specifying 2cm and 2cm at every occurrence of an …=of … key, use node distance=2cm and 2cm. I also would use a coordinate instead of a node which size is minimized. – Qrrbrbirlbel Sep 08 '13 at 13:32
  • @Qrrbrbirlbel Your are right. They are my thoughts too. :) I like giving extreme answers though. –  Sep 08 '13 at 14:07