我希望每个人frame
在beamer
演示中都展示一个small table + 4 images
。
对于每个新帧,4 个图像都会发生变化。相反,表中只有一个单元格的内容在发生变化。
给出以下列表FOLDERS
:
FOLDERS="
10.00K
30.10K
50.20K
70.30K
90.40K
"
我需要循环遍历数组的元素FOLDERS
以便以下内容可以工作,即:
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}
根据@marmot 的回答:
两个都:
\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}
和:
\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}
不工作。
答案1
pgffor
您可以使用、\only
和轻松完成此操作\pause
。我提供了一个适用于每台机器的示例,因为我不想在我的文件系统中添加多个文件夹,但如何根据您的需要进行调整应该是显而易见的。此示例
\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}
在不同的幻灯片上加载不同的图形,并且(更新) 显示的是表中的数字。
答案2
基本与 marmot 相同,但不需要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
{%
\advance\DavidC1
\only<\DavidC>{\includegraphics[width=4cm]{example-image-\X}}%
\pause
}\egroup
\includegraphics[width=4cm]{example-image-a}
\end{frame}
\end{document}