latex:如何排版许多没有正文的标题?(大约 20 个之后,它们不适合一页,并且由于某种原因,latex 不会创建新页面)

latex:如何排版许多没有正文的标题?(大约 20 个之后,它们不适合一页,并且由于某种原因,latex 不会创建新页面)

我有一份文档(我使用“article”类,但我不能保证,因为用户可能会覆盖它。),它只包含各种标题(\chapter,\section,\subsection,\subsubsection,天知道是哪些),大约有 200 个。

当我用 latex 编译它时(我使用 lualatex),结果非常令人毛骨悚然,即我得到一个空白页,然后是包含前约 20 个标题的页面。最后的标题溢出到底部边距(应该只有页码,甚至什么都没有),并且没有创建新页面,因此其余约 180 个标题都丢失了。

  1. 我怎样才能让乳胶永远不会超出它应该在的框范围?(以避免在边距中出现不适当的文本。)
  2. 如何让 latex 在需要时创建新页面?我无法重载 \section、\subsection 等命令,因为我无法提前知道它们的名称。(否则,我或许可以写一些类似的东西\renewcommand\section{\section\vspace{0.001cm}},但同样,我需要一个强大的解决方案,它不是基于预先计算的一组部分名称、大小等。

我的 MWE 如下:

\documentclass[11pt,a4paper]{article}
\begin{document}

\section{{\bfseries\sffamily TODO} Good Books [0/33]}
\subsection{{\bfseries\sffamily TODO} {http://www.finseth.com/craft/}{Craft of Text Editing about Emacs}}
\subsection{{\bfseries\sffamily TODO} The art of Metaobject protocol {https://en.m.wikipedia.org/wiki/The\_Art\_of\_the\_Metaobject\_Protocol}{Wikipedia Link}}
\subsection{{\bfseries\sffamily TODO} lesswrong.com {https://www.lesswrong.com/}{Link online}}
\subsection{{\bfseries\sffamily TODO} lesswrong.ru}
\subsection{{\bfseries\sffamily TODO} Ilya Prigogine Philosophy of complexity?}
\subsection{{\bfseries\sffamily TODO} An Introduction to the Graphic Language: The Vocabulary, Grammatical Construction, Idiomatic Use, and Historical Development, with Special Reference to the Reading of Drawings -- by Gardner Chace}
\subsection{{\bfseries\sffamily TODO} Getting Things Done}
\subsection{{\bfseries\sffamily TODO} Kernigan-Pike Practice of Programming}
\subsection{{\bfseries\sffamily TODO} Model Calibration and Parameter Estimation}
\subsection{{\bfseries\sffamily TODO} Hitchhiker's Guide to the Galaxy\hfill{}\textsc{hate}}
\subsection{{\bfseries\sffamily TODO} Thomas Hunt Pragmatic Programmer}
\subsection{{\bfseries\sffamily TODO} r-5.org}
\subsection{{\bfseries\sffamily TODO} otoro.net machine learning research blog}
\subsection{{\bfseries\sffamily TODO} Weinberg The Trouble With Quantum Mechanics}
\subsection{{\bfseries\sffamily TODO} Elements of Statistical Learning}
\subsection{{\bfseries\sffamily TODO} Tufte Book on graphs}
\subsection{{\bfseries\sffamily TODO} sumofsquares.org book}
\subsection{{\bfseries\sffamily TODO} Gabriel Wyner Fluent Forever How To Learn Any Language}
\subsection{{\bfseries\sffamily TODO} {https://en.wikipedia.org/wiki/Scientific\_community\_metaphor} and subbooks}
\subsection{{\bfseries\sffamily TODO} {https://www.amazon.com/dp/0201433117/?tag=stackoverfl08-20}}
\subsection{{\bfseries\sffamily TODO} {http://immersivemath.com/ila/index.html}{Immersive Linear Algebra}}
\subsection{{\bfseries\sffamily TODO} {http://discrete.openmathbooks.org/dmoi3.html}{Discrete Mathematics Open Book}}
\subsection{{\bfseries\sffamily TODO} danijar.com}
\subsection{{\bfseries\sffamily TODO} Terry Tang Yuan github.io}
\subsection{{\bfseries\sffamily TODO} blog.mdda.net}
\subsection{{\bfseries\sffamily TODO} brilliant.org blog}
\subsection{{\bfseries\sffamily TODO} {http://gaudisite.nl/newspage.html}{Gaudi Systems Architecture}}
\subsection{{\bfseries\sffamily TODO} Farnam Street}
\subsection{{\bfseries\sffamily TODO} {http://www.mitchr.me/SS/books/Catigory\_index.html} and subbooks}
\subsection{{\bfseries\sffamily TODO} {https://www.scrumalliance.org/labs}{Scrum Alliance}}
\subsection{{\bfseries\sffamily TODO} {http://flibusta.is/b/482781}{Gippenreiter-2+3}}
\subsection{{\bfseries\sffamily TODO} {http://timmurphy.org/2018/05/22/combining-pdf-documents-using-latex/}{Tim Murphy's Blog}}
\subsection{{\bfseries\sffamily TODO} {http://flibusta.is/b/122923}{Ruth Benedict Chrysanthemum and Sword}}
\subsection{{\bfseries\sffamily TODO} {https://www.amazon.com/Mathematicians-Lament-School-Fascinating-Imaginative/dp/1934137170/ref=pd\_aw\_sbs\_14\_1/146-9551928-4683768?\_encoding=UTF8\&pd\_rd\_i=1934137170\&pd\_rd\_r=ebc1f528-5232-11e9-a585-0fccb0784f1b\&pd\_rd\_w=gnvYP\&pd\_rd\_wg=V2MnV\&pf\_rd\_p=aae79475-6dc9-4a12-80e8-27b63108fa72\&pf\_rd\_r=GC659QJ4DRN1YBNG4HZE\&psc=1\&refRID=GC659QJ4DRN1YBNG4HZE}{Mathematician's Lament}}
\subsection{{\bfseries\sffamily TODO} Tech books}
\subsubsection{{\bfseries\sffamily TODO} Lamport Latex}
\subsubsection{{\bfseries\sffamily TODO} Spivak, JoyOfTex}
\subsubsection{{\bfseries\sffamily TODO} Knuth TeXbook}
\subsubsection{{\bfseries\sffamily TODO} FreeCAD}
\subsubsection{{\bfseries\sffamily TODO} SWIG}
\subsubsection{{\bfseries\sffamily TODO} Emacs Lisp}
\subsubsection{{\bfseries\sffamily TODO} Kernigan-Pike}
\subsubsection{{\bfseries\sffamily TODO} Pragmatic Programmer}
\subsubsection{{\bfseries\sffamily TODO} GDB}
\subsubsection{{\bfseries\sffamily TODO} IDA Pro}
\subsubsection{{\bfseries\sffamily TODO} Togaf}
\subsubsection{{\bfseries\sffamily TODO} Craig Scott CMAKE}
\subsubsection{{\bfseries\sffamily TODO} OpenSCAD}
\subsubsection{{\bfseries\sffamily DONE} AUCTeX}
\subsubsection{{\bfseries\sffamily DONE} Magit}
\subsection{{\bfseries\sffamily TODO} Science Books}
\subsubsection{{\bfseries\sffamily TODO} Shen Kolmogorov Komplexity}
\subsubsection{{\bfseries\sffamily TODO} Arora-Barak}
\subsubsection{{\bfseries\sffamily TODO} Strandh}
\subsubsection{{\bfseries\sffamily TODO} Kleinberg-Tardos}
\subsubsection{{\bfseries\sffamily TODO} Sipser Introduction to theory of computation}
\subsubsection{{\bfseries\sffamily TODO} Romanyuk}
\subsubsection{{\bfseries\sffamily TODO} Papoulis}
\subsubsection{{\bfseries\sffamily TODO} Model Calibration and Parameter Estimation}
\subsection{{\bfseries\sffamily TODO} Work}
\subsubsection{{\bfseries\sffamily TODO} Patents}
\subsubsection{{\bfseries\sffamily TODO} POSA-5}
\subsubsection{{\bfseries\sffamily TODO} MBSA}
\subsubsection{{\bfseries\sffamily TODO} ASML}
\subsubsection{{\bfseries\sffamily TODO} Wymore}
\subsection{{\bfseries\sffamily TODO} Culture}
\subsubsection{{\bfseries\sffamily TODO} Sources of Chinese Tradition}
\subsection{{\bfseries\sffamily TODO} Books that `If I have time'}
\subsubsection{{\bfseries\sffamily TODO} The \LaTeX{} Companion by Goossens, Mittelbach}
\subsubsection{{\bfseries\sffamily TODO} \LaTeX{} Web Companion}
\subsubsection{{\bfseries\sffamily TODO} Simmons Modern Analysis}
\subsubsection{{\bfseries\sffamily TODO} Sussman, A computational model of Skill Acquisition}
\subsubsection{{\bfseries\sffamily TODO} Julie Sussman, I can read that a traveler's introduction to Chinese}
\subsubsection{{\bfseries\sffamily TODO} Michael Kerrisk Linux API}
\subsubsection{{\bfseries\sffamily TODO} Acoff-Emery on purposeful systems}
\subsubsection{{\bfseries\sffamily TODO} Gabriel Wyner How to learn any language and never forget}
\subsubsection{{\bfseries\sffamily TODO} Structure and interpretation of classical mechanics}
\subsubsection{{\bfseries\sffamily TODO} Russel/Norvig Artificial Intelligence Modern Approach (STRIPS algorithm)}
\subsubsection{{\bfseries\sffamily TODO} Han Abelson Lower Bounds on Information Transfer in Distributed Computations}
\subsubsection{{\bfseries\sffamily TODO} Abelson Blown to Bits}
\subsubsection{{\bfseries\sffamily TODO} Shirko, Nonlinear Continual Mechanics}
\subsubsection{{\bfseries\sffamily TODO} Dougherty Random Processes for Image Processing}
\subsection{{\bfseries\sffamily TODO} Philosophy}
\subsubsection{{\bfseries\sffamily TODO} Proudhon}
\subsubsection{{\bfseries\sffamily TODO} Das Kapital}
\subsubsection{{\bfseries\sffamily TODO} Wittgenstein}
\subsubsection{{\bfseries\sffamily TODO} Zhorzhh Durua ( George Durois?)}
\subsubsection{{\bfseries\sffamily TODO} Ludwig von Mises}
\end{document}

答案1

正如 siracusa 所说,LaTeX 不会在分段标题后分页。一种解决方案是在标题后添加一些(不可见的)文本,例如:

\subsection{A title} \   % or
\subsection{Another title} \mbox{} % or ...

答案2

该问题的答案是在文档顶部添加以下内容:

\documentclass[11pt,a4paper]{article}
\usepackage{xpatch}
\makeatletter
% This is not recommended, because it can break several things
\xpatchcmd{\@afterheading}{\@nobreaktrue}{\@nobreakfalse}{%
  \typeout{WARNING: \string\@afterheading\space broken}%
}{%
  \@latexerr{ERROR: Cannot patch \string\@afterheading}\@ehd%
}
\makeatother

这个答案是由 LaTeX 论坛的伟人 Ijon Tichy 提供的。 https://latex.org/forum/viewtopic.php?p=110289

顺便说一句,我认为 LaTeX 的这个特性是不合理且违反直觉的。

相关内容