This is the definition of \beginsection
from plain.tex
:
\outer\def\beginsection#1\par{\vskip\z@ plus.3\vsize\penalty-250
\vskip\z@ plus-.3\vsize\bigskip\vskip\parskip
\message{#1}\leftline{\bf#1}\nobreak\smallskip\noindent}
This means that the title is indeed set inside \leftline
, which doesn't allow line breaks. How can you modify it? Remove \leftline
but add a local setting of \interlinepenalty
in order that the paragraph formed by the section title is not split across pages.
\catcode`@=11
\outer\def\beginsection#1\par{%
\vskip\z@ plus.3\vsize % a generous stretchability
\penalty-250 % a good point to break a page
\vskip\z@ plus-.3\vsize % but cancel it if no page break is taken at the penalty
\bigskip\vskip\parskip % separation from the above text if no page break
\message{#1}% log the section title
\begingroup
\interlinepenalty=10000 % no page break allowed in the title if split across lines
\hangindent=\parindent \hangafter=1 % indent all lines like the first one
\bf#1\par
\endgroup
\nobreak % no page break between the title and the following text
\smallskip
\noindent
}
\catcode`@=12
\vsize=6\baselineskip % just to show that no break is taken
\beginsection This is a long title that should be split across lines; just
make it sufficiently long; maybe this long is sufficient
Text of the section
\beginsection
This is a long title that should be split across lines; just
make it sufficiently long; maybe this long is sufficient
This is a long title that should be split across lines; just
make it sufficiently long; maybe this long is sufficient
This is a long title that should be split across lines; just
make it sufficiently long; maybe this long is sufficient
Text of the section
\bye
\beginsection{\vtop{...}}