Skip to content

Commit a97043d

Browse files
committed
ci: add needspace package to prevent orphan section headings in LaTeX output
1 parent 85d6693 commit a97043d

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

doc/conf.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,14 @@ def exclude_api_from_gettext(app):
237237
\newfontfamily\unicodefallback{Symbola}[Scale=MatchLowercase]
238238
\usepackage[Symbols]{ucharclasses}
239239
\setTransitionsForSymbols{\unicodefallback}{\normalfont}
240+
% Prevent orphan section headings at the bottom of a page: force a page
241+
% break if there is not enough room for the heading plus a few lines of
242+
% its following paragraph.
243+
\usepackage{needspace}
244+
\usepackage{etoolbox}
245+
\pretocmd{\section}{\Needspace{5\baselineskip}}{}{}
246+
\pretocmd{\subsection}{\Needspace{4\baselineskip}}{}{}
247+
\pretocmd{\subsubsection}{\Needspace{3\baselineskip}}{}{}
240248
"""
241249
+ "\n".join(f"\\newcommand{{\\{cmd}}}{{{defn}}}" for cmd, defn in macros.items()),
242250
}

0 commit comments

Comments
 (0)