![当我们接近页面顶部时,longtable 有时会开始新的页面](https://linux22.com/image/301282/%E5%BD%93%E6%88%91%E4%BB%AC%E6%8E%A5%E8%BF%91%E9%A1%B5%E9%9D%A2%E9%A1%B6%E9%83%A8%E6%97%B6%EF%BC%8Clongtable%20%E6%9C%89%E6%97%B6%E4%BC%9A%E5%BC%80%E5%A7%8B%E6%96%B0%E7%9A%84%E9%A1%B5%E9%9D%A2.png)
大多数情况下,longtable
它会按照要求进行操作,但有时,当它靠近页面顶部且当前页面上有足够的空间容纳整个表格时,它会开始一个新页面。
我已在以下完整文档中隔离了该问题:
\documentclass[a4paper] {report}
\addtolength{\hoffset}{-1.27cm}
\addtolength{\textwidth}{2.54cm}
\pagestyle{headings}
\usepackage{longtable}
\setlongtables
\parindent0mm
\parskip2ex plus1ex minus1ex
\author{Author}
\date{10 November 2014}
\title{Document}
\begin{document}
\maketitle
\newpage
\chapter{Functions}
to show the problem the function needs to start on a new page
to show the problem the function needs to start on a new page
to show the problem the function needs to start on a new page
to show the problem the function needs to start on a new page
to show the problem the function needs to start on a new page
to show the problem the function needs to start on a new page
to show the problem the function needs to start on a new page
to show the problem the function needs to start on a new page
to show the problem the function needs to start on a new page
to show the problem the function needs to start on a new page
to show the problem the function needs to start on a new page
to show the problem the function needs to start on a new page
to show the problem the function needs to start on a new page
to show the problem the function needs to start on a new page
to show the problem the function needs to start on a new page
to show the problem the function needs to start on a new page
to show the problem the function needs to start on a new page
to show the problem the function needs to start on a new page
to show the problem the function needs to start on a new page
to show the problem the function needs to start on a new page
\section{matrix\_multiply} \label{function_matrix_multiply}
This function multiplies two matrices together.
\textbf{Inputs:}
\small
\begin{longtable}{|p{150pt}|p{230pt}|l}
\cline{1-2} \textbf{Type and Name} & \textbf{Description} &
\endfirsthead
\cline{1-2} \textbf{Type and Name} & \textbf{Description} &
\endhead
\cline{1-2} \multicolumn{2}{r}{{Continued on next page}}
\endfoot
\cline{1-2}
\endlastfoot
\cline{1-2}
\raggedright Matrix A &
\raggedright Matrix A
& \\
\cline{1-2}
\raggedright Matrix B &
\raggedright Matrix B - the number of rows of B must be the same as the number of columns of A
& \\
\cline{1-2}
\end{longtable}
\normalsize
\textbf{ReturnType:} Matrix
\end{document}
我看到的是该部分进入一个新页面(自行进入 -\newpage
该部分之前没有命令),然后longtable
出现在一个新页面上,尽管该页面有大约 80% 的空闲空间并且只有几行。
如果您注释掉 section 命令之前的最后一个虚拟文本,问题就会消失。但是我的 TeX 文件是从源代码生成的,手动编辑 TeX 文件对我来说不是一个好选择。
任何帮助和见解都将不胜感激。
答案1
如果你失去这条线
%\parskip2ex plus1ex minus1ex
或者直接将其改为
\parskip2ex plus1ex %minus1ex
将大量(或任何)收缩胶放入垂直列表中会使是否有空间的评估变得复杂化......
longtable
可以更加努力地估计真正会拉伸/收缩的胶水量,但目前还不行。
如果您希望保持值的收缩,您可以通过在节标题处放置一个\parskip
来强制分页符决策在混淆之前发生。longtable
\clearpage
\clearpage
\section{matrix\_multiply} \label{function_matrix_multiply}