I have created a pic
of a simple polygon which I want to use and reuse to create tikzpictures
containing copies of it positioned relative to each other. How do I do that?
If I did not have the pic
, I would use the positioning
library and position relative to the polygon's corners. Can I do something similar here with a pic?
The expected result is something more elegant and reproducible than this. Thanks.
\documentclass[class=article,border=5pt,tikz]{standalone}
\usetikzlibrary{shapes.geometric}
\tikzset{fig/.pic={code={%
\begin{scope}
\node[regular polygon,regular polygon sides=6,draw,minimum width=3cm]
(hexagon){};
\foreach \x [evaluate=\x] in {1,...,6}
{\node[draw,shape=circle,fill=white,opacity=1,minimum size=6mm] at (hexagon.corner \x){}; }
\end{scope}
}}}%
\begin{document}
\begin{tikzpicture}[thick,x=1cm,y=1cm]
\path (0,0) pic {fig};
\path (2.265,1.305) pic {fig}; # inelegant + imprecise!
\path (4.53,0) pic {fig};
\path (2.265,-1.305) pic {fig};
\end{tikzpicture}
\end{document}