我在 LaTeX 文档中遇到分页符问题。LaTeX 似乎偶尔(莫名其妙地)将几行移到新页面上,即使上一页底部有足够的空间容纳这些行。
我已经能够计算出更改parskip
值将改变行为。在下面的 MWE 中,使用默认值会将\parskip
整个部分推送到新页面上。将更改为\parskip
0 会使所有内容适合一页(默认值\parskip
似乎是0pt plus 1pt
)。或者,将 parskip 更改为类似 的值0pt plus 4pt minus 1pt
会导致第二页上出现四个完整的部分。请注意,生成的文档中的实际段落间距根本没有改变。
\documentclass[10pt,a4paper,oneside]{article}
\usepackage{pgffor}
\usepackage[showframe,
left=10pc,
right=5pc,
top=5.5pc,
bottom=5pc,
marginparwidth=6pc,
]{geometry} % Adjust page margins
\setlength{\parskip}{0pt plus 4pt minus 1pt} % Many lines go to next page
% \setlength{\parskip}{0pt} % Everything fits on one page.
\usepackage{titlesec}
\titleformat{\subsection}
[leftmargin]{\footnotesize\vspace{0pt}\filleft}{}{.5em}{}
\titlespacing{\subsection}
{4pc}{0.2ex plus .1ex minus .1ex}{1pc}
\begin{document}
\raggedbottom
\setlength{\parindent}{0pc} % Remove paragraph indentation
\the\parskip
\foreach \n in {7:30,8:00,8:30,9:00,9:30,10:00,10:30,11:00,11:30,12:00,12:30,13:00,13:30,14:00,14:30,15:00,15:30,16:00,16:30,17:00,17:30,18:00,18:30,19:00,19:30,20:30,21:30}{
\subsection{\n}\textbf{Time now is \n}\par Let's get busy!\par}
\end{document}
MWE 的结果:
答案1
我认为这是选项使用的 titlesec 命令中的一个错误。它从当前值leftmargin
中删除,并使用正拉伸值堆积起来。如果我删除此行,您的文档可以正常编译:\pagegoal
\pagestretch
\parskip
\documentclass[10pt,a4paper,oneside]{article}
\usepackage{pgffor}
\usepackage[showframe,
left=10pc,
right=5pc,
top=5.5pc,
bottom=5pc,
marginparwidth=6pc,
]{geometry} % Adjust page margins
\setlength{\parskip}{0pt plus 4pt minus 1pt} % Many lines go to next page
% \setlength{\parskip}{0pt} % Everything fits on one page.
\usepackage{titlesec}
\titleformat{\subsection}
[leftmargin]{\footnotesize}{}{.5em}{}
\titlespacing{\subsection}
{4pc}{0.2ex plus .1ex minus .1ex}{1pc}
\usepackage{etoolbox}
\makeatletter
\patchcmd\ttlh@leftmargin{\advance\@tempskipa\pagestretch}{}{}{\fail}
\makeatother
\begin{document}
\raggedbottom
\setlength{\parindent}{0pc} % Remove paragraph indentation
\the\parskip
\foreach \n in {7:30,8:00,8:30,9:00,9:30,10:00,10:30,11:00,11:30,12:00,12:30,13:00,13:30,14:00,14:30,15:00,15:30,16:00,16:30,17:00,17:30,18:00,18:30,19:00,19:30,20:30,21:30}{
\subsection{\n}\textbf{Time now is \n}\par Let's get busy!\par}
\end{document}