如何减少标签后的空间?

如何减少标签后的空间?

我想减少子图中标签和标题之间的空间。

\usepackage{caption}
\usepackage{subcaption}
\renewcommand\thesubfigure{\Alph{subfigure}}
\begin{figure}
 \centering
 \begin{subfigure}[t]{.2\linewidth}
  \centering
  \includegraphics[width = \linewidth]{example-image-a}
  \caption{ABCDEFGHIJK}
 \end{subfigure}%
 \hspace{6em}% Space between image A and B
 \begin{subfigure}[t]{0.19\linewidth}
 \centering
  \includegraphics[width = \linewidth]{example-image-b}
  \caption{ABCDEFGHIJK}
  \end{subfigure}%
 \caption{Example images for the different group in Chest X-ray dataset.}
\end{figure}

结果

答案1

尝试:

\documentclass{article}
\usepackage{graphicx}  
\usepackage[skip=1ex]{caption}   % <---
\usepackage{subcaption}
\renewcommand\thesubfigure{\Alph{subfigure}}

\begin{document}
    \begin{figure}[ht]
 \centering
\setkeys{Gin}{width = \linewidth}
\begin{subfigure}[t]{.2\linewidth}
\includegraphics{example-image-a}
\caption{ABC DEF GHIJK}
\end{subfigure}
    \hfill
\begin{subfigure}[t]{0.19\linewidth}
  \includegraphics{example-image-b}
  \caption{ABC DEFG HIJK}
\end{subfigure}
\caption{Example images for the different group in Chest X-ray dataset.}
    \end{figure}
\end{document}

在此处输入图片描述

如果你不喜欢这个全局设置,你可以针对这个图在本地进行设置:

\documentclass{article}
\usepackage{graphicx}  
\usepackage{caption}
\usepackage{subcaption}
\renewcommand\thesubfigure{\Alph{subfigure}}

\begin{document}
    \begin{figure}[ht]
 \centering
\setkeys{Gin}{width = \linewidth}
\captionsetup{skip=1ex}    % <---
\begin{subfigure}[t]{.2\linewidth}
\includegraphics{example-image-a}
\caption{ABC DEF GHIJK}
\end{subfigure}
    \hfil
\begin{subfigure}[t]{0.19\linewidth}
  \includegraphics{example-image-b}
  \caption{ABC DEFG HIJK}
\end{subfigure}
\caption{Example images for the different group in Chest X-ray dataset.}
    \end{figure}
\end{document}

为了获得更小的垂直距离,请减小skip尺寸。

编辑:
从您的评论中可以看出,您似乎希望标题标签和其文本之间的间距更小。如果您不需要标题中的文本对齐,即标题中的文本可以在右侧不对齐,则可以实现这一点:

\usepackage{ragged2e}
\usepackage{caption}
\usepackage[justification=RaggedRight]{subcaption}

或者

\usepackage{caption}
\usepackage[justification=raggedright]{subcaption}

在您的特定标题文本情况下,您将获得相同的结果(因为文本不是自然的,因此单词连字无法正常工作):

在此处输入图片描述

完成 MWE:

\documentclass{article}
\usepackage{graphicx}
\usepackage{ragged2e}
\usepackage{caption}
\usepackage[justification=RaggedRight]{subcaption}
\renewcommand\thesubfigure{\Alph{subfigure}}

\begin{document}
    \begin{figure}[ht]
 \centering
\setkeys{Gin}{width = \linewidth}
\captionsetup{skip=1ex}    % <---
\begin{subfigure}[t]{.2\linewidth}
\includegraphics{example-image-a}
\caption{ABC DEF GHIJK}
\end{subfigure}
    \hfil
\begin{subfigure}[t]{0.19\linewidth}
  \includegraphics{example-image-b}
  \caption{ABC DEFG HIJK}
\end{subfigure}
\caption{Example images for the different group in Chest X-ray dataset.}
    \end{figure}
\end{document}

附录:为了将子标题保持在一行,请使subfigure环境更大。例如:

\documentclass{article}
\usepackage{graphicx}
\usepackage[skip=1ex]{caption}   % <---
\usepackage{subcaption}
\renewcommand\thesubfigure{\Alph{subfigure}}

\begin{document}
    \begin{figure}[ht]
 \centering
\setkeys{Gin}{width = \linewidth}
\begin{subfigure}[t]{.3\linewidth}
\includegraphics{example-image-a}
\caption{ABC DEF GHIJK}
\end{subfigure}
    \hfil
\begin{subfigure}[t]{0.3\linewidth}
  \includegraphics{example-image-b}
  \caption{ABC DEFG HIJK}
\end{subfigure}
\caption{Example images for the different group in Chest X-ray dataset.}
    \end{figure}

    \begin{figure}[ht]
 \centering
\begin{subfigure}[t]{.3\linewidth}
    \centering
\includegraphics[width=0.66\linewidth]{example-image-a}
\caption{ABC DEF GHIJK}
\end{subfigure}
    \hfil
\begin{subfigure}[t]{0.3\linewidth}
    \centering
  \includegraphics[width=0.66\linewidth]{example-image-b}
  \caption{ABC DEFG HIJK}
\end{subfigure}
\caption{Example images for the different group in Chest X-ray dataset.}
    \end{figure}
\end{document}

在此处输入图片描述

相关内容