答案1
你的问题很不明确,因为你没有具体说明你到底在哪方面失败了。下面是一个例子,你问题中的整个图像被分成了单个 A4 页面:
\documentclass[a4paper]{article}
\usepackage{pdfpages}
\usepackage{shellesc}
\IfFileExists{ukUUd.png}{}{%
\ifnum \ShellEscapeStatus=1
\ShellEscape{wget https://i.stack.imgur.com/ukUUd.png}%
\else
\errmessage{Shell escape must be enabled. Please run again with option --shell-escape}%
\fi
}
\newcount\ROW
\newcount\COLUMN
\newlength{\XLEFT}
\newlength{\XRIGHT}
\newlength{\YBOTTOM}
\newlength{\YTOP}
\begin{document}
\makeatletter
\@whilenum\ROW<4 \do{%
\COLUMN=0
\YTOP=\dimexpr 161px*\ROW+17px\relax
\YBOTTOM=\dimexpr 161px*\numexpr (3-\ROW)\relax+12px\relax
\@whilenum\COLUMN<8 \do{%
\XLEFT=\dimexpr 125px*\COLUMN+12px\relax
\XRIGHT=\dimexpr 125px*\numexpr(7-\COLUMN)\relax+11px\relax
\advance\COLUMN by 1
\edef\CMD{\noexpand\includepdf
[trim=\the\XLEFT\space \the\YBOTTOM\space\the\XRIGHT\space \the\YTOP,clip,width=\paperwidth,height=\paperheight]
{uKUUd.png}}%
\show\CMD
\CMD
}%
\advance\ROW by 1
}%
\end{document}
你需要启用 shell 转义编译示例。也可以下载https://i.stack.imgur.com/ukUUd.png并将其放入与文档同一目录中。
答案2
像这样吗?
该代码适用于 pdfLaTeX、XeLaTeX 和 LuaLaTeX。表格设置为横向模式,有四行和 8 个等宽列。假设 4 x 8 表格的图像文件命名为image11
、image12
、 至image48
。名为 的宏\DoCell
接受三个参数,对 4 x 8 = 32 个单元格中的每一个执行该任务。
\documentclass[demo]{article} % or some other suitable document class
\usepackage{iftex}
\ifpdftex
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\else
\usepackage{fontspec}
\setsansfont{Myriad Pro} % choose a suitable sans-serif font
\fi
\usepackage[a4paper,margin=2.5cm]{geometry} % set page parameters suitably
\usepackage{tabularx,ragged2e}
\newcolumntype{C}{>{\Centering}X}
\usepackage{graphicx} % for \includgraphics macro
\usepackage{rotating} % for \sidewaystable env.
\usepackage[dvipsnames]{xcolor}
% make suitable choices for "red" and "blue"
\newcommand{\red}[1]{\textcolor{red}{#1}}
\newcommand{\blue}[1]{\textcolor{blue}{#1}}
\usepackage{colortbl} % for \arrayrulecolor macro
\newcommand\DoCell[3]{%
{\Huge #1\enspace\MakeLowercase{#1}\strut}
%\vspace{1pt}
\includegraphics[width=0.9\linewidth,
height=1.9cm, % set height appropriately
keepaspectratio]{#2}
\Large #3\strut%
}
\begin{document}
\pagestyle{empty}
\renewcommand\familydefault\sfdefault
\begin{sidewaystable}
\setlength\extrarowheight{14pt}
\arrayrulecolor{gray}
\begin{tabularx}{\textwidth}{|*{8}{C|}}
\hline
% Cell 1,1
\DoCell{A}{image11}{\red{A}RBUZ}
&
% Cell 1,2
\DoCell{Ą}{image12}{W\red{Ą}Ż}
&
&
&
&
&
&
\\
\hline
%Cell 2,1
\DoCell{F}{image21}{\blue{F}ARB}
&
&
&
&
&
&
&
%Cell 2,8
\DoCell{Ł}{image28}{\blue{Ł}YŻKA}
\\
\hline
%Cell 3,1
\DoCell{M}{image31}{\blue{M}ALINA}
&
&
&
&
&
&
&
\\
\hline
%Cell 4,1
\DoCell{Ś}{image41}{\blue{Ś}LIMAK}
&
%Cell 4,2
\DoCell{T}{image42}{\blue{T}ORT}
&
&
&
&
&
&
%Cell 4,8
\DoCell{Ż}{image48}{\blue{Ż}ABA}
\\
\hline
\end{tabularx}
\end{sidewaystable}
\end{document}