Yet another attempt at a Fractal construction. This time I am trying to draw the Sierpinski Hexagon:

enter image description here

I think this should be easy enough to do using l-system. My question is a slightly broader one than just how to draw this I suppose.

How do I define an l-system to use hexagons instead of squares or triangles?

  • Hexagon = six triangles.
    – Symbol 1
    Aug 19, 2017 at 16:03
  • How would I implement that into the code? If I make the hexagon out of 6 equilaterals, then with the standard sierpinski code I would end up with 6 copies of the triangle no? That would look pretty cool.
    – JSharpee
    Aug 19, 2017 at 16:08
  • Do it for me... Aug 19, 2017 at 18:13

2 Answers 2


I simply adapt Jake's Sierpinski triangle : How to create a Sierpinski triangle in LaTeX?

The output

enter image description here

The code



\pgfdeclarelindenmayersystem{Sierpinski hexagon}{
    \rule{X -> X+X+X+X+X+X+Y}
    \rule{Y -> YYY}
\foreach \level in {1,...,4}{%
    l-system={step=\hexagwidth/3^\level, order=\level, angle=60}
  \fill (0,0) l-system [l-system={Sierpinski hexagon, axiom=X}] ;
  • very nice, . .......... Aug 20, 2017 at 5:41

Just for fun, I've reproduced this fractal figure with MetaPost, thanks to a recursive macro.

vardef Sierpinski(expr A, B, n) =
    save P; pair P[]; P0 = A; P1 = B;
    for i = 1 upto 5:
        P[i+1] = P[i-1] rotatedaround (P[i], 120);
    if n = 0: fill P0 for i = 1 upto 5: -- P[i] endfor -- cycle;
    for i = 0 step 2 until 4:
        Sierpinski(P[i], 1/3[P[i],P[i+1]], n-1);
        Sierpinski(2/3[P[i],P[i+1]], P[i+1], n-1);
    endfor; fi

    for n = 0 upto 4:
        draw image(Sierpinski(origin, (2cm, 0), n)) shifted (n*4.5cm, 0);


enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .