TikZ: difference between \node and \coordinate?
\node
requires a caption:
\node (name) at (coordinate) {caption};
\coordinate
does not use a caption:
\coordinate (name) at (coordinate);
\node
can also have a shape and dimension, \coordinate
is just a point
Well, perhaps it's interesting to look at the pgfmanual :
\coordinate
is a shortcut for\path ... coordinate[⟨options⟩](⟨name⟩)at(⟨coordinate⟩) ...;
and it's the same that
node[shape=coordinate][]⟨options ⟩](⟨name ⟩)at(⟨coordinate ⟩){},
where theat part
might be missing.Since nodes are often the only path operation on paths, there are two special commands for creating paths containing only a node:
\node
Inside{tikzpicture}
this is an abbreviation for\path node
.\coordinate
Inside{tikzpicture}
this is an abbreviation for\path coordinate
.pgf and TikZ define three shapes, by default:
- rectangle,
- circle, and
- coordinate.
The coordinate shape is handled in a special way by TikZ. When a node x whose shape is coordinate is used as a coordinate (x), this has the same effect as if you had said (x.center). None of the special “line shortening rules” apply in this case. This can be useful ...
finally
The exact behaviour of shapes differs, shapes defined for more special purposes (like a, say, transistor shape) will have even more custom behaviors. However, there are some options that apply to most shapes.
It's why some default values like inner sep
are different.
node
introduces an inner sep
and hence does not produce a geometrical point in true sense. coordinate
or \node [coordinate]
on the other hand, does not have inner sep
.
\documentclass{article}
\usepackage{tikz}
\begin{document}
\verb|\node| introduces an \verb|inner sep|:
\begin{tikzpicture}
\coordinate (cone) at (0,0);
\node (none) at (4,0) {};
\draw[->] (cone) -- (none);
\draw[draw,red,->] (none) -- (0:5);
\end{tikzpicture}
\verb|\node[coordinate]| or \verb|\coordinate| does not introduce an \verb|inner sep|:
\begin{tikzpicture}
\coordinate (cone) at (0,0);
\node[coordinate] (none) at (4,0) {}; %% or \coordinate (none) at (4,0);
\draw[->] (cone) -- (none);
\draw[draw,red,->] (none) -- (0:5);
\end{tikzpicture}
If you use \verb|\node|, you may be forced to use \verb|none.center| to get rid of the gap noticed between the two lines:
\begin{tikzpicture}
\coordinate (cone) at (0,0);
\node (none) at (4,0) {};
\draw[->] (cone) -- (none.center);
\draw[draw,red,->] (none.center) -- (0:5);
\end{tikzpicture}
Hence, when you need a geometric point, use \verb|\node[coordinate]| or \verb|\coordinate|.
\end{document}
Bottom line: When you need a point use coordinate
.