With help from answers to TikZ: Drawing regular hexagons with pictures inside, I've created some tiles for a children's game:
To save on costs of printing + card, I'd like to fit 3 more hexes into the gaps in the [a4] paper.
The code that generated that looked like this:
\tile{Lake}{lake.jpg}{1.2}{Starts on Board}{--}{\food}\hfill
\tile{Forest}{forest.jpg}{1.6}{Starts on Board}{--}{\wood}\\
\tile{Forest}{forest.jpg}{1.6}{Starts on Board}{--}{\wood}\hfill
\tile{Forest}{forest.jpg}{1.6}{Starts on Board}{--}{\wood}\\
\tile{Baker}{baker.jpg}{7}{Build on Clearing}{\wood\wood\person}{\convert{\grain}{\food}}\hfill
\tile{Butcher}{butcher.jpg}{10}{Build on Clearing}{\wood\wood\person}{\convert{\sheep}{\food}}\\
\tile{Baker}{baker.jpg}{7}{Build on Clearing}{\wood\wood\person}{\convert{\grain}{\food}}\hfill
\tile{Butcher}{butcher.jpg}{10}{Build on Clearing}{\wood\wood\person}{\convert{\sheep}{\food}}\\
I could add an extra 'location' argument to \tile
and cyclically instantiate it with 11 positions, but that would be a pain to maintain when I changed the number of tiles (e.g. changed 3 forests to 4 forests). So: how can I keep the positional information separate from the specification of the contents of the tiles?
Edit: full code as requested. (Tiles have changed a bit, but not in a way that affects the question.)
\documentclass[a4paper]{article}
\usepackage[margin=2mm]{geometry}
\usepackage{tikz,nopageno}
\usepackage{wasysym}
\usetikzlibrary{fit,backgrounds}
\setlength{\parskip}{0mm}
\newcommand{\highlight}[2]{%
\begin{tikzpicture}[baseline = (text.base)]
\node[inner sep=0pt] (text) {#2};
\begin{pgfinterruptboundingbox}
\begin{pgfonlayer}{background}
\node[fit=(text), rounded corners, fill=white, opacity=#1, draw=none] {};
\end{pgfonlayer}
\end{pgfinterruptboundingbox}
\end{tikzpicture}%
}
% General macro to draw a shape filled with a bitmap
\newcommand\fillshape[3]{ % #1 = shape, #2 = filename of texture, #3 = includegraphics options
\begin{scope}
\clip #1;
\node {\includegraphics[#3]{#2}};
\end{scope}
\draw[line width=0.5mm] #1;
}
% Particularization for hexagonal shape
\newcommand\fillhexagon[2][]{% #1 (optional) = includegraphics options, #2 = filename of texture
\fillshape{(0:4) -- (60:4) -- (120:4) -- (180:4) -- (240:4) -- (300:4) -- cycle}{#2}{#1}
}
\newcommand\tile[6]{
\begin{tikzpicture}
\fillhexagon[scale=#3]{#2};
\node at (0,2.4) {\highlight{0.65}{\LARGE\bf #1}};
\node at (0,0.7) {\highlight{1}{#6}};
\draw [rounded corners, fill=white, opacity=1] (-2,-0.6)--(2,-0.6)--(2,-2.5)--(-2,-2.5)--cycle;
\node at (0,-1.05) {#4};
\node at (0,-1.85) {#5};
\end{tikzpicture}
}
\newcommand\image[2]{$\vcenter{\hbox{\includegraphics[scale=#1]{#2}}}$}
\newcommand\wood{\image{0.22}{wood.png}}
\newcommand\food{\image{0.23}{bowl.jpg}}
\newcommand\person{\image{0.25}{peasant.jpg}}
\newcommand\grain{\image{0.5}{grain2.jpg}}
\newcommand\sheep{\image{0.05}{sheep.png}}
\newcommand\stone{\image{0.35}{stone.png}}
\newcommand\ale{\image{0.12}{ale.png}}
%\newcommand\cloth{\image{0.2}{cloth.png}}
\newcommand\paper{\image{0.1}{paper.png}}
\newcommand\gold{\image{0.7}{gold.jpg}}
\newcommand\marble{\image{0.2}{marble.jpg}}
\newcommand\TO{\Huge$\rightarrow$}
\newcommand*{\vpointer}{$\vcenter{\hbox{\ \scalebox{2}{$\rightarrow$}}}$}
\newcommand\convert[2]{#1\vpointer\, #2}
\begin{document}
\tile{Lake}{lake.jpg}{1.2}{Starts on Board}{--}{\food}\hfill
\tile{Field}{field2.jpg}{1.5}{Replaces Clearing}{\person\person\person\person}{\grain}\\
\tile{Forest}{forest2.jpg}{0.4}{Starts on Board}{--}{\wood}\hfill
\tile{Mountain}{mountain2.jpg}{0.3}{Starts on Board}{--}{--}\\
\tile{Baker}{baker.jpg}{7}{Build on Clearing}{\wood\wood\person}{\convert{\grain}{\food}}\hfill
\tile{Butcher}{butcher.jpg}{10}{Build on Clearing}{\wood\wood\person}{\convert{\sheep}{\food}}\\
\tile{Grazing}{grazing.jpg}{0.3}{Replaces Hill}{\person}{\sheep}\hfill
\tile{Pasture}{sheepfield.jpg}{2.1}{Replaces Clearing}{\wood\sheep\sheep\sheep\sheep}{\sheep\sheep}
\end{document}
\documentclass{...}
and ending at\end{document}
?\tile
s in atable
valid for you?