我怎样才能让它看起来像这样:
(我用油漆制作的。)
代码
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\centering
\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
\caption{1}
\end{subfigure}
\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
\caption{2}
\label{}
\end{subfigure}
\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
\caption{3}
\end{subfigure}
\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
\caption{4}
\label{}
\end{subfigure}
\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
\caption{5}
\label{}
\end{subfigure}
\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
\caption{6}
\label{}
\end{subfigure}
\begin{subfigure}[b]{0.05\textwidth}
\includegraphics[height=0.35\textheight]{./dct_for_publication_no_legend/legend}
\end{subfigure}
\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
\caption{7}
\label{}
\end{subfigure}
\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
\caption{8}
\label{}
\end{subfigure}
\caption{Pictures}\label{}
\end{figure}
\end{document}
答案1
您可以将子图设置为minipage
\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{showframe} % just for the example
\begin{document}
\begin{figure}[p]
\begin{minipage}{0.9\textwidth}
\centering
\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[width=\textwidth]{example-image}
\caption{1}\label{1}
\end{subfigure}\hspace*{\fill}
\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[width=\textwidth]{example-image}
\caption{2}\label{2}
\end{subfigure}\hspace*{\fill}
\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[width=\textwidth]{example-image}
\caption{3}\label{3}
\end{subfigure}\hspace*{\fill}
\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[width=\textwidth]{example-image}
\caption{4}\label{4}
\end{subfigure}\hspace*{\fill}
\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[width=\textwidth]{example-image}
\caption{5}\label{5}
\end{subfigure}\hspace*{\fill}
\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[width=\textwidth]{example-image}
\caption{6}\label{6}
\end{subfigure}\hspace*{\fill}
\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[width=\textwidth]{example-image}
\caption{7}\label{7}
\end{subfigure}\hspace*{\fill}
\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[width=\textwidth]{example-image}
\caption{8}\label{8}
\end{subfigure}\hspace*{\fill}
\end{minipage}% <--- don't forget
\begin{minipage}{0.1\textwidth}
\includegraphics[width=\textwidth,height=8cm]{example-image}
\end{minipage}
\caption{Global caption}\label{global}
\end{figure}
\end{document}
该showframe
包仅用于显示相对于文本块的位置。
答案2
我尝试保持图像的大小不变,但改变间距。请注意, 会minipage
改变 的值\textwidth
,因此使用\mywidth
。
由于实际图像顶部有很多空白,因此子标题应该放置在适当的位置。
请注意,图例相对于图像及其标题居中。这可以修复,但您需要测量不带标题的图像的高度。
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{subcaption}
\usepackage{showframe}% dubugging tool
\newlength{\mywidth}
\begin{document}
\begin{figure}
\mywidth=0.45\textwidth
\begin{subfigure}[b]{\mywidth}
\includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
\caption{1}
\end{subfigure}\hfil
\begin{subfigure}[b]{\mywidth}
\includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
\caption{2}
%\label{}
\end{subfigure}
\begin{minipage}[c]{.925\textwidth}
\begin{subfigure}[b]{\mywidth}
\includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
\caption{3}
\end{subfigure}\hfill
\begin{subfigure}[b]{\mywidth}
\includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
\caption{4}
%\label{}
\end{subfigure}
\begin{subfigure}[b]{\mywidth}
\includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
\caption{5}
%\label{}
\end{subfigure}\hfill
\begin{subfigure}[b]{\mywidth}
\includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
\caption{6}
%\label{}
\end{subfigure}
\end{minipage}\hfill
\raisebox{-0.5\height}{\includegraphics[height=0.35\textheight,width=0.05\textwidth]{./dct_for_publication_no_legend/legend}}
\begin{subfigure}[b]{\mywidth}
\includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
\caption{7}
%\label{}
\end{subfigure}\hfil
\begin{subfigure}[b]{\mywidth}
\includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
\caption{8}
%\label{}
\end{subfigure}
\caption{Pictures}\label{}
\end{figure}
\end{document}
此版本计算宽度以\columnsep
在图像之间留出间隙并使用图例的自然宽度。当然,在演示模式下看起来很糟糕。
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{subcaption}
\usepackage{showframe}% dubugging tool
\newlength{\mywidth}
\begin{document}
\begin{figure}
\sbox0{\includegraphics[height=0.35\textheight]{./dct_for_publication_no_legend/legend}}%
\setlength{\mywidth}{\dimexpr 0.5\textwidth-\columnsep-0.5\wd0}%
\begin{subfigure}[b]{\mywidth}
\includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
\caption{1}
\end{subfigure}\hfil
\begin{subfigure}[b]{\mywidth}
\includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
\caption{2}
%\label{}
\end{subfigure}
\begin{minipage}[c]{\dimexpr \textwidth-\columnsep-\wd0}
\begin{subfigure}[b]{\mywidth}
\includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
\caption{3}
\end{subfigure}\hfill
\begin{subfigure}[b]{\mywidth}
\includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
\caption{4}
%\label{}
\end{subfigure}
\begin{subfigure}[b]{\mywidth}
\includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
\caption{5}
%\label{}
\end{subfigure}\hfill
\begin{subfigure}[b]{\mywidth}
\includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
\caption{6}
%\label{}
\end{subfigure}
\end{minipage}\hfill
\raisebox{-0.5\ht0}{\usebox0}
\begin{subfigure}[b]{\mywidth}
\includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
\caption{7}
%\label{}
\end{subfigure}\hfil
\begin{subfigure}[b]{\mywidth}
\includegraphics[width=\textwidth]{./dct_for_publication_no_legend/ACTA2}
\caption{8}
%\label{}
\end{subfigure}
\caption{Pictures}\label{}
\end{figure}
\end{document}