Each of the five figures is drawn using a combination of a square, some circles and some sort of shading. I need to draw each of these using a single command so that they can fit and make a rectangle without gap, for example a 7 times 11 one. Even the arcs can be replaced by a zizag so that they make a rectangle when fit together but this means advanced computation and plotting.


\draw[fill=cyan] (4.,4.) -- (0.,4.) -- (0,0) -- (4,0) -- cycle;
\draw[fill=white,  draw=none](3.5,2) circle (.8cm);
\draw[fill=white, draw=none](2,3.5) circle (.8cm);

\draw[fill=cyan] (7,0) -- (11,0) -- (11,4) -- (7,4) -- cycle;
\draw[fill=white,  draw=none](10.5,2) circle (.8cm);
\draw[fill=cyan,  draw=none](6.5,2) circle (.8cm);

\draw[fill=cyan, draw=none](9,4.5) circle (.8cm);

\draw[fill=cyan] (14,0) -- (18,0) -- (18,4) -- (14,4) -- cycle;
\draw[fill=cyan,  draw=none](13.5,2) circle (.8cm);
\draw[fill=cyan,  draw=none](18.5,2) circle (.8cm);

\draw[fill=white, draw=none](16,3.5) circle (.8cm);

\draw[fill=cyan] (21,0) -- (25,0) -- (25,4) -- (21,4) -- cycle;
\draw[fill=white,  draw=none](24.5,2) circle (.8cm);
\draw[fill=white,  draw=none](21.5,2) circle (.8cm);
\draw[fill=white,  draw=none](23,.5) circle (.8cm);
\draw[fill=cyan,  draw=none](23,4.5) circle (.8cm);

\draw[fill=cyan] (28,0) -- (32,0) -- (32,4) -- (28,4) -- cycle;
\draw[fill=cyan,  draw=none](30,4.5) circle (.8cm);
\draw[fill=cyan,  draw=none](32.5,2) circle (.8cm);
\draw[fill=white,  draw=none](28.5,2) circle (.8cm);
\draw[fill=white,  draw=none](30,.5) circle (.8cm);

\node at (2, -1) {\small type  1};
\node at (9, -1) {\small type  2};
\node at (16, -1) {\small type  3};
\node at (23, -1) {\small type 4};
\node at (30, -1) {\small type 5};

enter image description here

enter image description here

  • I believe that the legal patterns are not unique. Which one do you like? Exactly the given one? – Symbol 1 Jan 28 '17 at 20:54
  • With only these types there are certain restrictions. There will be one and only one type 3 in each edge. You cannot have two type 3 in any given row or column. There can only be one type 4 in any row or column in the "hole to hole" direction. – John Kormylo Jan 28 '17 at 21:49
  • The 7x11 rectangles has more than one configurations yet all of the configurations have the same number of each type. – Thumbolt Jan 29 '17 at 2:04

I think this is a good chance to practice 's parser module. See the manual for more information.

The foreground layer is actually unnecessary. But since the pocket is drawn by a white circle, I have to draw the tab on a different layer.

The clipping syntax, shift and scale are unnecessary, too. But that means you have to recode your pieces.



\pgfparserdef{jigsaw}{all}{the character 1}{\def\jigsawtype{1}}
\pgfparserdef{jigsaw}{all}{the character 2}{\def\jigsawtype{2}}
\pgfparserdef{jigsaw}{all}{the character 3}{\def\jigsawtype{3}}
\pgfparserdef{jigsaw}{all}{the character 4}{\def\jigsawtype{4}}
\pgfparserdef{jigsaw}{all}{the character 5}{\def\jigsawtype{5}}

\pgfparserdef{jigsaw}{all}{the letter A}   {\def\jigsawangle{0}}
\pgfparserdef{jigsaw}{all}{the character <}{\def\jigsawangle{90}}
\pgfparserdef{jigsaw}{all}{the letter V}   {\def\jigsawangle{180}}
\pgfparserdef{jigsaw}{all}{the character >}{\def\jigsawangle{-90}}

\pgfparserdef{jigsaw}{all}{blank space \space}{}
\pgfparserdef{jigsaw}{all}{the character :}{\jigsawstart}
\pgfparserdef{jigsaw}{all}{the character ,}{\jigsawdrawone}
\pgfparserdef{jigsaw}{all}{the character ;}{\jigsawnewline}
\pgfparserdef{jigsaw}{all}{the character .}{\jigsawend}

    \path coordinate(line begin)coordinate(curser);
    \draw(curser)pic[rotate=\jigsawangle]{jigsaw \jigsawtype};
    \path(line begin)++(0,-1)coordinate(line begin)coordinate(curser);


    sq/.style={cyan,draw=white,line width=.05cm},
    jigsaw 1/.pic={
    jigsaw 2/.pic={
    jigsaw 3/.pic={
    jigsaw 4/.pic={
    jigsaw 5/.pic={



  • Found a overlap on the lower right corner; hope it does not harm. – Symbol 1 Jan 28 '17 at 22:12
  • You could sell this as a game "find the one overlap in this pattern" - it took me quite a bit to find it :) – user36296 Nov 19 '18 at 17:47
  • Or, put one thousand ducks on a page and find the one with red-white shirt and blue pants. – Symbol 1 Nov 19 '18 at 21:33
  • We could make a whole book with such riddles :) – user36296 Nov 19 '18 at 21:37

Instead of worrying yourself how to puzzle together your jigsaw pieces, you could use the jigsaw package to automatically create a pattern of your desired dimensions:




    \fill[cyan] (0,0) rectangle (11,7);


enter image description here

(the trick is to not try to puzzle matching pieces together, but to draw only every second line :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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