Draw 4 of the same figure in the same tikzpicture

Normally the recommendation is to use pics but here you can just use a slightly extended standard node.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric,calc}
\tikzset{repeating shape/.style={regular polygon,regular polygon sides=#1,alias=curr,draw,append after command={
    [draw,] foreach \XX [remember=\XX as \YY (initially #1)] 
    in {1,...,#1} {
    (curr.corner \XX) -- (curr.center) -- ($(curr.corner \YY)!0.5!(curr.corner
    \XX)$)}}}}

\begin{document}
\begin{figure}
\begin{tikzpicture}[scale=2]
  \draw[fill=gray] foreach \X in {0,2.2} { foreach \Y in {0,2.2}
  {(\X,\Y) node[repeating shape=6,minimum size=3cm]{} }};
\end{tikzpicture}
\end{figure}
\end{document}

enter image description here


No one prevents you from pic, with as many options as possible.

\documentclass[tikz]{standalone}
\usetikzlibrary{shapes.geometric}
\newdimen\R
\R=0.8cm
\tikzset{
  pics/hexagon/.style args={#1 and #2}{
    code={
      \node[regular polygon,regular polygon sides=6,minimum size=2*\R] (x) {};
      \coordinate (x.corner 0) at (x.corner 6);
      \foreach \i in {0,...,5} {
        \fill[#1] (x.center) -- (x.{\i*60}) -- (x.{\i*60+30});
        \fill[#2] (x.center) -- (x.{\i*60-30}) -- (x.{\i*60});
      }
    }
  }
}
\begin{document}
\begin{tikzpicture}
\pic at (-1,-1) {hexagon=gray and black};
\pic at (-1, 1) {hexagon=gray and black};
\pic at ( 1,-1) {hexagon=gray and black};
\pic at ( 1, 1) {hexagon=gray and black};
\end{tikzpicture}
\end{document}

enter image description here


Here is a simple way!

\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}
\def\a{2}
\def\subpic{
\fill[gray] (0:\a)--(60:\a)--(120:\a)
--(180:\a)--(240:\a)--(300:\a)--cycle;
\foreach \i in {0,1,...,5} 
\fill[rotate=60*\i] (0,0)--(120:\a)-|cycle;
}

\foreach \j in {45,135,-135,-45}{
\begin{scope}[shift={(\j:4)}]
\subpic 
\end{scope}
}
\end{tikzpicture}
\end{document}

enter image description here

Tags:

Tikz Pgf