更改子浮点间距

更改子浮点间距

\intextsep我尝试通过设置为 来消除 [H] 数字周围的间距0pt,但遗憾的是这并没有改变子浮点数周围的间距。

有没有办法做到这一点(除了手动添加负数\vspace)?

\documentclass{article}
\usepackage{showframe}
\usepackage{subfig}
\usepackage[demo]{graphicx}
\usepackage{float}

% remove spacing around H figures
\setlength{\intextsep}{0pt}

\begin{document}
  Sample text.

  % REMOVE THIS SPACING!

  \begin{figure}[H]
    \subfloat[Sample caption.]{\fbox{\includegraphics[width=.475\linewidth]{1.png}}}%
    \hfill
    \subfloat[Sample caption.]{\fbox{\includegraphics[width=.475\linewidth]{2.png}}}%
  \end{figure}

  Sample text.

  \begin{figure}[H]
    \minipage{0.475\textwidth}
      \includegraphics[width=\linewidth]{3.png}
    \endminipage\hfill
     \minipage{0.475\textwidth}
      \includegraphics[width=\linewidth]{4.png}
    \endminipage
  \end{figure}

  Sample text.
\end{document}

在此处输入图片描述

答案1

看来,使用subcaption而不是subfig包就可以达到目的。

\documentclass{article}
\usepackage{showframe}
\usepackage{subcaption}
\usepackage[demo]{graphicx}
\usepackage{float}

% remove spacing around H figures
\setlength{\intextsep}{0pt}

\begin{document}
  Sample text.

  \begin{figure}[H]
    \begin{subfigure}{0.475\textwidth}
      \includegraphics[width=\linewidth]{3.png}
      \caption{Sample caption.}
    \end{subfigure}\hfill
    \begin{subfigure}{0.475\textwidth}
      \includegraphics[width=\linewidth]{4.png}
      \caption{Sample caption.}
    \end{subfigure}
  \end{figure}

  Sample text.

  \begin{figure}[H]
    \minipage{0.475\textwidth}
      \includegraphics[width=\linewidth]{3.png}
    \endminipage\hfill
     \minipage{0.475\textwidth}
      \includegraphics[width=\linewidth]{4.png}
    \endminipage
  \end{figure}

  Sample text.
\end{document}

相关内容