子图标题看起来太近了

子图标题看起来太近了

有什么方法可以避免出现下面观察到的子图标题过于靠近的情况?

我宁愿不使用 minipage 环境作为解决方案。

\documentclass[]{article}
\usepackage{graphicx}

\usepackage{caption}

\usepackage{subcaption}
\usepackage{subfig}


\begin{document}

\begin{figure}[h!]
  \begin{subfigure}[t]{.5\textwidth}
  \centering
    \includegraphics[width=50mm]{image1.png}
    \caption{Test 1 - text filling out page so it is possible to view the how close the text regions get. I will keep going to show that in the second line.}
  \end{subfigure}%
  \begin{subfigure}[t]{.5\textwidth}
  \centering
    \includegraphics[width=50mm]{image2.png}
    \caption{Test 2 - text filling out page so it is possible to view the how close the text regions get}
  \end{subfigure}
  \caption{Full caption}
\end{figure}

\end{document}

在此处输入图片描述

答案1

只需使用较短的宽度即可subfigure

\documentclass[]{article}
\usepackage[demo]{graphicx} % demo is just for the example

\usepackage{caption}

\usepackage{subcaption}


\begin{document}

\begin{figure}[h!]
  \begin{subfigure}[t]{.45\textwidth}
  \centering
    \includegraphics[width=.9\textwidth]{image1.png}
    \caption{Test 1 - text filling out page so it is possible to view the how close the text regions get. I will keep going to show that in the second line.}
  \end{subfigure}\hfill
  \begin{subfigure}[t]{.45\textwidth}
  \centering
    \includegraphics[width=.9\textwidth]{image2.png}
    \caption{Test 2 - text filling out page so it is possible to view the how close the text regions get}
  \end{subfigure}
  \caption{Full caption}
\end{figure}

\end{document}

不要subfig与 一起加载subcaption。另外,指定 50mm 这样的固定宽度也不好,因为您可能会超出 的宽度subfigure

在此处输入图片描述

答案2

\captionsetup您可以使用在文档序言中执行的命令来更改子标题的样式。

要更改标题的宽度,可以使用参数宽度,如下所示(占子图宽度的 90%)。

 \captionsetup[subfigure]{width=0.9\textwidth}

将此命令包含在文档的序言中。

请注意,它会改变整个文档中子标题的样式。您还可以尝试其他几个有用的参数(例如marginindent有关更多信息,请参阅 subfig 包文档http://ctan.org/pkg/subfig,第 3.1.2 节)。

问候。

答案3

您可以使用包\subcaptionbox中的命令subcaptionhttp://ctan.mirrorcatalogs.com/macros/latex/contrib/caption/subcaption.pdf

\documentclass[]{article}
\usepackage{graphicx}

\usepackage{caption}

\usepackage{subcaption}
%\usepackage{subfig}


\begin{document}

\begin{figure}[h!]
\captionsetup[subfigure]{position=top} %if you want to change the position of the subcaption; default is bottom.
    \subcaptionbox{Test 1 - text filling out page so it is possible to view the how close the text regions get. I will keep going to show that in the second line.\label{subfig-1}}{\includegraphics[width=50mm]{image1.png}}
    \hfill
    %\hspace{1cm}
    \subcaptionbox{Test 2 - text filling out page so it is possible to view the how close the text regions get\label{subfig-b}}{\includegraphics[width=50mm]{image2.png}}
  \caption{Full caption}
\end{figure}

\end{document}

答案4

原始代码的较短版本。仅使用包\subfloat中的代码\subfig

\documentclass[draft]{article}

\usepackage{graphicx}
\usepackage{subfig}

\begin{document}
\begin{figure}[h!]
    \centering
    \subfloat[Test 1 - text filling out page so it is possible to view the how close the text regions get. I will keep going to show that in the second line.]
        {
            \includegraphics[width=.45\textwidth]{testing.png}
        }
    \qquad
    \subfloat[Test 2 - text filling out page so it is possible to view the how close the text regions get]
        {
            \includegraphics[width=.45\textwidth]{testing.png}
        }
  \caption{Full caption}
\end{figure}
\end{document}

结果:

在此处输入图片描述

相关内容