未给出图形标题时删除多余的垂直空间

未给出图形标题时删除多余的垂直空间

我想知道如何删除表格标题(以红色突出显示)后留下的空间?我使用了以下示例:https://latex.org/forum/viewtopic.php?t=1279

\documentclass{article}
\usepackage[belowskip=-15pt,aboveskip=0pt]{caption}

\setlength{\intextsep}{10pt plus 2pt minus 2pt}

\begin{document}

text text text text text text text text text text text text text text text text text text text text text text text text text text
\begin{figure}[!ht]
  \centering
  \fbox{Test figure 2}
\end{figure}
text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text 

\end{document}

在此处输入图片描述

答案1

简而言之:例如添加一些负垂直空间\vspace{-<lenght>}

浮动(图形和表格)在环境前后添加空间。长度\intextsep控制此类空间。(示例 1 和 2)

在示例 3 中,标题上方和下方的空格经过调整以挤压标题,使用belowskip和抑制多余的空格aboveskip

在最后一个例子中,一个没有标题的图形,使用以下方法抑制了多余的空间\vspace{-1em}

浮动的垂直间距

C

\documentclass[10pt]{article}
\usepackage{caption}

\setlength{\intextsep}{10pt plus 2pt minus 2pt} % Space above and below  text floats. Default 12pt plus 2pt minus 2pt for a 10pt document

\begin{document}
text text text text text text text text text text text text text text text text text text text text text text text text text text

\begin{figure}[!ht]
    \centering
    \fbox{Test figure and caption (1)}
    \caption{Normal caption}
\end{figure}
text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text

\begin{figure}[!ht]
    \centering
    \fbox{Test figure no caption (2)}
\end{figure}
text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text 

\begin{figure}[!ht]
    \centering
    \fbox{Test figure with a squeezed caption (3)}
    \captionsetup{belowskip=-14pt,aboveskip=3pt}
    \caption{Squeezed caption}
\end{figure}
text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text 

\begin{figure}[!ht]
    \centering
    \fbox{Test figure no caption \& vspace (4)}
    \vspace{-1em}% added <<<<<<<<<<<<<<<<
\end{figure}
text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text 

\end{document}

相关内容