如何使图形标题和文本之间的垂直间距相等 \baselineskip

如何使图形标题和文本之间的垂直间距相等 \baselineskip

我的代码:

\documentclass[12pt]{scrreprt}

\usepackage{float}
\floatplacement{figure}{H}
\floatplacement{table}{H}

\usepackage{graphicx}
\usepackage{array}
\usepackage{tabularx}

\RequirePackage
[
    skip=0pt,
    format=plain,
    labelsep=endash,
    singlelinecheck=false,
]{caption}
\captionsetup[figure]{singlelinecheck=true}

\AtBeginDocument{
    \setlength\floatsep{0pt}
    \setlength\textfloatsep{0pt}
    \setlength\intextsep{0pt}
}

\begin{document}
Text text Text text Text text Text textText text Text textText text Text textText text Text textText text Text textText text Text textText text Text textText text Text text
\begin{figure}
    \centering
    \includegraphics[width=\linewidth]{image}
    \caption{figure}
\end{figure}
Text text Text text Text text Text textText text Text textText text Text textText text Text textText text Text textText text Text textText text Text textText text Text text
\begin{table}
    \caption{table}
    \begin{tabularx}{\linewidth}{|X|X|}
        \hline
        Text & Text \\
        \hline
    \end{tabularx}
\end{table}
\end{document}

在此处输入图片描述

我在图形标题下方获得了额外的垂直空间。我想删除它。如何实现?此外,这是次要的,但我想知道如何删除表格和其标题之间的间距。

请不要注意表格的标题与文本相撞,此代码仅用于演示烦人的额外空间。

答案1

对于我的第一个回答,我深表歉意——我误解了您的问题。

那这个呢:

\documentclass[12pt]{scrreprt}

\usepackage{float}
\floatplacement{figure}{H}
\floatplacement{table}{H}

\usepackage{graphicx}
\usepackage{array}
\usepackage{tabularx}

\usepackage{color} % to demonstrate overlap

\RequirePackage
[
    skip=0pt,
    format=plain,
    labelsep=endash,
    singlelinecheck=false,
]{caption}
\captionsetup[figure]{singlelinecheck=true}

%\AtBeginDocument{
    \setlength\floatsep{0pt}
    \setlength\textfloatsep{0pt}
    \setlength\intextsep{0pt}
%}

\setlength{\belowcaptionskip}{-\dp\strutbox} % remove space after caption

\begin{document}
Text text Text text Text text Text textText text Text textText text Text textText text Text textText text Text textText text Text textText text Text textText text Text
\begin{figure}
    \centering
    \strut  one baseline float
    \caption{figure}
\end{figure}
\vskip -\baselineskip
{\centering\color{red}{Figure 1 -- figure}\par}

Text text Text text Text text Text textText text Text textText text Text textText text Text textText text Text textText text Text textText text Text textText text Text text

\begin{table}
    \caption{table}
    \strut one baseline float
\end{table}
\vskip -2\baselineskip
\noindent\color{red}{Table 1 -- table}

\end{document}

在此处输入图片描述

相关内容