如何删除其他六边形?

如何删除其他六边形?

我想画一个六边形,周围都是与原图全等的六边形,一共有 7 个六边形。我可以这样做,但是我不能删除其余的六边形。

\documentclass[border=2mm, tikz]{standalone}
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{tikzpicture}[x=7.5mm,y=4.34mm]
  \tikzset{box/.style={regular polygon, regular polygon sides=6,     
        minimum size=10mm,       
      inner sep=0mm,outer sep=0mm, rotate=0, draw }  }
\foreach \i in {0,...,1} 
    \foreach \j in {0,...,2} {\node[box] at (2*\i,2*\j) {};           
        \node[box] at (2*\i+1,2*\j+1) {}; }
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案1

这对你有用吗?

在此处输入图片描述

\documentclass[border=2mm, tikz]{standalone}
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{tikzpicture}[
   x=7.5mm,y=4.34mm,
   box/.style={
      regular polygon,
      regular polygon sides=6,     
      minimum size=10mm,       
      inner sep=0mm, outer sep=0mm,
      draw}
 ]
\node [box] (innerbox) {};
\foreach [evaluate=\x as \y using {int(ifthenelse(\x+2>6,\x-4,\x+2))}] \x in {1,...,6}
  \node [box,anchor=corner \y] at (innerbox.corner \x) {\pgfmathparse{int(mod(\x,2))}\pgfmathresult};

\end{tikzpicture}
\end{document}

相关内容