Plain is awesome up until you'd want to make some structure for your document(s), because getting the sectioning macros right seems to be painfully difficult.

Plain comes with a single sectioning macro called \beginsection, but I would be interested in seeing your sectioning macro(s), or pointers to such definitions.

For you see, the problems I've had with making one are related to situations when there is a higher-level sectioning command directly followed by a lower-level sectioning command. Because normally I would indeed want there to be an allowance for page-break, but in the abovementioned case I'd certainly not want that. For clarity, by higher- and lower-level I mean a structure like (from highest to lowest):

  • Chapter
  • Section
  • Subsection
  • Subsubsection

So the question is: How can I make a sectioning macro which could differentiate between if it was used just after a higher-level sectioning command, or not

I chose not to post any example code because most of it would have nothing to do with the problem itself.

  • 1
    Couldn't you look at the relevant part of texdoc source2e to see how LaTeX does it and modify that? or would that be cheating? – Seamus Jan 6 '11 at 16:34
  • @Seamus: Thanks for the tip! What do I need for that command to work? (I've tried: texdoc source2e => command not found; tlmgr install texdoc; texdoc source2e => Sorry, no documentation found for source2e.) – morbusg Jan 6 '11 at 20:30

I'd use \vskip1sp\par at the end of a sectioning command. Then you can test this with \ifdim\lastskip=1sp. You can also use different numbers to check which of the commands is used. (1sp is so small that is has practically no effect.)

If you want to use \noindent, then a \vskip at the end would be a bad idea: use \noindent\hskip-1sp\hskip1sp\relax instead of the above; then again \ifdim\lastskip=1sp should do the job.

  • Why the \par? After the \vskip, you will already be in vertical mode. \par has (almost) no effect there. – TH. Jan 6 '11 at 20:23
  • Thank you very, very much, this seems like a perfect answer. You even went ahead and read my mind about the noindent! – morbusg Jan 6 '11 at 20:33
  • @TH.: I'm actually not sure anymore. I did some testing before I posted the answer, and I guess the \par got in since it didn't work without it: It has the same effect as \relax, but probably \relax is better. – Hendrik Vogt Jan 6 '11 at 21:23
  • Could you post the definition of an example sectioning command to provide a more complete context? – Christian Lindig Mar 18 '11 at 13:27
  • @Christian: Are you asking morbusg or me? Maybe morbusg can just give you what he's using. – Hendrik Vogt Mar 18 '11 at 16:24

I am not a plain TeX user, but the easy way seem the OPmac package:


\input opmac
\chap Example  of chapter\par  Some text 
\sec Section example\par  Some text
\secc Subsection example\par That is  all. 
  • Some reason for the downvote ? – Fran Feb 27 '16 at 22:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.