如何将这个场景转化为 LaTeX 循环宏?

如何将这个场景转化为 LaTeX 循环宏?

我想将图像切成 8 个部分,即 2 行 4 列。每个部分都在一页上,如下所示。灰色框是 Acrobat Reader 背景,所以不要认为它是我想要的输出的一部分。

在此处输入图片描述

\documentclass{minimal}
\usepackage[margin=2cm,a6paper]{geometry}
\usepackage{graphicx}
\newsavebox\IBox
\savebox\IBox{\includegraphics{bald}}
\newdimen\width
\newdimen\height
\width=\wd\IBox
\height=\ht\IBox
\parindent=0bp
\usepackage{multido}
\begin{document}
\centering%
%first row
\fbox{\includegraphics[height=\textheight,viewport={0\width} {0.5\height} {0.25\width} {\height},clip]{bald}}
\fbox{\includegraphics[height=\textheight,viewport={0.25\width} {0.5\height} {0.5\width} {\height},clip]{bald}}
\fbox{\includegraphics[height=\textheight,viewport={0.5\width} {0.5\height} {0.75\width} {\height},clip]{bald}}
\fbox{\includegraphics[height=\textheight,viewport={0.75\width} {0.5\height} {\width} {\height},clip]{bald}}
%second row
\fbox{\includegraphics[height=\textheight,viewport={0\width} {0\height} {0.25\width} {0.5\height},clip]{bald}}
\fbox{\includegraphics[height=\textheight,viewport={0.25\width} {0\height} {0.5\width} {0.5\height},clip]{bald}}
\fbox{\includegraphics[height=\textheight,viewport={0.5\width} {0\height} {0.75\width} {0.5\height},clip]{bald}}
\fbox{\includegraphics[height=\textheight,viewport={0.75\width} {0\height} {\width} {0.5\height},clip]{bald}}
\end{document}

如果您需要切片图像,这里就是。

在此处输入图片描述

我尝试使用嵌套\multido宏来翻译它,如下所示,但它确实有效。我认为这是因为我对在 (La)TeX 中进行长度操作的知识不足。

\documentclass{minimal}
\usepackage[margin=2cm,a6paper]{geometry}
\usepackage{graphicx}
\newsavebox\IBox
\savebox\IBox{\includegraphics{bald}}
\newdimen\width
\newdimen\height
\width=\wd\IBox
\height=\ht\IBox
\parindent=0bp
\usepackage{multido}
\begin{document}
\centering
\multido{\nx=0+0.25}{4}
{%
    \multido{\ny=1+-0.5}{2}
    {%
        \fbox{\includegraphics[height=\textheight,viewport={\nx\width} {\ny\height-0.5\height} {\nx\width+0.25\width} {\ny\height},clip]{bald}}%
    }%
}
\end{document}

答案1

\documentclass{minimal}
\usepackage[margin=2cm,a6paper]{geometry}
\usepackage{graphicx}
\newsavebox\IBox
\savebox\IBox{\includegraphics{bald}}
\newdimen\width
\newdimen\height
\width=\wd\IBox
\height=\ht\IBox
\parindent=0bp
\usepackage{multido}
\begin{document}
\centering
\multido{\ry=0.5+-0.5, \rY=1.0+-0.5}{2}{%
  \multido{\rx=0.00+0.25, \rX=0.25+0.25}{4}{%
    \fbox{\includegraphics[%height=\textheight, makes no sense without width=...
       viewport={\rx\width} {\ry\height} {\rX\width} {\rY\height},clip]{bald}}%
    }\\%
}
\end{document}

在此处输入图片描述

相关内容