I have two set of images, fruits and flowers jpeg images like 1.jpeg, 2.jpeg, 3.jpeg, 4.jpeg and 5.jpeg. I want to put them in tikzpicture, without overlapping with each other. Below is the code-
\documentclass{standalone}
\usepackage{graphicx}
\usepackage{ifthen}
\usepackage{tikz}
\newcommand{\imgwidth}{0.3\linewidth}
\newcommand{\forloop}[5][1]%
{%
\setcounter{#2}{#3}%
\ifthenelse{#4}%
{#5%
\addtocounter{#2}{#1}%
\forloop[#1]{#2}%
{%
\value{#2}%
}%
{#4}{#5}%
}%
%Else
{%
}%
}%
\newcounter{count}
\newcounter{index}
\setcounter{index}{1}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\forloop[1]{count}{1}{\value{count} < 6}
{
\node[inner sep=0] at (\arabic{index},3,0) {\includegraphics[width=\imgwidth]{./flowers/\arabic{count}}};
\node[inner sep=0] at (\arabic{index},0,0) {\includegraphics[width=\imgwidth]{./fruits/\arabic{count}}};
\addtocounter{index}{4}
}
\draw (\arabic{index}*0.45,-2) node {Flowers and Fruits};
\end{scope}
\end{tikzpicture}
\end{document}
As it can be seen that the code is not robust enough. Any better way to achieve the same using tikzpicture?


\foreachusage easier here? – Jul 10 '16 at 08:39