TransWikia.com

plain tex. beginsection doesnt break line

TeX - LaTeX Asked by NivMan on June 22, 2021

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

One Answer

This is the definition of beginsection from plain.tex:

outerdefbeginsection#1par{vskipz@ plus.3vsizepenalty-250
  vskipz@ plus-.3vsizebigskipvskipparskip
  message{#1}leftline{bf#1}nobreaksmallskipnoindent}

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

outerdefbeginsection#1par{%
  vskipz@ plus.3vsize % a generous stretchability
  penalty-250 % a good point to break a page
  vskipz@ plus-.3vsize % but cancel it if no page break is taken at the penalty
  bigskipvskipparskip % 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#1par
  endgroup
  nobreak % no page break between the title and the following text
  smallskip
  noindent
}

catcode`@=12

vsize=6baselineskip % 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

Answered by egreg on June 22, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP