🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text.tex
Article #2060

Obeying \penalty when \vsplitting into 3 cols

#2060
From: Peter Flynn, Official Muffin-sam...
Date: Thu, 03 Sep 1992 11:26
54 lines
2450 bytes
I have an application which is to print a list in three columns. The list
is subdivided into section, so the input goes

\sectionhead{heading}
\entry{text}
\entry{text}
\entry{text}
...
\sectionhead{heading}
\entry{text}
[etc]

I have extended Knuth's two-col code which uses \vsplit in the output routine
and it works fine for 99% of cases. The \balancetriplecolumns routine,
however (to get the final page into three shorter cols to finish up with)
occasionally splits the stuff up so that a heading appears at the bottom
of the column, with the text belonging to it at the top of the next column.
The macro for \sectionhead includes:

     \flexbreak\hbox{}
     \noindent{\sbf#1}\nobreak\smallskip\hrule\nobreak\medskip\nobreak%

with

\newskip\flexskipamount
\flexskipamount=1pc plus3pc minus.5pc
\def\flexbreak{\par\penalty-500 \vskip\flexskipamount}

to try and avoid this effect, but one one occasion it's breaking between the 
{\bf #1} and the \hrule, so the next column starts with a \hrule. I've tried the \penalty more negative, but that introduces masses of whitespace at the bottom 
of other columns on other pages in the printout and still doesn't fix the final
page.

The \balancetriplecolumns says (extraneous guff removed)

\def\balancethreecolumns{\setbox0=\vbox{\unvbox255} \dimen@=\ht0
  \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip
  \divide\dimen@ by3   \splittopskip=\topskip
  {\vbadness=10000 \loop 
                   \global\setbox3=\copy0
                   \global\setbox1=\vsplit3 to\dimen@
                   \global\setbox1=\vsplit3 to\dimen@
                   \ifdim\ht3>\dimen@ \global\advance\dimen@ by1pt 
                   \repeat}
  \setbox255=\vbox{\unvbox0}

and then \vsplits \box255 into a left, middle and right column. What puzzles me
is that when the problem occurs, it is breaking at a place where there is an
explicit \nobreak (between heading and \hrule) instead of where there is a
negative penalty and a goodish amount of flexibility. 

Clearly I have misunderstood something. What?

///Peter
Technical Details
Message-ID: <1992Sep3.112627.49606@ccvax.ucd.ie>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!ieunet!ccvax.ucd.ie!pflynn

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!ieunet!ccvax.ucd.ie!pflynn
From: pflynn@ccvax.ucd.ie (Peter Flynn, Official Muffin-sampler)
Newsgroups: comp.text.tex
Subject: Obeying \penalty when \vsplitting into 3 cols
Message-ID: <1992Sep3.112627.49606@ccvax.ucd.ie>
Date: 3 Sep 92 11:26:27 GMT
Organization: University College Dublin
Lines: 54