TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a case where I need to draw a hexagonal grid in LaTeX. I am considering just reading the grid from an eps file.

Is there an alternative way to do it completely within LaTeX?

share|improve this question
You can use TikZ and adopt the code from this triangular grid. – Caramdir Nov 26 '10 at 23:14
as usual tikz or pstricks or metapost among others – pluton Nov 26 '10 at 23:17
By the way, I was quite amused by your no-so-veiled "threat" to LaTeX: "I am considering just reading the grid from an eps file.".... :-) – Yossi Farjoun Nov 28 '10 at 9:18
Thanks for mentioning TikZ. I want to typeset some astrology charts and this might be just the thing. – Larry Coleman Nov 28 '10 at 23:14
up vote 38 down vote accepted

Here's a quick option:

  \foreach \i in {0,...,3} 
  \foreach \j in {0,...,3} {
  \foreach \a in {0,120,-120} \draw (3*\i,2*sin{60}*\j) -- +(\a:1);
  \foreach \a in {0,120,-120} \draw (3*\i+3*cos{60},2*sin{60}*\j+sin{60}) -- +(\a:1);}

Which results in

alt text

share|improve this answer
I think your approximations are not good enough. The lines of the grid cross each other slightly. – Caramdir Nov 26 '10 at 23:46
Fixed. I was lazy before, and it was late... – Yossi Farjoun Nov 27 '10 at 10:40
That is an amazingly good solution! – Yiannis Lazarides Nov 27 '10 at 12:48
I have to give you the checkmark. You did exactly how I dreamt it. – John Smith Nov 29 '10 at 0:13
Took a bit of searching for the code to do this (but faster than doing it myself) but thanks. It's helped me too. – Matthew Orlinski Apr 8 '13 at 23:09

With TikZ, you can define a pattern which allows to fill any shape with a hexagonal grid by adding the option pattern=hexagons:

alt text



  {hexagons}% name
  {\pgfpointorigin}% lower left
  {\pgfpoint{3*\hexagonsize}{0.866025*2*\hexagonsize}}%  upper right
  {\pgfpoint{3*\hexagonsize}{0.866025*2*\hexagonsize}}%  tile size
  {% shape description

\fill[pattern=hexagons] (0,0) rectangle (10,5);

\fill[pattern=hexagons] (0,0) circle (3cm);


You can change the size of the hexagons by modifying the value of the macro \hexagonsize.

share|improve this answer
I like it! Nice solution. – Yossi Farjoun Nov 29 '10 at 8:16
Ah finally found it. I was looking for this nice snippet for a while with bad keywords :-) Would you like to write an answer to the open question tex.stackexchange.com/questions/54358/… ? I think this would be the perfect example. – percusse Jun 17 '12 at 21:32
@percusse: thanks for notifying me. I'll add an answer later on. – Philippe Goutet Jun 18 '12 at 6:34

Another way could be to draw hexagonal nodes over an adjusted coordinate system. The idea came adapting Paul Gaborit's Pascal triangle for How can I draw Pascal's triangle with some its properties?.

shapes.geometric library helps to draw hexagon where the minimum size is the diameter of the circumcircle. Therefore, selecting adjusted values for x (x=1.5*{minimum size}) and y (y=\sqrt{.75}*{minimum size}/2) the hexagonal grid can be drawn placing an node centered in every pair (x,y).

\documentclass[border=2mm, tikz]{standalone}

% x=3*(minimum size)/2
% x=\sqrt{3/4}*(minimum size)/2
  % some styles
      regular polygon,
      regular polygon sides=6,
      minimum size=10mm,
      inner sep=0mm,
      outer sep=0mm,

\foreach \i in {0,...,5} 
    \foreach \j in {0,...,5} {
            \node[box] at (2*\i,2*\j) {};
            \node[box] at (2*\i+1,2*\j+1) {};



enter image description here

share|improve this answer
What are the [x=7.5mm,y=4.34mm] parameters for the Tikz package? – jvriesem Jan 6 at 1:13
@jvriesem They define base vectors for the coordinate system. By default,x=1cm and y=1cm. When you say (2,3), TiKZ reads (2*x,3*y). Better explanation can be found in Coordiante system in TiKZ documentation. – Ignasi Jan 6 at 21:11

And a Metapost approach...

enter image description here

prologues := 3;
outputtemplate := "%j%c.eps";


% r = side of hexagon, n = repetitions of the grid (- and +)
r = 5mm; n=10;

% make a shape to draw
path tri; tri = for t=0 step 120 until 359: origin -- (r,0) rotated t -- endfor cycle;

% save the pattern as a picture centered on the origin
picture grid; grid = image(
  for i=-n upto n:
    for j=-n upto n: 
      draw tri shifted (i*3/2r,j*r*sqrt(3)) if (i mod 2)=1: shifted (0,r/2*sqrt(3)) fi ; 

% clip the pattern as required (to get rid of the rough edges...)
clip grid to fullcircle scaled (2*n*r);

% draw as needed
draw grid; 
draw grid rotated 30 shifted (2n*r,0) withcolor .67 red;

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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