# Box with incoming and outgoing arrows

I am trying to make figure using TikZ but couldn't seem to achieve the desired result.
I need to make a box with some incoming arrows and some with outgoing arrows.

My minimal example

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}
\pagestyle{empty}
%
\tikzstyle{int}=[draw, fill=blue!20, minimum size=7em]
\tikzstyle{init} = [pin edge={to-,thin,black}]

\begin{tikzpicture}[node distance=2.5cm,auto,>=latex']
\node [int] (a) {$U$ \vspace{1cm} evolution operator};
\node (b) [left of=a,node distance=3cm, coordinate] {a1};
\node (c) [right of=a,node distance=3cm, coordinate] {b1};
\node (d) [left of=a,node distance=3cm, coordinate] {a2};
\node (e) [right of=a,node distance=3cm, coordinate] {b2};
\path[->] (b) edge node {$a1$} (a);
\path[<-] (c) edge node {$b1$} (a);
\path[->] (d) edge node {$a2$} (a);
\path[<-] (e) edge node {$b2$} (a);
\end{tikzpicture}

\end{document}


The problem I have encountered is that I thought a1 and a2 will be the separated by some vertical distance but they got merged, similarly b1 and b2.

Is there a way I can separate them, and make a figure with a1, a2, a3 incoming arrows and b1, b2 and b3 with outgoing arrows

• I'm not sure exactly how you want it to look, but you appear to be drawing arrows between the same points. That is, nodes(b) and (d) are at the same location as are nodes (c) and (e). If you want the arrows (and the labels) to be in different locations, then you need to change the start and end nodes. – TH. Jun 8 '17 at 20:36
• @TH. Ya I am missing that. How can I do that? – Shamina Jun 8 '17 at 20:50
• Shamina, AboAmmar provided a good answer for one way to do that. – TH. Jun 9 '17 at 0:43

If you only change the last four lines so that the arrows start relative to a.west and a.east, you can achieve want you want.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning}
\begin{document}
\pagestyle{empty}
%
\tikzstyle{int}=[draw, fill=blue!20, minimum size=7em]
\tikzstyle{init} = [pin edge={to-,thin,black}]

\begin{tikzpicture}[node distance=2.5cm,auto,>=latex']
\node [int,align=center] (a) {$U$\\evolution operator};
\draw[<-] ([yshift=5pt]a.west)  -- node[above]{$a1$} ++(-4em,0em);
\draw[<-] ([yshift=-5pt]a.west) -- node[below]{$a2$} ++(-4em,0em);
\draw[->] ([yshift=5pt]a.east)  -- node[above]{$b1$} ++(4em,0em);
\draw[->] ([yshift=-5pt]a.east) -- node[below]{$b2$} ++(4em,0em);
\end{tikzpicture}

\end{document}


This solved the problem, after working around I got the solution. Thanks to you all people

\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node [draw,minimum height=3cm] (a) {$U$ \vspace{1cm} evolution operator};
\path (a.south east) -- (a.north east)
coordinate [pos=0.2] (p1)
coordinate [pos=0.5] (p2)
coordinate [pos=0.8] (p3);
\path (a.south west) -- (a.north west)
coordinate [pos=0.2] (p4)
coordinate [pos=0.5] (p5)
coordinate [pos=0.8] (p6);
\draw [->] (p1) -- +(1cm,0) node[right]{$b_1$};
\draw [->] (p2) -- +(1cm,0) node[right]{$b_2$};
\draw [->] (p3) -- +(1cm,0) node[right]{$b_3$};
\draw [<-] (p4) -- +(-1cm,0) node[left]{$a_1$};
\draw [<-] (p5) -- +(-1cm,0) node[left]{$a_2$};
\draw [<-] (p6) -- +(-1cm,0) node[left]{$a_3$};
\end{tikzpicture}
\end{document}