I have a number of figures coming from experiments; they are indexed with an integer number, and they are not always consecutive. Given a list of the indexes, I need to put them in a tabular
of, say, 4 columns. After some searching I made this:
\begin{table}[H]
\begin{tabular}{|c|c|c|c|}
\hline
\newcounter{imagecounter}
\foreach \n in {2,3,10,11,13,14,16,17,18,19,24,25,26,31,32,33,34,35,39,40}{
\stepcounter{imagecounter}
\ifnum\intcalcMod{\value{imagecounter}}{4}=0
& \includegraphics{image_index\n.png} \\
\fi
\ifnum\intcalcMod{\value{imagecounter}}{4}=1
\includegraphics{image_index\n.png}
\fi
\ifnum\intcalcMod{\value{imagecounter}}{4}=2
& \includegraphics{image_index\n.png}
\fi
\ifnum\intcalcMod{\value{imagecounter}}{4}=3
& \includegraphics{image_index\n.png}
\fi
}
\end{tabular}
\end{table}
The problem is that, apparently, IF controllers must be inside tabular
cells (is that the case?). I haven't been able to solve it or to find an alternative.
Is there a simple way to solve it? Is there another approach?
If so, please provide an example, I am very new to macros, new commands, and anything that is not straightforwards formatting text and tables.
\intcalcMod
is a macro we can guess but it is not part of standard latex.