3

I try to start an arrow from the center of a split rectangle. A tip here suggested that I should compute the center myself. I tried doing so, but it is still no good. Why does it have to be so difficult?

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows,calc,positioning,shapes.multipart}
\begin{document}\begin{tikzpicture}
      \node[draw,circle] (a) {a};
      \node[draw,circle, right=of a] (b) {b};
      \node[draw,
        rectangle split, 
        rectangle split parts=2, 
        rectangle split horizontal,above=of b] (c) {};
\coordinate (c1) at ($(c.west)!.5!(c.one split)$);
\coordinate (c2) at ($(c.one split)!.5!(c.east)$);
\draw[*->,>= stealth] (c1)--(a.north);
\draw[*->,>= stealth] (c2)--(b.east);
\end{tikzpicture}\end{document}

the rendered version of the above document

Yossi Gil
  • 15,951
  • 1
    Could you just draw the circles separately, then? If you draw a circle doesn't the centre go at the coordinates you specify? – cfr Jan 02 '14 at 16:47
  • 2
    If you remove the * arrow tip, you get the expected behavior. The problem is that the * arrow tip is not centered at the end point, instead its edge is at the end point. This answers to this question http://tex.stackexchange.com/questions/11871/modifying-and-o-style-tikz-arrows-so-that-they-are-centered-at-the-end-of might help, especially http://tex.stackexchange.com/a/115268/27666, which defines a new arrow style with centered endpoint – Chris Chudzicki Jan 02 '14 at 16:52
  • 1
    @cfr Yes, \draw[->,>= stealth,fill=black] (c2) circle (1pt) (c2)--(b.east); would work, but it's probably better to define a new arrow style with centered endpoint if you're going to do this a lot. – Chris Chudzicki Jan 02 '14 at 16:54

0 Answers0