[Tex/LaTex] TikZ block diagram with multiple arrows not from centre of block

tikz-pgf

I'm trying to create a rather simple diagram but I don't know how to get the multiple arrows on the left not leaving the centre of the node.

The block diagram I would like to create

Best Answer

Two options; using anchors and some shifts, and using the <name>.<angle > syntax:

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\node[draw,minimum size=2cm] (x) {X};
\draw[->] ([yshift=-10pt]x.west) -- node[fill=white] {a} +(-1cm,0pt);
\draw[->] ([yshift=10pt]x.west) -- node[fill=white] {b} +(-1cm,0pt);
\draw[->] (x.120) -- node[fill=white] {c} +(0pt,1cm);
\draw[->] (x.60) -- node[fill=white] {d} +(0pt,1cm);
\end{tikzpicture}

\end{document}

enter image description here

As Claudio Fiandrino has mentioned in his comment, another option is to use the calc library, so the shifts are not absolute, but can be calculated in terms of anchors:

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

\begin{document}

\begin{tikzpicture}
\node[draw,minimum size=2cm] (x) {X};
\draw[->] ([yshift=-10pt]x.west) -- node[fill=white] {a} +(-1cm,0pt);
\draw[->] ([yshift=10pt]x.west) -- node[fill=white] {b} +(-1cm,0pt);
\draw[->] (x.120) -- node[fill=white] {c} +(0pt,1cm);
\draw[->] (x.60) -- node[fill=white] {d} +(0pt,1cm);
\draw[->]
  ( $ (x.north east)!0.5!(x.east) $ ) -- 
    node[fill=white] {e} 
  +(1cm,0pt);
\draw[->] 
  ( $ (x.east)!0.5!(x.south east) $ ) -- 
    node[fill=white] {f} 
    +(1cm,0pt);
\end{tikzpicture}

\end{document}

enter image description here

In the above example ( $ (x.north east)!0.5!(x.east) $ ) means the point whose coordinate is halfway between x.north east and x.east.

Related Question