\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning, calc}
\begin{document}
%define length of square
\def\length{5}
%define offset of squares
\def\offset{10mm}
%define square-layout
\newcommand{\TwoQuad}[1]{
\begin{tikzpicture}
\node (rectangle) at (0,0) {
\tikz \draw (0,0) rectangle (\length,\length);
};
\node (line) at (rectangle.center) {\tikz \draw[red] (0,-\length/2) -- (0,\length/2);};
\node (text) at (rectangle.north) {#1};
\end{tikzpicture}
}
\begin{tikzpicture}
\node (first) at (0,0) {\TwoQuad{First}};
\node (second) [right=\offset of first]{\TwoQuad{Second}};
\node (third) [below=\offset of first] {\TwoQuad{Third}};
\node (fourth) [right=\offset of third]{\TwoQuad{Fourth}};
\end{tikzpicture}
\end{document}
Hi,
I'm having an issue with the relative positioning of tikz nodes together with a macro, where some other nodes are created. The red line and the heading are changing their relative positions when using the below = ... of
or similar syntax. I don't know why the result is not everywhere the same. Any ideas how to fix this?
P.s. The result should look everywhere like "First" (Red line and Headline centered). "Second" should be on the same height at the right, "Third" below "First" and "Fourth" below "Second".
Thanks
Nico