使用 longtable 时行与行之间出现不必要的空白

使用 longtable 时行与行之间出现不必要的空白

我使用的是 longtable,它由 4 列 7 行组成,包含相当多的长句子。问题是,当排版一行时,它会在该页面上留下更多空间,并在下一页打印下一行。

长桌图片

\documentclass[12pt,oneside]{book}%

%%%%%%%%%%%Packages Initialization%%%%%%%%%%%%%%%
\usepackage[a4paper,top=0.75in,bottom=0.75in,left=1.25in,right=1in]{geometry}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{longtable}
\usepackage{array, booktabs}
\usepackage{lipsum}
\begin{document}
\newcommand{\mylipsum}{The Hadean eon represents the time before a reliable (fossil) record of life; it began with the formation of the planet and ended 4.0 billion years ago.}
\newcommand{\Mylipsum}{\mylipsum{} \mylipsum}
\begin{center}
\begin{longtable}{p{0.15\textwidth}p{0.22\textwidth}p{0.25\textwidth}p{0.28\textwidth}}
\captionsetup{justification=centering}
\caption{Test long table} \label{tab:testlongtable}\\
\hline \multicolumn{1}{p{0.15\textwidth}}{\centering \textbf{Column1}} & \multicolumn{1}{p{0.22\textwidth}}{\centering \textbf{Column2}} & \multicolumn{1}{p{0.25\textwidth}}{\centering \textbf{Column3}} & \multicolumn{1}{p{0.28\textwidth}}{\centering \textbf{Column4}}\\ \hline 
\endfirsthead
\captionsetup{justification=centering}
\caption[]{Test long table} \\
\hline \multicolumn{1}{p{0.15\textwidth}}{\centering \textbf{Column1}} & \multicolumn{1}{p{0.22\textwidth}}{\centering \textbf{Column2}} & \multicolumn{1}{p{0.25\textwidth}}{\centering \textbf{Column3}} & \multicolumn{1}{p{0.28\textwidth}}{\centering \textbf{Column4}}\\ \hline 
\endhead
\hline \multicolumn{4}{r}{Continued on next page..} \\ 
\endfoot
\hline
\endlastfoot
\mylipsum &The following Archean and Proterozoic eons produced the beginnings of life on Earth and its earliest evolution. The succeeding eon is the Phanerozoic, divided into three eras: the Palaeozoic, an era of arthropods, fishes, and the first life on land; the Mesozoic, which spanned the rise, reign, and climactic extinction of the non-avian dinosaurs; and the Cenozoic, which saw the rise of mammals. Recognizable humans emerged at most 2 million years ago, a vanishingly small period on the geological scale.&The following Archean and Proterozoic eons produced the beginnings of life on Earth and its earliest evolution. The succeeding eon is the Phanerozoic, divided into three eras: the Palaeozoic, an era of arthropods, fishes, and the first life on land; the Mesozoic, which spanned the rise, reign, and climactic extinction of the non-avian dinosaurs; and the Cenozoic, which saw the rise of mammals. Recognizable humans emerged at most 2 million years ago, a vanishingly small period on the geological scale.&\mylipsum\\
\midrule
\mylipsum &The following Archean and Proterozoic eons produced the beginnings of life on Earth and its earliest evolution. The succeeding eon is the Phanerozoic, divided into three eras: the Palaeozoic, an era of arthropods, fishes, and the first life on land; the Mesozoic, which spanned the rise, reign, and climactic extinction of the non-avian dinosaurs; and the Cenozoic, which saw the rise of mammals. Recognizable humans emerged at most 2 million years ago, a vanishingly small period on the geological scale.&The following Archean and Proterozoic eons produced the beginnings of life on Earth and its earliest evolution. The succeeding eon is the Phanerozoic, divided into three eras: the Palaeozoic, an era of arthropods, fishes, and the first life on land; the Mesozoic, which spanned the rise, reign, and climactic extinction of the non-avian dinosaurs; and the Cenozoic, which saw the rise of mammals. Recognizable humans emerged at most 2 million years ago, a vanishingly small period on the geological scale.&\mylipsum\\
\midrule
\mylipsum &The following Archean and Proterozoic eons produced the beginnings of life on Earth and its earliest evolution. The succeeding eon is the Phanerozoic, divided into three eras: the Palaeozoic, an era of arthropods, fishes, and the first life on land; the Mesozoic, which spanned the rise, reign, and climactic extinction of the non-avian dinosaurs; and the Cenozoic, which saw the rise of mammals. Recognizable humans emerged at most 2 million years ago, a vanishingly small period on the geological scale.&The following Archean and Proterozoic eons produced the beginnings of life on Earth and its earliest evolution. The succeeding eon is the Phanerozoic, divided into three eras: the Palaeozoic, an era of arthropods, fishes, and the first life on land; the Mesozoic, which spanned the rise, reign, and climactic extinction of the non-avian dinosaurs; and the Cenozoic, which saw the rise of mammals. Recognizable humans emerged at most 2 million years ago, a vanishingly small period on the geological scale.&\mylipsum\\
\end{longtable}
\end{center}
\end{document}

答案1

将表格旋转为横向并相应调整列宽时,您可以最小化表格中的垂直和水平空白。根据实际内容,表格的 2 行可能适合一页。正如评论中已经推荐的那样,我还使用了包\thead中的命令makecell作为列标题,并使用您已加载的包\hline中的规则替换了命令booktabs

在此处输入图片描述

\documentclass[12pt,oneside]{book}%

%%%%%%%%%%%Packages Initialization%%%%%%%%%%%%%%%
\usepackage[a4paper,top=0.75in,bottom=0.75in,left=1.25in,right=1in]{geometry}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{longtable}
\usepackage{array, booktabs}
\usepackage{lipsum}
\usepackage{pdflscape}
\usepackage{makecell}
\usepackage{calc}
\renewcommand{\theadfont}{\normalsize\bfseries}
\begin{document}
\newcommand{\mylipsum}{The Hadean eon represents the time before a reliable (fossil) record of life; it began with the formation of the planet and ended 4.0 billion years ago.}
\newcommand{\Mylipsum}{\mylipsum{} \mylipsum}

\begin{landscape}
\begin{longtable}{>{\raggedright\arraybackslash}p{0.125\linewidth-2\tabcolsep}
                  p{0.325\linewidth-2\tabcolsep}
                  p{0.325\linewidth-2\tabcolsep}
                  >{\raggedright\arraybackslash}p{0.125\linewidth-2\tabcolsep}}
\captionsetup{justification=centering}
\caption{Test long table} \label{tab:testlongtable}\\
\toprule
\thead{Column1} & \thead{Column2} & \thead{Column3} & \thead{Column4}\\ \midrule 
\endfirsthead
\captionsetup{justification=centering}
\caption[]{Test long table} \\
\toprule
\thead{Column1} & \thead{Column2} & \thead{Column3} & \thead{Column4}\\ \midrule 
\endhead
\multicolumn{4}{r}{Continued on next page..} \\ 
\endfoot
\bottomrule
\endlastfoot
\mylipsum &The following Archean and Proterozoic eons produced the beginnings of life on Earth and its earliest evolution. The succeeding eon is the Phanerozoic, divided into three eras: the Palaeozoic, an era of arthropods, fishes, and the first life on land; the Mesozoic, which spanned the rise, reign, and climactic extinction of the non-avian dinosaurs; and the Cenozoic, which saw the rise of mammals. Recognizable humans emerged at most 2 million years ago, a vanishingly small period on the geological scale.&The following Archean and Proterozoic eons produced the beginnings of life on Earth and its earliest evolution. The succeeding eon is the Phanerozoic, divided into three eras: the Palaeozoic, an era of arthropods, fishes, and the first life on land; the Mesozoic, which spanned the rise, reign, and climactic extinction of the non-avian dinosaurs; and the Cenozoic, which saw the rise of mammals. Recognizable humans emerged at most 2 million years ago, a vanishingly small period on the geological scale.&\mylipsum\\
\midrule
\mylipsum &The following Archean and Proterozoic eons produced the beginnings of life on Earth and its earliest evolution. The succeeding eon is the Phanerozoic, divided into three eras: the Palaeozoic, an era of arthropods, fishes, and the first life on land; the Mesozoic, which spanned the rise, reign, and climactic extinction of the non-avian dinosaurs; and the Cenozoic, which saw the rise of mammals. Recognizable humans emerged at most 2 million years ago, a vanishingly small period on the geological scale.&The following Archean and Proterozoic eons produced the beginnings of life on Earth and its earliest evolution. The succeeding eon is the Phanerozoic, divided into three eras: the Palaeozoic, an era of arthropods, fishes, and the first life on land; the Mesozoic, which spanned the rise, reign, and climactic extinction of the non-avian dinosaurs; and the Cenozoic, which saw the rise of mammals. Recognizable humans emerged at most 2 million years ago, a vanishingly small period on the geological scale.&\mylipsum\\
\midrule
\mylipsum &The following Archean and Proterozoic eons produced the beginnings of life on Earth and its earliest evolution. The succeeding eon is the Phanerozoic, divided into three eras: the Palaeozoic, an era of arthropods, fishes, and the first life on land; the Mesozoic, which spanned the rise, reign, and climactic extinction of the non-avian dinosaurs; and the Cenozoic, which saw the rise of mammals. Recognizable humans emerged at most 2 million years ago, a vanishingly small period on the geological scale.&The following Archean and Proterozoic eons produced the beginnings of life on Earth and its earliest evolution. The succeeding eon is the Phanerozoic, divided into three eras: the Palaeozoic, an era of arthropods, fishes, and the first life on land; the Mesozoic, which spanned the rise, reign, and climactic extinction of the non-avian dinosaurs; and the Cenozoic, which saw the rise of mammals. Recognizable humans emerged at most 2 million years ago, a vanishingly small period on the geological scale.&\mylipsum\\
\end{longtable}
\end{landscape}
\end{document}

相关内容