更改子浮動間距

更改子浮動間距

\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}

相關內容