4

How can I center the dot in the first part of box? I want to make it look symmetrical. But don't know why the dot and arrow just won't center in the first part of box like the third part of box.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,shapes.multipart,chains,arrows.meta}

\begin{document}
\begin{tikzpicture}[
   list/.style={minimum size=9mm,
   rectangle split,
   rectangle split parts=3,
   draw,
   rectangle split horizontal
},
   dotarrow/.style={Circle-Stealth},
   start chain
   ]
   \node[list,on chain] (A) {};
   \node[left of=A,xshift=-3mm] (1) {};
   \node[right of=A,xshift=3mm] (2) {};

   \draw[dotarrow] (A.three |- A.center) -- (2);
   \draw[dotarrow] (A.one |- A.center) -- (1);

 \end{tikzpicture}
 \end{document}

enter image description here

8
  • Your code is not compilable. It brings many errors. Please make it compilable. Starting with \documentclass{...} and ending with \end{document}.
    – Cragfelt
    Nov 19, 2017 at 5:45
  • Well, this piece of code should be able to display in any document type....What do you mean by not compilable?? Nov 19, 2017 at 5:50
  • You are missing all the necessary libraries. But the answer is that the circle arrow head is put next to the point not on the point. So it is a visual problem.
    – percusse
    Nov 19, 2017 at 5:54
  • To be honest, I pulled this off from a document that a group of people are working on......I'm in the group of course......There are at least 500 lines of preamble, and at least 1000 pages of codes already......You ask me which library is for this?? My guess is just tikz.....let me try to find out .... Nov 19, 2017 at 6:03
  • @Cragfelt Ok....I just edit the code, now should be ok......could you please help me now??? Nov 19, 2017 at 6:12

1 Answer 1

4

There's two problems. One is that as Percusse points out, the circle at the beginning of the dotarrow doesn't go exactly at the coordinate given. The second problem is that the A.one and A.three anchors appear to be in slightly odd locations. The easy solution to the first problem is to put a node with shape a filled circle at the end of your arrow. A harder solution would be to make a modified version of the dot arrowhead with no offset. It seems like the easy solution is sufficient here.

To solve the second problem, it appears that the anchor A.one south is located at the center of the bottom edge of the region. So to get the two edges say:

\tikzset{dot/.style={circle,fill, inner sep=1.3pt}}
\draw (A.three south |- A.center) node[dot]{} -- (2);
\draw (A.one south |- A.center) node[dot]{} -- (1);

The complete example:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,shapes.multipart,chains,arrows.meta}

\begin{document}
\begin{tikzpicture}[
   list/.style={minimum size=9mm,
   rectangle split,
   rectangle split parts=3,
   draw,
   rectangle split horizontal
},
   dot/.style={circle,fill, inner sep=1.3pt},
   -Stealth,
   start chain
   ]
   \node[list,on chain] (A) {};
   \node[left of=A,xshift=-3mm] (1) {};
   \node[right of=A,xshift=3mm] (2) {};

   \draw (A.three south |- A.center) node[dot]{} -- (2);
   \draw (A.one south |- A.center) node[dot]{} -- (1);
 \end{tikzpicture}
 \end{document} 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .