Recently there was a great answer in How to draw a 3D hexagonal structure with TikZ?
But I noticed a small "bug" which I can't seem to be able to fix. I stripped the code down that shows the problem:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}
\begin{scope}[%
every node/.style={anchor=west,regular polygon, regular polygon sides=6,draw,inner sep=0.5cm},
transform shape]
\node (A) {A};
\node (B) at (A.corner 1) {B};
\node (C) at (B.corner 5) {C};
\node (D) at (A.corner 5) {D};
\node (E) at (D.corner 5) {E};
\foreach \hex in {A,...,E}
{
\foreach \corn in {1,...,6}
\draw[fill=white] (\hex.corner \corn) circle (2pt);
}
\end{scope}
\end{tikzpicture}
\end{document}
This code draws five nodes with hexagonal shape, but the hexagons are a few, but always a different "number of few", pixels "off", as shown in this picture:
- Which value is responsible for this?
- Why is the "shifting" happening with different strength?
- How to fix it?