子图之间的垂直空间不同

子图之间的垂直空间不同

我正在尝试添加如下所示的子图组,LaTex 正在跟踪。但是,第二个标题比其他标题低一点。我该如何修复它?

\documentclass[twocolumn]{article}
\usepackage[demo]{graphicx}
\usepackage{subcaption}

\begin{document}
\begin{figure*}
\centering
\captionsetup[subfigure]{labelformat=empty}
\begin{subfigure}[b]{.16\linewidth}
\includegraphics[width=\linewidth]{figure/a_1.png}
\end{subfigure}
\begin{subfigure}[b]{.16\linewidth}
\includegraphics[width=\linewidth]{figure/a_2.png}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.16\linewidth}
\includegraphics[width=\linewidth]{figure/b_1.png}
\end{subfigure}
\begin{subfigure}[b]{.16\linewidth}
\includegraphics[width=\linewidth]{figure/b_2.png}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.16\linewidth}
\includegraphics[width=\linewidth]{figure/c_1.png}
\end{subfigure}
\begin{subfigure}[b]{.16\linewidth}
\includegraphics[width=\linewidth]{figure/c_2.png}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.16\linewidth}
\includegraphics[width=\linewidth]{figure/a_3.png}
\end{subfigure}
\begin{subfigure}[b]{.16\linewidth}
\includegraphics[width=\linewidth]{figure/a_4.png}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.16\linewidth}
\includegraphics[width=\linewidth]{figure/b_3.png}
\end{subfigure}
\begin{subfigure}[b]{.16\linewidth}
\includegraphics[width=\linewidth]{figure/b_4.png}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.16\linewidth}
\includegraphics[width=\linewidth]{figure/c_3.png}
\end{subfigure}
\begin{subfigure}[b]{.16\linewidth}
\includegraphics[width=\linewidth]{figure/c_4.png}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.32\linewidth}
\small \textbf{Easy} [no duplicate]\\
\scriptsize
blah1\\
\end{subfigure}
\hfill
\begin{subfigure}[b]{.32\linewidth}
\small \textbf{Middle} [two duplicate]\\
\scriptsize
blah2\\
\end{subfigure}
\hfill
\begin{subfigure}[b]{.32\linewidth}
\small \textbf{Hard} [three duplicate]\\
\scriptsize
blah3
\end{subfigure}
\caption{sample1}
  \label{fig:3}
\end{figure*}
\end{document}

sample1

答案1

为了快速解决您遇到的问题,您可以将最后 3 个实例更改为\begin{subfigure}[b]\begin{subfigure}[t]更好的是,只需省略和\\之后的 (双反斜杠) 指令:它们是不需要的,而且它们会弄乱这些环境的垂直定位。blah1blah2subfigure

话虽如此,您可能需要重新考虑使用subfigure环境的整个方法。由于您没有\caption在 12+3=15 个subfigure环境中使用指令,因此您可以(实际上,应该!)subfigure用环境替换所有环境minipage。如果您不知道:subfigure环境只不过是一个minipage被告知在遇到指令时该做什么的环境\caption。既然没有这样的\caption指令,为什么要承担开销?

接下来,为什么还要使用minipage环境来封装这 12 个图像文件?这样做似乎毫无意义,因为\includegraphics可以让您直接说明图像的(相对)尺寸。

最后,由于您有 12 条\includegraphics语句,因此最好创建一个快捷宏来自动调整图像大小。

enter image description here

\documentclass[twocolumn]{article}
\usepackage[demo]{graphicx} % omit 'demo' option in real doc.
%% Handy shortcut macro:
\newcommand\inc[1]{\includegraphics%
   [width=0.15\linewidth,height=0.15\linewidth]{#1}}

\begin{document}
\begin{figure*}
%% First row of images:
\inc{figure/a_1.png}\hspace{0.005\linewidth}
\inc{figure/a_2.png}\hspace{\fill}
\inc{figure/b_1.png}\hspace{0.005\linewidth}
\inc{figure/b_2.png}\hspace{\fill}
\inc{figure/c_1.png}\hspace{0.005\linewidth}
\inc{figure/c_2.png}

\smallskip
%% Second row of images:
\inc{figure/a_3.png}\hspace{0.005\linewidth}
\inc{figure/a_4.png}\hspace{\fill}
\inc{figure/b_3.png}\hspace{0.005\linewidth}
\inc{figure/b_4.png}\hspace{\fill}
\inc{figure/c_3.png}\hspace{0.005\linewidth}
\inc{figure/c_4.png}

\smallskip
% Row of captions
\begin{minipage}{.305\linewidth}  % 0.305=2*0.15+0.005
\small\textbf{Easy} [no duplicate]

\scriptsize blah1
\end{minipage}%
\hspace{\fill}
\begin{minipage}{.305\linewidth}
\small\textbf{Middle} [two duplicate]

\scriptsize blah2
\end{minipage}%
\hspace{\fill}
\begin{minipage}{.305\linewidth}
\small\textbf{Hard} [three duplicate]

\scriptsize blah3
\end{minipage}

\caption{sample1}
\label{fig:3}
\end{figure*}
\end{document}

答案2

我会在环境中使用标题subfigure,并subfigure合并四幅图像:

\documentclass[twocolumn]{article}
\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage{subcaption}

\begin{document}
    \begin{figure*}
\captionsetup[subfigure]{labelformat=empty}
\begin{subfigure}[b]{.32\linewidth}
\includegraphics[width=0.48\linewidth]{figure/a_1.png}
\includegraphics[width=0.48\linewidth]{figure/a_2.png}

\smallskip
\includegraphics[width=0.48\linewidth]{figure/a_3.png}
\includegraphics[width=0.48\linewidth]{figure/a_4.png}
    \caption{\textbf{Easy} [no duplicate]\newline\scriptsize
             blah1}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.32\linewidth}
\includegraphics[width=0.48\linewidth]{figure/b_1.png}
\includegraphics[width=0.48\linewidth]{figure/b_2.png}

\smallskip
\includegraphics[width=0.48\linewidth]{figure/b_3.png}
\includegraphics[width=0.48\linewidth]{figure/b_4.png}
    \caption{\textbf{Middle} [two duplicate]\newline\scriptsize
             blah1}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.32\linewidth}
\includegraphics[width=0.48\linewidth]{figure/c_1.png}
\includegraphics[width=0.48\linewidth]{figure/c_2.png}

\smallskip
\includegraphics[width=0.48\linewidth]{figure/c_3.png}
\includegraphics[width=0.48\linewidth]{figure/c_4.png}
    \caption{\textbf{Hard} [three duplicate]\newline\scriptsize
             blah1}
\end{subfigure}
\caption{sample1}
  \label{fig:3}
    \end{figure*}
\end{document}

enter image description here

相关内容