My goal is to automate a process where I have many pictures from a movie sequence and I would like them to be typeset in descending rows. For that, all my images rest in a folder and of course, they are named with a file index at the end. I went with a matrix but, as long as it's flexible (based on 3 parameters: total width; miniature width; number of columns), anything made in tikz would be great.
% !TeX encoding = UTF-8
% !TeX spellcheck = fr_FR
\documentclass[11pt, frenchb, twoside]{report}
% IMPORTS
\usepackage{polyglossia}
\usepackage{xparse}
\usepackage{xifthen}
\usepackage{tikz}
\usetikzlibrary{backgrounds, patterns, shapes,
calc, positioning,
matrix, scopes,
decorations.fractals, decorations.text}
\newlength{\foolen}
\newlength{\barlen}
% GRIDFIGURES % % % % % % % % % % % % % % % %
% #1 total width [default: \textwidth]
% #2 total figures
% #3 total columns
% #4 gutter space
% #5 folder
% #6 label
\ProvideDocumentCommand \gridFigures{ O{\textwidth} m m m m m }
{%
\let\gridcontent\empty
\let\ea\expandafter%
\pgfmathsetlength{\foolen}{(#1/#3)-#4}
\pgfdeclareimage[width=\foolen]{ghost}{../assets/#5/#6-1}
\settoheight{\barlen}{\pgfuseimage{ghost}}
%
\foreach \i in {1,2,...,#2}
{%
\pgfmathparse{mod(\i,#3)}
\pgfmathtruncatemacro{\mod}{\pgfmathresult}
\ifthenelse{\mod>0}
{\ea\gappto\ea\gridcontent\ea{\ea{\i} \&}}
{\ea\gappto\ea\gridcontent\ea{something \ea{\i} \\}}}
\begin{tikzpicture}
\matrix[matrix of nodes, ampersand replacement=\&]{\gridcontent};
\end{tikzpicture}}
\begin{document}
\begin{figure}[ht]
\gridFigures{40}{5}{5mm}{mohr}{cubic-limit}
\end{figure}
\end{document}
Because for now, I can't fill my matrix with the image number due to an expansion trouble. To re-build the image with the file index (\i) within the \foreach, i must be expanded right after \ea\gappto\ea\gridcontent\ea otherwise it won't work. I'm probably missing something since it's the first time I actually begin to understand what expansion is.
