9

I want to draw a hexagon surrounded by hexagons congruent to the original, with a total of 7 hexagons. I can do, but I can't delete the rest.

\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}

enter image description here

7

Does this work for you?

enter image description here

\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}
  • Torbjorn T. - Perfect! Works great! – benedito Nov 16 '16 at 22:50
  • Torbjorn T. In the hexagons of the ring, can I number them alternately 0 and 1? – benedito Nov 16 '16 at 23:23
  • @benedito Like that (see edited answer)? – Torbjørn T. Nov 16 '16 at 23:34
  • Torbjorn T. Show! – benedito Nov 17 '16 at 0:19
  • Torbjorn T. - What is the command that makes switch 0 and 1? – benedito Nov 17 '16 at 0:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.