我正在编写一个文档,该文档需要有一个长表,它将自动生成并可能生成多个页面。我设法使用 longtable 来实现它,但我发现,当表格结束时,页面的其余部分是空白的,下一节从下一页开始。但是,如果文档的其余部分足够短以适合同一页,它就不会进行分页。
这是我能找到的最简单的例子。我正在使用其他一些我认为不会触发此问题的实现,但我更愿意使用这个,并且主要是为了理解为什么会发生这种情况。
\documentclass[a4paper, 12pt, landscape]{article}
\usepackage{longtable}
\usepackage{fontspec}
\usepackage[table,xcdraw]{xcolor}
\usepackage{lipsum}
\usepackage[a4paper,top=3.17cm, bottom=3.17cm,
left=3.17cm, right=2.54cm,
headsep=0.2cm,headheight=50pt,heightrounded,
footskip=1.3cm]{geometry}
\usepackage{mdframed}
\setmainfont{Times New Roman}
\newmdenv[
leftmargin=0pt,
rightmargin=0pt,
innertopmargin=0pt,
innerbottommargin=0pt,
innerrightmargin=0pt,
innerleftmargin=0pt
]{siderules}
\definecolor{grey}{HTML}{C0C0C0}
\definecolor{white}{HTML}{FFFFFF}
\begin{document}
\begin{siderules}
\begin{center}
\textbf{1. Section 1: } \\[\baselineskip]
\lipsum[1]
\rule{\linewidth}{0.5pt}
\textbf{Section 2:} \\[\baselineskip]
The longtable starts a line below \\[\baselineskip]
\rowcolors{1}{grey}{white}
\renewcommand*{\arraystretch}{1.4}
\begin{longtable}{p{0.07\linewidth} p{0.5\linewidth} p{0.1\linewidth} p{0.13\linewidth}}
\rowcolor[HTML]{343434} {\textcolor[HTML]{EFEFEF}{\textbf{Issue ID}}} & { \textcolor[HTML]{EFEFEF}{\textbf{Title}}} & {\textcolor[HTML]{EFEFEF}{\textbf{Assignee}}} & {\textcolor[HTML]{EFEFEF}{\textbf{Closed At (UTC)}}} \\
01 & This is a long line that whould wrap up inside the cell when it reaches the end of the available space & 2c \\
2a & 2b & 2c & 2d \\
2a & 2b & 2c & 2d \\
2a & 2b & 2c & 2d \\
2a & 2b & 2c & 2d \\
2a & 2b & 2c & 2d \\
2a & 2b & 2c & 2d \\
2a & 2b & 2c & 2d \\
2a & 2b & 2c & 2d \\
2a & 2b & 2c & 2d
\end{longtable}
This line should start just below the table.
\rule{\linewidth}{0.5pt}
\textbf{Section 3} \\[\baselineskip]
\lipsum[2]
\rule{\linewidth}{0.5pt}
\textbf{Section 4} \\[\baselineskip]
\lipsum[3]
\rule{\linewidth}{0.5pt}
\textbf{Section 5} \\[\baselineskip]
\lipsum[4]
\end{center}
\end{siderules}
\end{document}