# how do I make tikz circular arrowheads concentric to the point they connect?

I have a box-and-pointer diagram but it looks wrong, because the circular arrowheads are tangential to the point it connects, rather than concentric to that point.

How can I fix this?

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows}
%%%<
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%
%%%>
\title{immutable list}
\begin{document}
\begin{tikzpicture}
\tikzstyle{square} = [draw, shape=rectangle, minimum height=1cm, minimum width=1cm, node distance=2cm, line width=1pt]
\node[square] (1a) at (0,0)     {};
\node[square] (1b) at (1cm,0)   {};

\node[square] (2a) at (3cm,0)   {};
\node[square] (2b) at (4cm,0)   {};

\node[square] (3a) at (6cm,0)   {};
\node[square] (3b) at (7cm,0)   {};

\node[square] (4a) at (9cm,0)   {};
\node[square] (4b) at (10cm,0)  {};

\node (1) at (0,-2) {1};
\node (2) at (3,-2) {2};
\node (3) at (6,-2) {3};
\node (4) at (9,-2) {4};

\draw [*-latex] (1b.center) -- (2a);
\draw [*-latex] (2b.center) -- (3a);
\draw [*-latex] (3b.center) -- (4a);
\draw (4b.north east) -- (4b.south west);

\draw [*-latex] (1a.center) -- (1);
\draw [*-latex] (2a.center) -- (2);
\draw [*-latex] (3a.center) -- (3);
\draw [*-latex] (4a.center) -- (4);

\end{tikzpicture}
\end{document}

• Wouldn't it be easier to just draw a small circle which will automatically be centred on the appropriate spot? – cfr Sep 14 '14 at 0:35
• Do you mean to say the black circles are not centered within the square? – user11232 Sep 14 '14 at 0:41
• Correct, the black circles are not centered; instead, they are, like normal arrowheads, placed to be tangent to their endpoint. – Jason S Sep 14 '14 at 0:49
• – Ignasi Sep 17 '14 at 7:41
• The image in the question is no longer available. Can you fix it? – 200_success Jan 5 '15 at 10:28

Getting the required effect is pretty easy using the "old-style" arrows:

\documentclass[tikz,border=5]{standalone}
\pgfarrowsdeclare{dot}{dot}
{
\pgfarrowsleftextend{0pt}
\pgfarrowsrightextend{0pt}
}
{
\pgfpathcircle{\pgfqpoint{0pt}{0pt}}{2pt}
\pgfusepathqfill
}
\begin{document}
\begin{tikzpicture}
\draw [help lines] (0,0) grid (3,2);
\draw [dot-stealth, red]  (0,0) -- (3,2);
\end{tikzpicture}
\end{document}


...But it is much easier with the arrows.meta library:

\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{arrows.meta}
\pgfarrowsdeclare{dot}{dot}
{
\pgfarrowsleftextend{0pt}
\pgfarrowsrightextend{0pt}
}
{
\pgfpathcircle{\pgfqpoint{0pt}{0pt}}{2pt}
\pgfusepathqfill
}
\tikzset{Dot/.tip={Circle[length=4pt,sep=-2pt]}}
\begin{document}
\begin{tikzpicture}
\draw [help lines] (0,0) grid (3,2);
\draw [dot-stealth, red]  (0,0) -- (3,2);
\draw [Dot-Stealth, blue] (0,2) -- (3,0);
\end{tikzpicture}
\end{document}


• oh, I like it, but writelatex.com doesn't provide arrows.meta. :-( – Jason S Sep 14 '14 at 17:11
• @JasonS arrows.meta is only required for the Dot and Stealth arrows. The old-style arrow definition is fine doesn't require this. I've updated the answer to make things a bit clearer. – Mark Wibrow Sep 14 '14 at 17:36

If you draw circles at those points, they will centre on the point by default which may be easier than trying to adjust the arrow length:

\documentclass[tikz, border=5pt]{standalone}
\usetikzlibrary{arrows}

\begin{document}
\begin{tikzpicture}
[
square/.style = {draw, shape=rectangle, minimum height=1cm, minimum width=1cm, node distance=2cm, line width=1pt},
]
\node[square] (1a) at (0,0)     {};
\node[square] (1b) at (1cm,0)   {};

\node[square] (2a) at (3cm,0)   {};
\node[square] (2b) at (4cm,0)   {};

\node[square] (3a) at (6cm,0)   {};
\node[square] (3b) at (7cm,0)   {};

\node[square] (4a) at (9cm,0)   {};
\node[square] (4b) at (10cm,0)  {};

\node (1) at (0,-2) {1};
\node (2) at (3,-2) {2};
\node (3) at (6,-2) {3};
\node (4) at (9,-2) {4};

\foreach \i / \j in {1b/2a,2b/3a,3b/4a,1a/1,2a/2,3a/3,4a/4}
{
\draw [-latex] (\i.center) -- (\j);
\path [fill] (\i.center) circle (1.5pt);
}

\draw (4b.north east) -- (4b.south west);

\end{tikzpicture}
\end{document}


Alternatively, you could shorten the start point of the arrow by the radius of the circle. Roughly:

\documentclass[tikz, border=5pt]{standalone}
\usetikzlibrary{arrows}

\begin{document}
\begin{tikzpicture}
[
square/.style = {draw, shape=rectangle, minimum height=1cm, minimum width=1cm, node distance=2cm, line width=1pt},
]
\node[square] (1a) at (0,0)     {};
\node[square] (1b) at (1cm,0)   {};

\node[square] (2a) at (3cm,0)   {};
\node[square] (2b) at (4cm,0)   {};

\node[square] (3a) at (6cm,0)   {};
\node[square] (3b) at (7cm,0)   {};

\node[square] (4a) at (9cm,0)   {};
\node[square] (4b) at (10cm,0)  {};

\node (1) at (0,-2) {1};
\node (2) at (3,-2) {2};
\node (3) at (6,-2) {3};
\node (4) at (9,-2) {4};

\foreach \i / \j in {1b/2a,2b/3a,3b/4a,1a/1,2a/2,3a/3,4a/4}
{
\draw [*-latex, shorten <=-2pt] (\i.center) -- (\j);
}

\draw (4b.north east) -- (4b.south west);

\end{tikzpicture}
\end{document}


But the adjustment would need to be tweaked to get this exactly right.

For example:

\documentclass[tikz, border=5pt]{standalone}
\usetikzlibrary{arrows.meta}

\begin{document}
\begin{tikzpicture}
[
square/.style = {draw, shape=rectangle, minimum height=1cm, minimum width=1cm, node distance=2cm, line width=1pt},
]
\node[square] (1a) at (0,0)     {};
\node[square] (1b) at (1cm,0)   {};

\node[square] (2a) at (3cm,0)   {};
\node[square] (2b) at (4cm,0)   {};

\node[square] (3a) at (6cm,0)   {};
\node[square] (3b) at (7cm,0)   {};

\node[square] (4a) at (9cm,0)   {};
\node[square] (4b) at (10cm,0)  {};

\node (1) at (0,-2) {1};
\node (2) at (3,-2) {2};
\node (3) at (6,-2) {3};
\node (4) at (9,-2) {4};

\foreach \i / \j in {1b/2a,2b/3a,3b/4a,1a/1,2a/2,3a/3,4a/4}
{
\draw [{Circle[length=4pt]}-latex, shorten <=-2pt] (\i.center) -- (\j);
}

\draw (4b.north east) -- (4b.south west);

\end{tikzpicture}
\end{document}


will give you circles with radius of 2pt (diameter 4pt) which will be centred if you shorten the arrow by 2pt.

• I like that second suggestion. How do I choose the circle size in these arrowheads? I would like to adjust them anyway. – Jason S Sep 14 '14 at 0:50
• @JasonS I would look at arrows.meta in the TiKZ manual for the options. I don't know how to adjust them for the arrows library. (I've not yet figured out how the two relate to each other and started with arrows.meta have just learnt that one.) Hang on. – cfr Sep 14 '14 at 0:53
• writelatex.com doesn't seem to support arrows.meta, just the plain arrows library. – Jason S Sep 14 '14 at 0:54
• @JasonS Hmmm. Maybe they are using an older version of TiKZ? That's a shame as 3.0.0 introduces a lot of useful features. I'm afraid my TiKZ manual doesn't cover the old arrows library as far as I can tell. – cfr Sep 14 '14 at 1:04
• screw it, i'm designing my own arrowhead :-( stuff.mit.edu/afs/athena/contrib/tex-contrib/beamer/pgf-1.01/… – Jason S Sep 14 '14 at 1:16