Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there an easy way to draw a triangular grid in TikZ, like this?

share|improve this question
Just a pointer. Sorry for not offering real code. I'd draw it just like there were no grid. Use foreach to draw the three sets of lines. –  Leo Liu Aug 18 '10 at 12:54

4 Answers 4

up vote 22 down vote accepted

Like Leo said: use \foreach and some math:


    \foreach \row in {0, 1, ...,\rows} {
        \draw ($\row*(0.5, {0.5*sqrt(3)})$) -- ($(\rows,0)+\row*(-0.5, {0.5*sqrt(3)})$);
        \draw ($\row*(1, 0)$) -- ($(\rows/2,{\rows/2*sqrt(3)})+\row*(0.5,{-0.5*sqrt(3)})$);
        \draw ($\row*(1, 0)$) -- ($(0,0)+\row*(0.5,{0.5*sqrt(3)})$);
share|improve this answer
If I'm not mistaken, for an equilateral triangle, those should all be sqrt(3), not sqrt(2). (Though maybe you didn't want an equilateral one, in which case, ignore me.) –  Ben Alpert Aug 19 '10 at 4:28
Well, that is rather embarrassing. Don't tell anyone! ;) –  Caramdir Aug 19 '10 at 8:39

A funny solution (have you ever used lindenmayersystems library?):

  \pgfdeclarelindenmayersystem{triangular grid}{\rule{F->F-F+++F--F}}
  l-system={triangular grid,step=1cm,
  lindenmayer system -- cycle;
share|improve this answer
Wow, that's pretty clever! –  Jake Jun 26 '12 at 0:25
Great example of lateral thinking -- congratulations! –  Brent.Longborough Jun 26 '12 at 10:30
The question is not "have you ever used lindenmayersystems library", but "did you even know about it's existence". Very nice! –  Tom Bombadil Jun 26 '12 at 10:42
@TomBombadil How to use TikZ without reading the manual? How to read pgfmanual without reading all chapters? ;-) –  Paul Gaborit Jun 26 '12 at 22:10

A slightly different solution using a matrix transformation and clipping:



    \path[clip,preaction = {draw=black}] (\rows,0) -- (0,0) -- (0,\rows) -- cycle;
    \draw (0,0) grid (\rows,\rows);
    \foreach \x in {1,2,...,\rows} {
        \draw (0,\x) -- (\x,0);
share|improve this answer
Very beautiful! –  Paul Gaborit Jun 26 '12 at 0:28
Nice. (nitpick: the last (\rows,0) can be cycle :P) –  percusse Jun 26 '12 at 9:44
Very nice (and very convenient when one needs to draw something on triangular grid). –  Grigory M Dec 8 at 15:43

Probably not the most elegant, but slightly simplified (from my perspective) variant of Caramdir's answer.




        \tikzstyle{every node}=[draw,thin]

        \foreach \a in {1,...,\gridsize}{
            \draw[dotted] (0, 0) -- (\a, 0) -- ({cos(60)*\a}, {sin(60)*\a}) -- cycle;
            \draw[dashed] ({\gridsize-\a}, 0) -- (\gridsize, 0) -- ({\gridsize-cos(60)*(\a)}, {sin(60)*(\a)}) -- cycle;
            \draw[red] ({cos(60)*(\gridsize-\a)}, {sin(60)*(\gridsize-\a)}) -- ({(\gridsize/2)+cos(60)*\a}, {sin(60)*(\gridsize-\a)}) -- ({cos(60)*\gridsize}, {sin(60)*\gridsize}) -- cycle;

\caption{Triangular grid}


Charles Staats contributed to this solution in Drawing scaled triangles with their bottom left corner at the same coordinates in TikZ as I became fixated on using polygons.

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.