如何刪除其他六邊形?

如何刪除其他六邊形?

我想畫一個六邊形,周圍有與原來全等的六邊形,總共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}

相關內容