# [Tex/LaTex] TikZ: What affects the space between nodes placed with below of= syntax

tikz-pgf

How does TikZ decide how much space to put between these two nodes:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\node (a) {A};
\node [below of=a] (b) {B};
\draw (a.north west) rectangle (a.south east);
\draw (b.north west) rectangle (b.south east);
\end{tikzpicture}
\end{document}


And how can I change it? I've added some rectangles to illustrate the extent of the nodes.

I can, of course, have more control as follows:

\begin{tikzpicture}
\node (a) {A};
\node at (a.south) [anchor=north] (b) {B};
\draw (a.north west) rectangle (a.south east);
\draw (b.north west) rectangle (b.south east);
\end{tikzpicture}


And then just add whatever space I want to (a.south) but this is less semantic and much more fiddly.

There must be a way to globally change the space between nodes placed with the positioning library…

To clarify, I'd ideally like to specify the separation between node rather than the distance between node centres. This is because I have nodes of varying y-height and I'd like to have them have a uniform distance between them.

You are loading the positioning library but then use below of=..., however the library provides the syntax below=<optional length> of ..., while below of is already provided by the TikZ core.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\node (a) {A};
\node [below=1cm of a] (b) {B};
\draw (a.north west) rectangle (a.south east);
\draw (b.north west) rectangle (b.south east);
\end{tikzpicture}
\end{document}