I have this kind of table:
\begin{tabular}{p{0.5\textwidth}|p{0.5\textwidth}}
caption1 & caption2 \\
\includegraphics[params]{path11} \includegraphics[params]{path12} ... \includegraphics[params]{path1N} & \includegraphics[params]{path21} \includegraphics[params]{path22} ... \includegraphics[params]{path2N} \\
\end{tabular}
I want images to be like array, but they should consider column width and make new row of images automatically if there is no room. all images should be placed equally with margins so they don't touch each other.