我想在一页中放置 8 张图片,如下所示:
2 个区块,每个区块包含 4 张图片,其中每张图片的名称位于其下方,并且所有四张图片都有一个通用标题。
我尝试使用以下代码制作 4 张图片。但是,只有 2 张图片相邻时,它才有效。
\documentclass[a4paper, 10pt]{article}
\usepackage{graphicx}
\usepackage{subfig}
\begin{figure}[htbp]
\centering
\subfloat[1]{{\includegraphics[width=5cm]{fig1}}}
\qquad
\subfloat[2]{{\includegraphics[width=5cm]{fig2}}}
\\
\subfloat[3]{{\includegraphics[width=5cm]{fig3}}}
\qquad
\subfloat[4]{{\includegraphics[width=5cm]{fig4}}}
\caption{graphs}%
\end{figure}
谢谢。
答案1
使用该subfig
包,我个人建议使用以下示例:
\documentclass[a4paper, 10pt]{article}
\usepackage{graphicx}
\usepackage{subfig}
\begin{document}
\begin{figure}[htbp]
\centering
\subfloat[1]{{\includegraphics[width=0.22\textwidth]{example-image-a}}}
\hfill
\subfloat[2]{{\includegraphics[width=0.22\textwidth]{example-image-a}}}
\hfill
\subfloat[3]{{\includegraphics[width=0.22\textwidth]{example-image-a}}}
\hfill
\subfloat[4]{{\includegraphics[width=0.22\textwidth]{example-image-a}}}
\subfloat[1]{{\includegraphics[width=0.22\textwidth]{example-image-a}}}
\hfill
\subfloat[2]{{\includegraphics[width=0.22\textwidth]{example-image-a}}}
\hfill
\subfloat[3]{{\includegraphics[width=0.22\textwidth]{example-image-a}}}
\hfill
\subfloat[4]{{\includegraphics[width=0.22\textwidth]{example-image-a}}}
\caption{graphs}%
\end{figure}
\end{document}
我已将每幅图像的宽度指定为文本宽度的 22%。这样,即使边距发生变化,图像仍然适合。\hfill
相邻图像之间的间距确保图像水平均匀分布在整个文本宽度上。
更新
根据评论中的要求,此更新包括一个 MWE,以 2 列 4 行(而不是 4 列 2 行)显示图像。
\documentclass[a4paper, 10pt]{article}
\usepackage{graphicx}
\usepackage{subfig}
\begin{document}
\begin{figure}[htbp]
\centering
\subfloat[1]{{\includegraphics[width=0.45\textwidth]{example-image-a}}}
\hfill
\subfloat[2]{{\includegraphics[width=0.45\textwidth]{example-image-a}}}
\subfloat[3]{{\includegraphics[width=0.45\textwidth]{example-image-a}}}
\hfill
\subfloat[4]{{\includegraphics[width=0.45\textwidth]{example-image-a}}}
\subfloat[1]{{\includegraphics[width=0.45\textwidth]{example-image-a}}}
\hfill
\subfloat[2]{{\includegraphics[width=0.45\textwidth]{example-image-a}}}
\subfloat[3]{{\includegraphics[width=0.45\textwidth]{example-image-a}}}
\hfill
\subfloat[4]{{\includegraphics[width=0.45\textwidth]{example-image-a}}}
\caption{graphs}%
\end{figure}
\end{document}
答案2
尝试下面提到的代码。
\documentclass[10pt,a4paper,twoside,onecolumn]{article}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{subfig}
\begin{document}
\begin{figure*}
\mbox{\subfloat[]{\label{subfig:1} \includegraphics[height=2.3cm]{example-image-a}}}
\mbox{\subfloat[]{\label{subfig:2} \includegraphics[height=2.3cm]{example-image-b}}}
\mbox{\subfloat[]{\label{subfig:3} \includegraphics[height=2.3cm]{example-image-c}}}
\mbox{\subfloat[]{\label{subfig:4} \includegraphics[height=2.3cm]{example-image-b}}}
\mbox{\subfloat[]{\label{5} \includegraphics[height=2.3cm]{example-image-b}}}
\mbox{\subfloat[]{\label{6} \includegraphics[height=2.3cm]{example-image-c}}}
\mbox{\subfloat[]{\label{7} \includegraphics[height=2.3cm]{example-image-b}}}
\mbox{\subfloat[]{\label{8} \includegraphics[height=2.3cm]{example-image-b}}}
\mbox{\subfloat[]{\label{9} \includegraphics[height=2.3cm]{example-image-a}}}
\mbox{\subfloat[]{\label{10} \includegraphics[height=2.3cm]{example-image-b}}}
\mbox{\subfloat[]{\label{11} \includegraphics[height=2.3cm]{example-image-c}}}
\mbox{\subfloat[]{\label{12} \includegraphics[height=2.3cm]{example-image-b}}}
\mbox{\subfloat[]{\label{13} \includegraphics[height=2.3cm]{example-image-b}}}
\caption{Normal Models. \protect\subref{subfig:1} SLR. \protect\subref{subfig:2} MLR. \protect\subref{subfig:3} SWR. \protect\subref{subfig:4} OLS. \protect\subref{5} OLS. \protect\subref{6} OS. \protect\subref{7} Ok. \protect\subref{8} hi. \protect\subref{9} hey. \protect\subref{10} MSD. \protect\subref{11} LPY. \protect\subref{12} MSY. \protect\subref{13} Hello.}
\label{f45}
\end{figure*}
\end{document}