You could use the .<angle>
syntax to manually control the position of the arrows; another option would be to use a matrix of (math) nodes
instead of the array
environment, to get access to the nodes in the matrix. The following example illustrates both these ideas:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,matrix}
\begin{document}
\begin{tikzpicture}[>=stealth]
\node[draw,rectangle,inner sep=0.5cm] (y) at (0,0) {$A$};
\node[draw,rectangle,inner sep=0.3cm] (d) at (0,2) {$\begin{array}{cc}B&\\&C \end{array}$};
\draw[->] (y.west) -| ++(-1,1) |- (d.160);
\draw[->] (y.west) -| ++(-0.8,1) |- (d.190);
\draw[->] (d.-10) -| ++(0.8,-1) |- (y.east);
\draw[->] (d.20) -| ++(1,-1) |- (y.east);
\end{tikzpicture}
\vspace*{10pt}
\begin{tikzpicture}[>=stealth,remember picture]
\node[draw,rectangle,inner sep=0.5cm] (y) at (0,0) {$A$};
\node[draw] (d) at (0,2) {%
\begin{tikzpicture}[remember picture]
\matrix [matrix of math nodes] (mat)
{
B & \phantom{C} \\
\phantom{B} & C \\
};
\end{tikzpicture}
};
\draw[->,shorten >= 6pt] (y.west) -| ++(-1,1) |- (mat-1-1);
\draw[->,shorten >= 6pt] (y.west) -| ++(-0.8,1) |- (mat-2-1);
\draw[->] ($(mat-2-2)+(14pt,0)$) -| ++(0.8,-1) |- (y.east);
\draw[->] ($(mat-1-2)+(14pt,0)$) -| ++(1,-1) |- (y.east);
\end{tikzpicture}
\end{document}
EDIT: a variant on kgr's solution, but using two matrices of nodes:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,matrix,positioning}
\begin{document}
\begin{tikzpicture}[>=stealth]
\matrix[matrix of math nodes,nodes in empty cells,draw] (d) at (0,2)
{
A & & & & \\
& B & & & \\
& & C & & \\
& & & D & \\
& & & & E \\
};
\matrix[matrix of math nodes,nodes in empty cells,draw,minimum width=30pt,below=of d] (y)
{
\\ \\ \\ \\ \\
};
\node at (y) {$D$};
\foreach \i in {1,2,3,4,5}
{
\draw[->] let \p1 = (d.west), \p2 = (d-\i-\i.west), \p3 = (y.west), \p4 = (y-\i-1.west) in (\x3,\y4) -|
++(-2.4+0.2*\i,1) |- (\x1,\y2);
\draw[->] let \p1 = (d.east), \p2 = (d-\i-\i.east), \p3 = (y.east), \p4 = (y-\i-1.east) in (\x1,\y2) -|
++(1.6-0.2*\i,-1) |- (\x3,\y4);
}
\end{tikzpicture}
\end{document}
I don't really get the question so I hope this is what you wanted. If you include a full document (such that we copy paste and see the problem on our systems) things are much more easier.
Here, you can change the default setting within a scope but your block
style had a node distance
which was resetting every time it is issued. I've made it 2mm such that we can see the difference easier.
\documentclass[tikz]{standalone}
\usetikzlibrary{arrows,shapes.geometric,positioning}
\begin{document}
\begin{tikzpicture}[decision/.style={diamond, draw, text width=4.5em, text badly centered, node distance=3.5cm, inner sep=0pt},
block/.style ={rectangle, draw, text width=6em, text centered, rounded corners, minimum height=4em, minimum height=2em},
cloud/.style ={draw, ellipse, minimum height=2em},
line/.style ={draw,-latex'},
node distance = 1cm,
auto]
\node [block] (1st) {1st};
\node [block, right= of 1st] (2nd1) {2nd1};
\begin{scope}[node distance=2mm and 10mm]%Here we change it for everything inside this scope
\node [block, above= of 2nd1] (2nd2) {2nd2};
\node [block, below= of 2nd1] (2nd3) {2nd3};
\node [block, right= of 2nd1] (3rd1) {3rd1};
\node [block, above= of 3rd1] (3rd2) {3rd2};
\node [block, above= of 3rd2] (3rd3) {3rd3};
\end{scope}
\node [block, below= of 3rd1] (3rd4) {3rd4};
\node [block, below= of 3rd4] (3rd5) {3rd5};
\path [line] (1st) -- (2nd1);
\path [line] (2nd1) -- (2nd2);
\path [line] (2nd1) -- (2nd3);
\path [line] (2nd2) -- (3rd3);
\path [line] (2nd1) -- (3rd1);
\path [line] (1st) -- (2nd1);
\end{tikzpicture}
\end{document}
Best Answer
This is quite straight forward in the sense that you can use
calc
library oftikz
and access the points between two points with any ratio. For example,($(foo.north east)!0.25!(foo.south east)$)
is the point that is 25% away fromfoo.north east
on the line connectingfoo.north east
andfoo.south east
. Hence we could useFull code will be
Adding to this you can also use a
\foreach
loop to draw the lines and reduce the code lines.