I want to draw an image like the following:
I did this using the following Tikz code:
\documentclass[a4paper]{article}
\usepackage{tikz}
\usepgflibrary{shapes.geometric}
\begin{document}
\begin{tikzpicture}
[hexagon/.style={regular polygon, regular polygon sides=6,
draw, minimum size=1cm, anchor=center}]
\foreach \x in {0,...,2}
\node at (\x, 5) [hexagon]{};
\foreach \x in {0,...,3}
\node at (\x-0.5, 4.12) [hexagon]{};
\foreach \x in {0,...,4}
\node at (\x-1, 3.25) [hexagon]{};
\foreach \x in {0,...,3}
\node at (\x-.5, 2.38) [hexagon]{};
\foreach \x in {0,...,2}
\node at (\x, 1.52) [hexagon]{};
\end{tikzpicture}
\end{document}
Is there a better way to code this, using fewer manually-calculated approximations in Tikz? Also, as can be seen, the lines overlap in a weird inexact way. Can I avoid that too?
Best Answer
I realized that this question is slightly different form the drawing hexagons of yore...so, how about this solution:
which yields:![alt text](https://i.stack.imgur.com/3FPGs.png)