我正在寻找一种方法,将多幅图像平铺到 LaTeX 中的单个图形中。
我目前有下面的代码,当图像很好地适合网格时,它可以工作
\documentclass[11pt]{article}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{overpic}
\usepackage{xcolor}
\DeclareCaptionLabelFormat{bold}{\textbf{(#2)}}
\captionsetup{subrefformat=bold}
\renewcommand{\thesubfigure}{\Alph{subfigure}}
\begin{document}
% Sub-Figure Example
\begin{figure}[!htp]
\centering
\captionsetup{width=.9\textwidth}
% Figure row 1
\begin{subfigure}{0.3\textwidth}
\centering
\begin{overpic}[percent,width=\textwidth]{coffee.jpg}
\put (5,40) {\color{white} A}
\end{overpic}
\phantomsubcaption\label{fig:a}
\end{subfigure}%
\begin{subfigure}{0.3\textwidth}
\centering
\begin{overpic}[percent,width=\textwidth]{coffee.jpg}
\put (5,40) {\color{white} B}
\end{overpic}
\phantomsubcaption\label{fig:b}
\end{subfigure}%
\begin{subfigure}{0.3\textwidth}
\centering
\begin{overpic}[percent,width=\textwidth]{coffee.jpg}
\put (5,40) {\color{white} C}
\end{overpic}
\phantomsubcaption\label{fig:c}
\end{subfigure}
\vspace{-\baselineskip}
\begin{subfigure}{0.9\textwidth}
\centering
\begin{overpic}[percent,width=\textwidth]{coffee.jpg}
\put (1.5,48) {\color{white} D}
\end{overpic}
\phantomsubcaption\label{fig:d}
\end{subfigure}
\vspace{-\baselineskip}
\caption{This is a figure. \subref{fig:a} This is a cup of coffee.
\subref{fig:b} This is another cup of coffee. \subref{fig:c} This is more coffee.
\subref{fig:d} This is a big cup of coffee.}
\label{fig:coffee3}
\end{figure}
\end{document}
然而,当图像需要跨列时,这似乎不起作用。例如当一张或多张图像的方向不同时。它还假设所有图像都具有相同的纵横比。
例如
\documentclass[11pt]{article}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{overpic}
\usepackage{xcolor}
\DeclareCaptionLabelFormat{bold}{\textbf{(#2)}}
\captionsetup{subrefformat=bold}
\renewcommand{\thesubfigure}{\Alph{subfigure}}
\begin{document}
% Sub-Figure Example
\begin{figure}[!htp]
\centering
\captionsetup{width=.9\textwidth}
% Figure row 1
\begin{subfigure}{0.3\textwidth}
\centering
\begin{overpic}[abs,unit=1mm,width=\textwidth]{example-image}
\put (3,23) {\color{white} A}
\end{overpic}
\phantomsubcaption\label{fig:a}
\end{subfigure}%
\begin{subfigure}{0.3\textwidth}
\centering
\begin{overpic}[abs,unit=1mm,width=\textwidth]{example-image}
\put (3,23) {\color{white} B}
\end{overpic}
\phantomsubcaption\label{fig:b}
\end{subfigure}%
\begin{subfigure}{0.3\textwidth}
\centering
\begin{overpic}[abs,unit=1mm,width=\textwidth,angle=90]{example-image}
\put (3,23) {\color{white} C}
\end{overpic}
\phantomsubcaption\label{fig:c}
\end{subfigure}
\vspace{-\baselineskip}
\begin{subfigure}{0.9\textwidth}
\centering
\begin{overpic}[abs,unit=1mm,width=\textwidth]{example-image}
\put (3,80) {\color{white} D}
\end{overpic}
\phantomsubcaption\label{fig:d}
\end{subfigure}
\vspace{-\baselineskip}
\caption{This is a figure caption \subref{fig:a} This is a subfigure.
\subref{fig:b} This is another subfigure. \subref{fig:c} This is yet another subfigure.
\subref{fig:d} This is a big subfigure.}
\label{fig:coffee3}
\end{figure}
\end{document}