Loop over the elements of an array so that each frame changes with images and cell content

I would like each frame in a beamer presentation to show a small table + 4 images.

For every new frame, the 4 images change. On the contrary, only the content of one cell is changing in the table.

Given a list of FOLDERS:

FOLDERS="
10.00K
30.10K
50.20K
70.30K
90.40K
"


I would need to loop over the elements of the FOLDERS array so that the following could work, i.e.:

FOLDERS="
10.00K
30.10K
50.20K
70.30K
90.40K
"

for i in {FOLDERS}: %%%% LOOPING OVER THE i ELEMENTS OF THE ARRAY

\begin{frame}
\vspace{-0.5em}
\begin{table} % This is the small table I was referring to:
\centering
\begin{tabular}{c|c|c|c|c}
$E$ \text{ from \texttt{ABC}}&
$V$ &
$Z= -\frac{\partial M}{\partial N}$ &
$K = L + HJ$ &
$LK^{I}$ and $LL^{II}$  \\\hline
$\cdots$ &
$\cdots$ &
$\cdots$ &
$\cdots$ &
at {i}  %%%% NOTE THAT HERE COMES i, THE ELEMENT FROM THE ARRAY
\end{tabular}
\end{table}
\vspace{-0.5em}
%
% This is the set of 4 images:
\makebox[\textwidth]{%
\begin{minipage}{1.05\textwidth} %
\includegraphics[width=.49\textwidth,keepaspectratio]
{/path/to/images/folder/{i}/myimage.pdf}% %%%% NOTE i HERE
\includegraphics[width=.49\textwidth,keepaspectratio]
{/path/to/images/folder/{i}/otherimage.pdf}\\[4pt] %%%% NOTE i HERE
\includegraphics[width=.49\textwidth,keepaspectratio]
{/path/to/images/folder/{i}/otherotherimage.pdf}\hfill% %%%% NOTE i HERE
\includegraphics[width=.49\textwidth,keepaspectratio]
{/path/to/images/folder/{i}/otherotherotherimage.pdf} %%%% NOTE i HERE
\end{minipage}
}

\end{frame}


Both:

\begin{frame}

\foreach \X [count=\Y]in {10.00K, 30.10K}
{
\only<\Y>{
\makebox[\textwidth]{%
\begin{minipage}{1.05\textwidth} % <--- can be as large the slide size permits
\includegraphics[width=.49\textwidth,keepaspectratio]{/path/to/\X/image.pdf}}%
\includegraphics[width=.49\textwidth,keepaspectratio]{/path/to/\X/other_image.pdf}\\[4pt]
\includegraphics[width=.49\textwidth,keepaspectratio]{/path/to/\X/other_other_image.pdf}\hfill%
\includegraphics[width=.49\textwidth,keepaspectratio]{/path/to/\X/other_other_other_image.pdf}
}

\end{minipage}
\pause
}

\end{frame}


and:

\begin{frame}

\makebox[\textwidth]{%
\begin{minipage}{1.05\textwidth} %
\foreach \X [count=\Y]in {10.00K, 30.10K}
{
\only<\Y>{
\includegraphics[width=.49\textwidth,keepaspectratio]{/path/to/\X/image.pdf}}%
\includegraphics[width=.49\textwidth,keepaspectratio]{/path/to/\X/other_image.pdf}\\[4pt]
\includegraphics[width=.49\textwidth,keepaspectratio]{/path/to/\X/other_other_image.pdf}\hfill%
\includegraphics[width=.49\textwidth,keepaspectratio]{/path/to/\X/other_other_other_image.pdf}
\end{minipage}
\pause
}
}
\end{frame}


do not work.

You can do that very easily with pgffor, \only and \pause. I present an example that works on every machine because I didn't want to add several folders to my file system, but it should be obvious how to adjust it to your needs. This example

\documentclass{beamer}
\usepackage{pgffor}
\begin{document}
\newcommand{\Funkytable}[1]{
\vspace{-0.5em}
\begin{table} % This is the small table I was referring to:
\centering
\begin{tabular}{c|c|c|c|c}
$E$ \text{ from \texttt{ABC}}&
$V$ &
$Z= -\frac{\partial M}{\partial N}$ &
$K = L + HJ$ &
$LK^{I}$ and $LL^{II}$  \\\hline
$\cdots$ &
$\cdots$ &
$\cdots$ &
$\cdots$ &
at {#1}  %%%% NOTE THAT HERE COMES i, THE ELEMENT FROM THE ARRAY
\end{tabular}
\end{table}
\vspace{-0.5em}}
\begin{frame}

\foreach \X [count=\Y]in {a,b,c}
{
\only<\Y>{
\Funkytable{\Y}
}
\only<\Y>{\includegraphics[width=4cm]{example-image-\X}}
\pause
}
\Funkytable{4}
\includegraphics[width=4cm]{example-image-golden.pdf}
\end{frame}
\end{document}


loads different graphics on different slides and (UPDATE) shows the number in the table.

• Thank you for your answer. Unfortunately, there are several things that do not work: 1) Please note that there are 4 \includegraphics declarations under a makebox and minipage environment (see original post). Inserting the \foreach block inside the \begin{minipage} line does not work. 2) Note that the original post states that the cell content of the small table (last column) contains {i}, the variable from which we are looping Apr 7, 2018 at 15:13
• @DavidC. 1) I used only three graphics because there are only three standard example images a, b, and c. 2) You are not supposed to insert the loop inside the minipage, and there is no need for that. 3) It is straightforward to put the i. Proposal: You ask me to provide an example that does not require anyone adapting it to add new folders and so on, and I'll do that. What I am not going to do is to write an answer that only can be used once.
– user121799
Apr 7, 2018 at 15:38
• Just to be clear, I am not discarding your answer and all your efforts, but totally the opposite: I do really appreciate your approach and your help. I am just trying to understand how to use your approach in a \makebox environment, which is where I was having the problem initially. Please see updated post, where I show what I am referring to. Apr 7, 2018 at 16:41
• @DavidC. \relax ;-) The only thing I am asking is to tell me how I can come up with an answer that doesn't make others who want to reproduce it freak out. The current version of my answer does show four graphics, its just that the fourth one coincides with first one (because there is no example-image-d). I'll fix the table now. ;-)
– user121799
Apr 7, 2018 at 16:48
• @DavidC. OK, I added the number,
– user121799
Apr 7, 2018 at 16:54

Basically the same as marmot, but without the need of pgffor:

\documentclass{beamer}
\newcount\DavidC
\makeatletter
\let\DavidFor\@for
\makeatother
\begin{document}
\begin{frame}
\vspace{-0.5em}
\begin{table} % This is the small table I was referring to:
\centering
\begin{tabular}{c|c|c|c|c}
$E$ \text{ from \texttt{ABC}}&
$V$ &
$Z= -\frac{\partial M}{\partial N}$ &
$K = L + HJ$ &
$LK^{I}$ and $LL^{II}$  \\\hline
$\cdots$ &
$\cdots$ &
$\cdots$ &
$\cdots$ &
at {i}  %%%% NOTE THAT HERE COMES i, THE ELEMENT FROM THE ARRAY
\end{tabular}
\end{table}
\vspace{-0.5em}
\bgroup
\DavidFor\X:={a,b,c}\do
{%