![如何并排创建两个 2x2 图像](https://linux22.com/image/460537/%E5%A6%82%E4%BD%95%E5%B9%B6%E6%8E%92%E5%88%9B%E5%BB%BA%E4%B8%A4%E4%B8%AA%202x2%20%E5%9B%BE%E5%83%8F.png)
我想要将 2 张 2x2 的图像并排放置。
| image1 | image2 | | image5 | image6 |
-------- -------- ------- -------
| image3 | image4 | | image7 | image8 |
-------- -------- ------- -------
label:class1 label:class2
Fig: image dataset
这是我编写的代码。我无法将 class2 标签图像放置在 class1 标签图像的右侧。
\begin{figure}
\begin{minipage}[t][6cm]{0.3\linewidth}
{\includegraphics[width=3cm,height=3cm]{img}}
\hspace{0.1 cm}
{\includegraphics[width=3cm,height=3cm]{img}}
\vspace{0.1 cm}
\end{minipage}%
\begin{minipage}[t][6cm]{0.3\linewidth}
{\includegraphics[width=3cm,height=3cm]{img}}
\hspace{0.1 cm}
{\includegraphics[width=3cm,height=3cm]{img}}
\vspace{0.1 cm}
\end{minipage}%
\begin{minipage}[t][6cm]{0.3\linewidth}
{\includegraphics[width=3cm,height=3cm]{img}}
\end{minipage}%
\begin{minipage}[t][6cm]{0.3\linewidth}
{\includegraphics[width=3cm,height=3cm]{img}}
\end{minipage}
\begin{minipage}[t][6cm]{0.3\linewidth}
{\includegraphics[width=3cm,height=3cm]{img}}
\end{minipage}%
\begin{minipage}[t][6cm]{0.3\linewidth}
{\includegraphics[width=3cm,height=3cm]{img}}
\end{minipage}
\caption{Many figures}\label{foo}
\end{figure}
答案1
欢迎来到 TeX:SE!
像这样:
\documentclass{article}
\usepackage{geometry}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\begin{document}
\begin{figure}[ht]
\setkeys{Gin}{width=3cm,height=3cm}
\centering
\begin{subfigure}[t]{0.48\linewidth}
\centering
\includegraphics{img}
\hfil
\includegraphics{img}
\medskip
\includegraphics{img}
\hfil
\includegraphics{img}
\caption{class 1}
\end{subfigure}%
\hfil
\begin{subfigure}[t]{0.48\linewidth}
\centering
\includegraphics{img}
\hfil
\includegraphics{img}
\medskip
\includegraphics{img}
\hfil
\includegraphics{img}
\caption{class 2}
\end{subfigure}%
\caption{Many figures}
\label{foo}
\end{figure}
\end{document}
(红线表示文档页面布局)