1

I'm typing a math article for someone. He asked me to type it in plain TeX (rather than LaTeX) because he is used to plain TeX and would like the option to edit my typing, I think.

Anyway, I am new to plain TeX. In the head of every section I use \beginsection. But the line doesn't break when the text exceeds the line length. Is there a way to alter the command \beginsection so it would break the line at the end of the line?

Thanks, niv

2
  • 1
    Can you add a minimal example document showing the problem? Commented Apr 30, 2021 at 19:53
  • 1
    Try \beginsection{\vtop{...}} Commented Apr 30, 2021 at 21:27

1 Answer 1

2

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

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .