假设你有图片images=["1.png", "2.png", "3.png", ..., "50.png"];
。你想将它们循环到单个 tex 文档中,以便获得漂亮的标题。我认为使用 Tikz 可以实现。最小伪代码
\documentclass{article}
\usepackage{graphicx}
\begin{document}
%images=["1.png", "2.png", "3.png", ..., "50.png"];
%% Loop here all images; for i in images
\begin{figure}
\center
\includegraphics[scale=0.3]{"${i}"}
\caption{"Image "${i}"."}
%% end
\end{figure}
\end{document}
操作系统:Debian 8.5
TeXLive:2016(不是 apt-get)
答案1
有很多循环实现,例如
\documentclass{article}
\usepackage[demo]{graphicx}
\newcount\ii
\begin{document}
%images=["1.png", "2.png", "3.png", ..., "50.png"];
%% Loop here all images; for i in images
\loop
\ifnum\ii<50
\advance\ii by 1
\begin{figure}
\centering% not \center!
\includegraphics[scale=0.3]{\ii.png}
\caption{Image \the\ii.}
%% end
\end{figure}
\repeat
\end{document}
答案2
既然您要求使用 TikZ。(好吧,如果您不将 TikZ 用于其他任何用途,那么您可以只加载包pgffor
。)
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{pgffor}
\begin{document}
\foreach \ii in {1,...,50} {
\begin{figure}
\centering% not \center!
\includegraphics[scale=0.3]{\ii.png}
\caption{Image \ii.}
\end{figure}
} % closing brace for loop
\end{document}