# tikzpicture coordinate unit

\documentclass[12pt]{report}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\begin{tikzpicture}[x=1cm, y=1cm]
\draw [help lines] (0, 0) grid (6, 1);

\node (A) at (0, 0) {A};
\node[right = 2 of A] (B) {B};
\node[right = 2 of B] (C) {C};

\draw[->, thick] (A.east) -- (B.west);
\draw[->, thick] (B.east) -- (C.west);

\end{tikzpicture}

\end{document}


I'm positioning my nodes within tikzpicture using library positioning. Running the code above, I hope to draw A, B, C at (0, 0), (2, 0), (4, 0).

But instead I got A at (0, 0), B at (2.6, 0), C at (5.2, 0):

Looks like the coordinate units of help lines and nodes don't match. How do I fix this?

By default, distance with positioning library is measured between node's borders. You can change it to be a distance between node's centers with on grid option.

In your code I've applied to the complete tikzpicture, but it can be applied to a certain scope or only on some nodes.

\documentclass[12pt]{report}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\begin{tikzpicture}[x=1cm, y=1cm, on grid]
\draw [help lines] (0, 0) grid (6, 1);

\node (A) at (0, 0) {A};
\node[right = 2 of A] (B) {B};
\node[right = 2 of B] (C) {C};

\draw[->, thick] (A.east) -- (B.west);
\draw[->, thick] (B.east) -- (C.west);

\end{tikzpicture}

\end{document}