Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

up vote 11 down vote accepted

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.

share|improve this answer
    
What about the calc library? –  Claudio Fiandrino Mar 18 at 13:39
1  
@ClaudioFiandrino I wanted to show some options without libraries, but perhaps it's worth also mentioning calc. Do you mean to use calc to calculate the shifts? –  Gonzalo Medina Mar 18 at 13:42
2  
Yes, for example \draw[->]($(x.north west)!0.5!(x.west)$)-- node[fill=white] {b} +(-1cm,0pt); and \draw[->] ($(x.west)!0.5!(x.south west)$) -- node[fill=white] {a} +(-1cm,0pt);. –  Claudio Fiandrino Mar 18 at 13:47
    
@ClaudioFiandrino I added some example with your suggestion. Thanks. –  Gonzalo Medina Mar 18 at 13:52
    
@GonzaloMedina Many thanks for that quick and detailed answer! –  Jan Mar 18 at 16:11

A PSTricks solution:

\documentclass{article}

\usepackage{pstricks-add}
\usepackage{expl3}
\ExplSyntaxOn
  \cs_new_eq:NN \calc \fp_eval:n
\ExplSyntaxOff
\newcommand*\Width{\calc{2*\arrowLength+\boxLength}}
\newcommand*\Height{\boxLength}

\def\arrowLength{3 }
\def\boxLength{3 }


\begin{document}

\begin{pspicture}(\Width,\Height)
 \psset{arrows = ->}
  \psframe(\arrowLength,0)(!\arrowLength \boxLength add \boxLength)
  \rput(!\arrowLength \boxLength 2 div add \boxLength 2 div){X}
  \pcline(!\arrowLength \boxLength 3 div)(!0 \boxLength 3 div)
  \ncput*{a}
  \pcline(!\arrowLength 2 \boxLength mul 3 div)(!0 2 \boxLength mul 3 div)
  \ncput*{b}
  \pcline(!2 \arrowLength mul \boxLength add \boxLength 2 div)(!\arrowLength \boxLength add \boxLength 2 div)
  \ncput*{c}
\end{pspicture}

\end{document}

output

Note that the drawing is 'automated' and all you have to do is choose the values of \arrowLength and \boxLength.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.