\documentclass[11pt,a4paper]{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
% CTC : center to center
% Distance is 2*sin(pi/3)
\def\ctc{1.7320508075688772cm}
% Draw an hexagon anywhere.
\def\hexagon#1{
%\draw #1 +(0:1cm) \foreach \a in {60,120,...,300} { -- +(\a:1cm) } -- cycle;
\fill[red] #1 circle (0.2cm);
}
% Draw a small hextile anywhere.
\def\hextile#1{
\foreach \l in {1,2} {
\foreach \a in {30,90,...,330} {
\hexagon{#1 ++(\a:\l*\ctc)};
}
\foreach \a in {0,60,...,300} {
\hexagon{#1 ++(\a:\l*3cm-3cm)};
}
}
}
\def\hextiles{
\foreach \a in {0,120,240} {
\hextile{(\a:6cm)};
}
}
%\hextiles;
\hextile{(0:6cm)};
\hextile{(120:6cm)};
\hextile{(240:6cm)};
\end{tikzpicture}
\end{document}
I am wondering why, oh why, calling \hextiles and \hextile three times don't give out the same result...
It seems linked with the way paths are handled, but I can't see how...
\documentclassand ending with\end{document}? – percusse May 18 '12 at 13:58\ctcdefined and hextile definition is missing a closing brace and no\end{tizkpicture}just by looking at it. – percusse May 18 '12 at 14:05\draw,\fill,\node,\pathand the like) need semi-colons. All "wrapper" macros don't need them – Andrew Stacey May 18 '12 at 14:44