Block Diagrams Multi Input - Multi Output Components in TikZ
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'm not perfectly clear on what you want, but here is a first pass, using tikz matrices:
\documentclass[11pt]{memoir}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}[>=stealth]
\node[draw,rectangle,inner sep=0.5cm] (y) at (0,0) {$A$};
\matrix[matrix of nodes,nodes in empty cells,rectangle,draw] (d) at (0,2)
{
$B$ & \\
& $C$ \\
};
\draw[->] let \p1 = (d.west), \p2=(d-1-1.west) in (y.west) -| ++(-1,1) |- (\x1,\y2);
\draw[->] let \p1 = (d.west), \p2=(d-2-2.west) in (y.west) -| ++(-0.8,1) |- (\x1,\y2);
\draw[->] let \p1 = (d.east), \p2=(d-2-2.east) in (\x1,\y2) -| ++(0.8,-1) |- (y.east);
\draw[->] let \p1 = (d.east), \p2=(d-1-1.east) in (\x1,\y2) -| ++(1,-1) |- (y.east);
\end{tikzpicture}
\end{document}
The line drawing could probably be simplified quite a bit by writing some macros.
For getting the lines to start/end in the right place, there is also an even simpler syntax for the line drawing you could use, that I didn't do above because it is slightly less transparent. Instead of e.g. the first draw line above, you could do:
\draw[->] (y.west) -| ++(-1,1) |- (d.west |- d-1-1.west);
and so on.
(Edited this a bit to match Gonzalo Medina's interpretation of the request, which seems more correct than mine initially was.)
Ok, and one more edit:
Just for fun I made something a little more interesting.
\documentclass[11pt]{memoir}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}[>=stealth]
\node[draw,rectangle,inner sep=0.5cm] (y) at (0,0) {$A$};
\matrix[matrix of nodes,nodes in empty cells,rectangle,draw] (d) at (0,3)
{
$B$ & & & &\\
& $C$ & & & \\
& & $D$ & & \\
& & & $E$ & \\
& & & & $F$ \\
};
\foreach \z in {1,...,5}
{
\draw[->] let \n1={\z * -0.2cm - 0.5cm} in
(y.west) -| ([xshift=\n1] d.west |- y.west) |- (d.west |- d-\z-\z.west);
\draw[->] let \n1={\z * 0.2cm + 0.5cm} in
(d.east |- d-\z-\z.east) -| ([xshift=\n1] d.east |- y.east) |- (y.east);
}
\end{tikzpicture}
\end{document}