1

I’ve been looking for a template for a background of hexagons using tikz. Tinkering around with other designs have been not working out for me, so I thought I’d ask myself.

The main point for my request is to ask:

  • for a scalable design,
  • to be able to change the sizes of the hexagons some way,
  • perhaps to locate specific hexagons fairly easily, or at all?

I’m looking for this on an a0 poster but any help in the right direction would be extremely appreciated.

AndréC
  • 24,137
Genni
  • 11
  • Welcome to TeX.SE! Hexagon lattices can be found in several posts here, such as https://tex.stackexchange.com/q/141911/121799. –  Feb 10 '19 at 07:26
  • You could also look at https://tex.stackexchange.com/q/6019/1952 – Ignasi Feb 11 '19 at 08:33

1 Answers1

2

To make hexagonal paving, I wrote a double foreach loop that makes a hexagonal paving from a minimal pattern.

This pattern is called hexapavage (it is not a hexagon), it has the advantage of not drawing the same line twice and therefore, there is no superposition of lines between them.

hexapavage

\def\hexapavage{--++(60:1)--+(120:1)++(0,0)--++(1,0)--++(60:1)--+(1,0)++(-120:1)--++(-60:1)}
\tikz\draw[blue](0,0)\hexapavage;

I coloured a copy of this pattern in blue as well as a reduction of the hexagons in the second figure.

On the other hand, I didn't try to create a coordinate system to locate hexagons.

pavage hexagonal

\documentclass[tikz,border=3mm]{standalone} 
\def\hexapavage{--++(60:1)--+(120:1)++(0,0)--++(1,0)--++(60:1)--+(1,0)++(-120:1)--++(-60:1)}

\begin{document} 

%\tikz\draw[blue](0,0)\hexapavage;
\begin{tikzpicture}

% Le pavage hexagonal
  \foreach \j in {0,1,...,4} {
\foreach \i in {0,1,...,4} {\draw[thick] (60:\j)++(120:\j)++
(60:\i)++(-60:\i)++(\i,0)++(\i,0) \hexapavage ;
}}
 \draw[blue,very thick](0,0)\hexapavage;

% pavage avec scale
 \begin{scope}[yshift=-6cm,scale=.6]
  \foreach \j in {0,1,...,4} {
\foreach \i in {0,1,...,4} {\draw[thick] (60:\j)++(120:\j)++
(60:\i)++(-60:\i)++(\i,0)++(\i,0) \hexapavage ;
}}
 \draw[blue,very thick](0,0)\hexapavage;
 \end{scope}
\end{tikzpicture} 
\end{document}
AndréC
  • 24,137
  • Oh wow, \draw[thick] (60:\j)++(120:\j)++ (60:\i)++(-60:\i)++(\i,0)++(\i,0) \hexapavage; instead of \draw[thick] (3*\i,{sqrt(3)*\j}) \hexapavage;... –  Feb 10 '19 at 17:58
  • This time, the text of your code is shorter. But at execution, they are both equally fast. – AndréC Feb 10 '19 at 18:32
  • The compilation time is not the issue. The issue is that there is no reason to represent a translation by \i times something and \j times something by a zigzag combination with 6 steps. You know that the issue is not the compilation time, which is tiny. I stop here. –  Feb 10 '19 at 18:40
  • You're on the wrong track. I wrote this code two weeks after learning LaTeX during a professional training internship. – AndréC Feb 10 '19 at 18:42