I'd like to automatically repeat section headings after a page break. My naive attempt at doing this is to check the page counter and print the extra text whenever the counter increments:
\newcounter{pagecnt}
\setcounter{pagecnt}{\value{page}}
...
\ifnum \value{page} > \value{pagecnt}% are we on a new page?
\normalfont\Large\bfseries\sectionheadinghere% print heading again
\setcounter{pagecnt}{\value{page}}% reset counter
\fi%
Except I'm not entirely sure what should 'trigger' this code? Is it possible or desirable to check after every line-break (or every word) if the page has flipped?
Best Answer
The following patch (via
etoolbox
) saves the sectional content (number, title and font) in a macro that is re-evaluated at page shipout (as supplied byeveryshi
) if there is text overflow. Overflow is established using the conditionthat checks whether the gathered page content (of height
\pagetotal
) extends beyond the allowed total (of height\pagegoal
).The sectional content is captured in
\@section@title@
and includes the latest sectional title used (anything from level 1 =\section
to level 5 =\paragraph
).Customizations include using only a specific sectional unit (like
\section
, say). Also, to duplicate the spacing after the sectional header when traditionally used, rather than issuing\bigskip
.The above works in the context of the standard LaTeX document classes (like
book
,article
andreport
) and may require additional modifications if used in other document classes, or in conjunction with other sectional heading packages.