标题间距 - 表格与长表格

标题间距 - 表格与长表格

如果我在一个文档中同时使用表格和长表格,则表格和长表格之间的标题和表格之间的间距(标题后的空白空间)是不同的。

我希望两种情况下标题后的间距都尽量小(实际上相同)。谢谢。

例子:

\documentclass[12pt]{article}
\usepackage{longtable, booktabs, graphicx}
\begin{document}

\begin{table}
\caption{This is the first caption}
\begin{center}
\resizebox{1\textwidth}{!}{
\begin{tabular}{@{}llllll@{}}
\toprule
\textbf{Name} & \textbf{Description} & \textbf{Unit} & \textbf{Data source} & \textbf{Time frame} & \textbf{Frequency} \\
\midrule  
Name & Description & Unit & Data source & Time frame & Frequency \\
\bottomrule  
\end{tabular}}
\end{center}
\end{table}

\begin{center} 
\begin{longtable}{@{}p{2cm}p{1.5cm}p{3.6cm}p{1.2cm}p{1.5cm}p{1.5cm}@{}}
\caption{This is the second caption} \\
\toprule 
\textbf{Author(s)} & \textbf{Area} & \textbf{Estimated relationship} & \textbf{Time frame}  & \textbf{Scope}  & \textbf{type} \\
\midrule 
\endfirsthead
\multicolumn{6}{c}{\tablename\ \thetable\ -- \textit{Continued from previous page}} \\
\toprule 
\textbf{Author(s)} & \textbf{Area} & \textbf{Estimated relationship} & \textbf{Time frame}  & \textbf{Scope}  & \textbf{ type} \\ 
\midrule 
\endhead
\midrule 
\multicolumn{6}{r}{\textit{Continued on next page}} \\ 
\endfoot 
\bottomrule 
\endlastfoot
name & area & relationship & time & scope &  type \\
\end{longtable} 
\end{center}
\end{document}

答案1

加载caption包:

\documentclass[12pt]{article}
\usepackage{longtable, booktabs, graphicx, caption}
\captionsetup[table]{position=above}
\begin{document}

\begin{table}
\caption{This is the first caption}
\centering
\begin{tabular}{@{}llllll@{}}
\toprule
\textbf{Name} & \textbf{Description} & \textbf{Unit} & \textbf{Data source} & \textbf{Time frame} & \textbf{Frequency} \\
\midrule  
Name & Description & Unit & Data source & Time frame & Frequency \\
\bottomrule  
\end{tabular}
\end{table}

\begin{longtable}{@{}p{2cm}p{1.5cm}p{3.6cm}p{1.2cm}p{1.5cm}p{1.5cm}@{}}
\caption{This is the second caption} \\
\toprule 
\textbf{Author(s)} & \textbf{Area} & \textbf{Estimated relationship} & \textbf{Time frame}  & \textbf{Scope}  & \textbf{type} \\
\midrule 
\endfirsthead
\multicolumn{6}{c}{\tablename\ \thetable\ -- \textit{Continued from previous page}} \\
\toprule 
\textbf{Author(s)} & \textbf{Area} & \textbf{Estimated relationship} & \textbf{Time frame}  & \textbf{Scope}  & \textbf{ type} \\ 
\midrule 
\endhead
\midrule 
\multicolumn{6}{r}{\textit{Continued on next page}} \\ 
\endfoot 
\bottomrule 
\endlastfoot
name & area & relationship & time & scope &  type \\
\end{longtable} 
\end{document}
  1. 不要使用center里面的环境table,但是\centering
  2. 不要使用center环境longtable:表格将默认居中显示
  3. \resizebox作为最后的手段
  4. p如果添加,窄列可能会得到更好的处理\raggedright,您可以使用array包来完成:

    >{\raggedright\arraybackslash}p{3.6cm}
    

    将成为您第三栏的一个很好的声明longtable(添加\usepackage{array}到您的序言中。

在此处输入图片描述

相关内容