4

I am relatively new to Plain TEX and I wanted to define a \section command to typeset a bold and centered text with some spacing around it. Here is what I came up with.

\def\section#1{\bigbreak\centerline{\bf #1}\medskip\nobreak}

Is that a correct way to do so? In particular I don't know if \medskip has to be typed before or after \nobreak. I know that the \beginsection macro (that left aligns the section title) is more complex than that but I don't understand what benefits it has.

1 Answer 1

5

You need the penalty before the skip otherwise you can ge a break:

enter image description here

\def\section#1{\bigbreak\centerline{\bf #1}\medskip\nobreak}

\def\text{Aaaa bbb ccc one two three four five.
Red blue green yellow white black. }


\text\text
\section{1 abc}
\text\text

\section{2 aabbcc}
\text\text

\vskip 40\baselineskip

\text

\section{3 aa}

\text\text

\bye

If you swap them round you get

enter image description here

Other than that, apart from using a centered box and a braced argument rather that \par delimited, it is more or less similar to the plain tex macro.

The main thing missing is control of indentation of the following paragraph, but perhaps you want indented first paragraphs anyway.

3
  • That makes sense, thank you. I don't need to control the indentation so it's perfect
    – user227615
    Mar 12, 2022 at 12:08
  • What else is missing is a |\mark| etc... Mar 12, 2022 at 12:08
  • @YiannisLazarides missing from a real section macro, but not mising compared with \beginsection which also doesn't do marks (not that I'd ever consider plain tex for a real document other than test examples that it is designed for) Mar 12, 2022 at 12:11

You must log in to answer this question.