I have a problem using relative positioning in TikZ. As shown in the MWE below, my "vertex circles" are not placed correctly when putting two figures side by side using \node[right = of ...] syntax.
Code using "right = of ..." syntax:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\tikzset{
vertex/.style={circle,fill=black,minimum size=.8mm,inner sep=0pt}
}
\begin{document}
\begin{tikzpicture}
\node (2nd_1) at (0,0) {
\tikz{
\coordinate (u1) at (0,0);
\coordinate[below= of u1] (l1);
\coordinate[right= of u1] (u2);
\coordinate[right= of l1] (l2);
%
\draw (u1) -- (l1);
\draw (u2) -- (l2);
\draw (l1) -- (l2);
\draw (l1) node[vertex]{};
\draw (l2) node[vertex]{};
}
};
\node[right=0 of 2nd_1] (2nd_2) {
\tikz{
\coordinate (u1) at (0,0);
\coordinate[below= of u1] (l1);
\coordinate[right= of u1] (u2);
\coordinate[right= of l1] (l2);
%
\draw (u1) -- (l1);
\draw (u2) -- (l2);
\draw (l1) -- (l2);
\draw (l1) node[vertex]{};
\draw (l2) node[vertex]{};
}
};
\end{tikzpicture}
\end{document}
Code setting the position manually:
\begin{tikzpicture}
\node (2nd_1) at (0,0) {
\tikz{
\coordinate (u1) at (0,0);
\coordinate[below= of u1] (l1);
\coordinate[right= of u1] (u2);
\coordinate[right= of l1] (l2);
%
\draw (u1) -- (l1);
\draw (u2) -- (l2);
\draw (l1) -- (l2);
\draw (l1) node[vertex]{};
\draw (l2) node[vertex]{};
}
};
\node (2nd_2) at (1.5,0) {
\tikz{
\coordinate (u1) at (0,0);
\coordinate[below= of u1] (l1);
\coordinate[right= of u1] (u2);
\coordinate[right= of l1] (l2);
%
\draw (u1) -- (l1);
\draw (u2) -- (l2);
\draw (l1) -- (l2);
\draw (l1) node[vertex]{};
\draw (l2) node[vertex]{};
}
};
\end{tikzpicture}
Left: using "right = of" syntax. Right: Manual position
As is evident from the picture, the vertex-circles are not placed correctly on the second figure to the left. I can't seem to figure out, where the error originates so any help/explanation is appreciated.