如下图,如何设置表格和图形的垂直间距?

如下图,如何设置表格和图形的垂直间距?

在此处输入图片描述

如何设置如上图所示的垂直空间?我只能为所有标题设置,无法为“图形”标题和“表格”标题设置。

\documentclass[a4paper,oneside,11pt]{book}
\usepackage[left=4 cm,right=3cm,top=4cm,bottom=3cm]{geometry}
\usepackage{graphicx}
\setlength{\abovecaptionskip}{24pt}
\setlength{\belowcaptionskip}{24pt}
\setlength{\intextsep}{18pt}
\setlength{\textfloatsep}{18pt}
\begin{document}
    abcdefghijklmnopqrstuvwxyz
    
    \begin{figure}[h!]
        \centering
        \includegraphics[width=3cm]{example-grid-100x100pt}
        \caption{Figure BlaBlaBla}
    \end{figure}

abcdefghijklmnopqrstuvwxyz
\begin{table}[h!]
    \centering
    \caption{Table BlaBlaBla}
    \begin{tabular}{|l|l|l|l|}
        \hline
        A & B & C & D \\
        \hline
    \end{tabular}
\end{table}

abcdefghijklmnopqrstuvwxyz
\end{document}

答案1

使用caption,您可以为各个环境设置字幕跳过。然后,将长度\intextsep和设置\textfloatsep为 24pt(参见底部屏幕截图)

在此处输入图片描述

如果标题后面的一点额外空格figure让您感到困扰,只需删除以下几行的注释即可

\usepackage{etoolbox}
    \AfterEndEnvironment{figure}{\vspace{-2pt}}

来自包布局第 28 页的屏幕截图:

在此处输入图片描述

\documentclass[a4paper,oneside,11pt]{book}
\usepackage[left=4 cm,right=3cm,top=4cm,bottom=3cm]{geometry}
\usepackage{graphicx}
% Added
\usepackage{caption}
    \captionsetup[figure]{skip=18pt, position=bottom}
    \captionsetup[table]{skip=12pt, position=top}
% \usepackage{etoolbox}
%     \AfterEndEnvironment{figure}{\vspace{-2pt}}
\usepackage{lipsum}

\setlength{\intextsep}{24pt}
\setlength{\textfloatsep}{24pt}


\begin{document}

\lipsum[1][1-2]

\begin{figure}[h!]
    \centering
    \includegraphics[width=3cm]{example-grid-100x100pt}
    \caption{Figure BlaBlaBla}
\end{figure}

\lipsum[1][1-2]

\begin{table}[h!]
    \centering
    \caption{Table BlaBlaBla}
    \begin{tabular}{|l|l|l|l|}
        \hline
        A & B & C & D \\
        \hline
    \end{tabular}
\end{table}

\lipsum[1][1-2]
\end{document}

相关内容