减少表格前和表格之间的空间以添加新部分

减少表格前和表格之间的空间以添加新部分

我有这个代码:

\documentclass[a4paper,oneside,11pt]{article}
\usepackage[left=4cm,right=3cm,top=4cm,bottom=3cm]{geometry}
\usepackage{tabularx}
\usepackage{longtable}
\usepackage{lipsum}
\usepackage{titlesec}
\usepackage{placeins}
\usepackage[labelsep=period]{caption}
\titlespacing*{\section}
{0pt}{3ex plus 1ex minus .2ex}{3ex plus .2ex}
\begin{document}
    \section{Section One}
    \lipsum[4]
    \FloatBarrier
    \begingroup
    \setlength\extrarowheight{11pt}
    \begin{center}
        \begin{longtable}{|c|c|c|}
            \caption{aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} \label{table1}\\
            \hline
            Variable1&Variable2&Variable3\\
            \hline
            uxbwyy&xneio22xi&nc33i3\\
            \hline
            \multicolumn{3}{@{}l}
            { 
                Source: cnihe3i3nixom;
            }
        \end{longtable}
    \end{center}
    \endgroup
    \FloatBarrier
    \section{Section Two}
    \lipsum[4]
\end{document}

输出如下:

在此处输入图片描述

我想减少空间(红线),但我不想使用\vspace*{-...mm}。如何解决?

答案1

  • 表格周围的垂直空间取决于下一页的内容。

  • 你为什么使用longtable

  • 表格代码略有变化

    • 表插入在center环境中,因此它不浮动,因此使用\FloatBarrier多余的
    • 使用tabular而不是longtable
    • captionof{figure}{...}而是使用\caption{...}
    • 使用copyrightbox包来记录表源

    MWE 的结果是:

在此处输入图片描述

梅威瑟:

\documentclass[a4paper,oneside,11pt]{article}
\usepackage[hmargin={4cm,3cm},vmargin={4cm,3cm}]{geometry}
\usepackage{longtable, makecell, tabularx}
\usepackage{lipsum}
\usepackage{titlesec}
\titlespacing*{\section}
{0pt}{3ex plus 1ex minus .2ex}{3ex plus .2ex}
\usepackage{placeins}
\usepackage[labelsep=period]{caption}
\usepackage{copyrightbox}

\begin{document}
    \section{Section One}
    \lipsum[4]
%    \FloatBarrier
    \begin{center}
    \setcellgapes{11pt}
    \makegapedcells
    \captionof{figure}{aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} 
    \label{table1}
    \copyrightbox[b]{\begin{tabular}{|c|c|c|c|}
            \hline
            Variable1&Variable2&Variable3\\
            \hline
            uxbwyy&xneio22xi&nc33i3\\
            \hline
        \end{tabular}}{Source: cnihe3i3nixom;}
     \end{center}

    \section{Section Two}
%    \FloatBarrier
    \lipsum[4]
\end{document}

附录:如果您确实需要长表,那么问题中说明问题的图像就永远不会发生。例如,该长表类似于下面 MWE 中的使用,然后它会产生以下结果:

在此处输入图片描述

\documentclass[a4paper,oneside,11pt]{article}
\usepackage[hmargin={4cm,3cm},vmargin={4cm,3cm}]{geometry}
\usepackage{longtable, makecell, tabularx}
\renewcommand\theadfont{\normalsize\bfseries}
\renewcommand\theadgape{}
\usepackage{lipsum}
\usepackage{titlesec}
\titlespacing*{\section}
{0pt}{3ex plus 1ex minus .2ex}{3ex plus .2ex}
\usepackage{placeins}
\usepackage[labelsep=period]{caption}

\begin{document}
    \section{Section One}
    \lipsum[1-3]
\begingroup
    \setcellgapes{3pt}
    \makegapedcells
\begin{longtable}{|c|c|c|c|}
    \caption{That is my longtable, which is supposed to reproduce my problem}
    \label{:tab:longtable}          \\
    \hline
\thead{text} & \thead{text} & \thead{text} & \thead{text}   \\
    \hline
\endfirsthead
    \caption[]{That is my longtable, which is supposed 
               to reproduce my problem (cont.)}             \\
    \hline
\thead{text} & \thead{text} & \thead{text} & \thead{text}   \\
    \hline
\endhead
    \multicolumn{4}{r @{}}{\small\emph{continue on the next page}}  \\*
    \multicolumn{4}{@{} l}{\small Source: cnihe3i3nixom}    \\
\endfoot
    \hline
\endlastfoot
%%%% table nody    
Variable 1   & Variable 2   & Variable 3   & variable 4     \\
    \hline
uxbwyy       & xneio22xi    & nc33i3       & 44444          \\
    \hline
uxbwyy       & xneio22xi    & nc33i3       & 44444          \\
    \hline
uxbwyy       & xneio22xi    & nc33i3       & 44444          \\
    \hline
uxbwyy       & xneio22xi    & nc33i3       & 44444          \\
    \hline
uxbwyy       & xneio22xi    & nc33i3       & 44444          \\
    \hline
uxbwyy       & xneio22xi    & nc33i3       & 44444          \\
    \hline
uxbwyy       & xneio22xi    & nc33i3       & 44444          \\
    \hline
uxbwyy       & xneio22xi    & nc33i3       & 44444          \\
    \hline
uxbwyy       & xneio22xi    & nc33i3       & 44444          \\
    \hline
uxbwyy       & xneio22xi    & nc33i3       & 44444          \\
    \hline
uxbwyy       & xneio22xi    & nc33i3       & 44444          \\
    \hline
uxbwyy       & xneio22xi    & nc33i3       & 44444          \\
    \hline
uxbwyy       & xneio22xi    & nc33i3       & 44444          \\
    \hline
uxbwyy       & xneio22xi    & nc33i3       & 44444          \\
    \hline
uxbwyy       & xneio22xi    & nc33i3       & 44444          \\
    \hline
uxbwyy       & xneio22xi    & nc33i3       & 44444          \\
\end{longtable}
\endgroup

    \section{Section Two}
    \lipsum[4]
\end{document}

相关内容