答案1
使用subfig
包的解决方案:
\documentclass{article}
\usepackage{graphicx}
\usepackage{subfig}
\usepackage{lipsum}
\begin{document}
\begin{figure}[!ht]
\centering
\subfloat[]{\includegraphics[width=0.45\linewidth]{example-image-a}}
\hfil
\subfloat[]{\includegraphics[width=0.45\linewidth]{example-image-b}}
\subfloat[]{\includegraphics[width=0.45\linewidth]{example-image-a}}
\hfil
\subfloat[]{\includegraphics[width=0.45\linewidth]{example-image-b}}
\subfloat[]{\includegraphics[width=0.45\linewidth]{example-image-a}}
\hfil
\subfloat[]{\includegraphics[width=0.45\linewidth]{example-image-b}}
\caption{2 x 3 grid of images}
\label{fig:my figure}
\end{figure}
\lipsum[11]
\end{document}
使用subcaption
包的解决方案:
\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{lipsum}
\begin{document}
\begin{figure}[!ht]
\centering
\begin{subfigure}{0.45\linewidth}
\includegraphics[width=\linewidth]{example-image-a}
\caption{}
\end{subfigure}
\hfil
\begin{subfigure}{0.45\linewidth}
\includegraphics[width=\linewidth]{example-image-b}
\caption{}
\end{subfigure}
\begin{subfigure}{0.45\linewidth}
\includegraphics[width=\linewidth]{example-image-a}
\caption{}
\end{subfigure}
\hfil
\begin{subfigure}{0.45\linewidth}
\includegraphics[width=\linewidth]{example-image-b}
\caption{}
\end{subfigure}
\begin{subfigure}{0.45\linewidth}
\includegraphics[width=\linewidth]{example-image-a}
\caption{}
\end{subfigure}
\hfil
\begin{subfigure}{0.45\linewidth}
\includegraphics[width=\linewidth]{example-image-b}
\caption{}
\end{subfigure}
\caption{2 x 3 grid of images}
\label{fig:my figure}
\end{figure}
\lipsum[11]
\end{document}
两种解决方案都得出相同的结果:
如果您希望按列的顺序对子图进行编号,那么最简单的解决方案就是在表格中封闭子图或子浮点数:
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{subcaption}
\usepackage{tabularx}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\usepackage{lipsum}
\begin{document}
\begin{figure}[!ht]
\begin{tabularx}{\linewidth}{CC}
\begin{subfigure}{\linewidth}
\includegraphics[width=\linewidth]{example-image-a}
\caption{}
\end{subfigure}
\begin{subfigure}{\linewidth}
\includegraphics[width=\linewidth]{example-image-b}
\caption{}
\end{subfigure}
\begin{subfigure}{\linewidth}
\includegraphics[width=\linewidth]{example-image-c}
\caption{}
\end{subfigure}
&
\begin{subfigure}{\linewidth}
\includegraphics[width=\linewidth]{example-image-a}
\caption{}
\end{subfigure}
\begin{subfigure}{\linewidth}
\includegraphics[width=\linewidth]{example-image-b}
\caption{}
\end{subfigure}
\begin{subfigure}{\linewidth}
\includegraphics[width=\linewidth]{example-image-c}
\end{subfigure}
\end{tabularx}
\caption{2 x 3 grid of images}
\label{fig:my figure}
\end{figure}
\lipsum[11]
\end{document}