0

In TeXbook p.110 it is said:

...computing badness ratings ... more or less as it does when breaking paragraphs into lines.

On page 112 of TeXbook there is example of page building. Let's use this example to calculate glue set ratio:

\input manmac
\tracingpages=1
\tracingoutput=1
\showboxdepth=2
\showboxbreadth=\maxdimen
\TeX\ attempts to choose desirable places to divide your document into
individual pages, and its technique for doing this usually works pretty
well. But the problem of ^{page make-up} is considerably more difficult
than the problem of line breaking that we considered in the previous chapter,
because pages often have much less flexibility than lines do. If the
vertical glue on a page has little or no ability to stretch or to shrink,
\TeX\ usually has no choice about where to start a new page; conversely, if
there is too much variability in the glue, the result will look bad because
different pages will be too irregular. Therefore if you are fussy about the
appearance of pages, you can expect to do some rewriting of the manuscript
until you achieve an appropriate balance, or you might need to fiddle
with the ^|\looseness| as described in Chapter~14; no automated system will
be able to do this as well as you.

Mathematical papers that contain a lot of displayed equations have an
advantage in this regard, because the glue that surrounds a display tends to
be quite flexible. \TeX\ also gets valuable room to maneuver when you
have occasion to use ^|\smallskip| or ^|\medskip| or ^|\bigskip| spacing
between certain paragraphs. For example, consider a page that contains
a dozen or so exercises, and suppose that there is $3\pt$ of additional
space between exercises, where this space can stretch to $4\pt$ or
shrink to $2\pt$. Then there is a chance to squeeze an extra line on the page,
or to open up the page by removing one line, in order to avoid splitting
an exercise between pages. Similarly, it is possible to use flexible
glue in special publications like membership rosters or company telephone
directories, so that individual entries need not be split between columns
or pages, yet every column appears to be the same height.

For ordinary purposes you will probably find that \TeX's automatic method
of page breaking is satisfactory. And when it occasionally gives
unpleasant results, you can force the machine to break at your favorite
place by typing `^|\eject|'. But be careful: |\eject| will cause \TeX\ to
stretch the page out, if necessary, so that the top and bottom baselines
agree with those on other pages. If you want to eject a short page,
filling it with blank space at the bottom, type `|\vfill\eject|' instead.

\danger If you say `|\eject|' in the middle of a paragraph, the paragraph
will end first, as if you typed `|\par\eject|'. But Chapter~14 mentions
that you can say `^|\vadjust||{\eject}|' in mid-paragraph, if you want to
force a page break after whatever line contains your current position
when the full paragraph is eventually broken up into lines; the rest of the
paragraph will go on the following page.

\danger To prevent a page break, you can say `^|\nobreak|' in vertical
mode, just as |\nobreak| in horizontal mode prevents breaks between lines.
For example, it is wise to say |\nobreak| between the title of a subsection
and the first line of text in that subsection. But |\nobreak| does not
cancel the effect of other commands like |\eject| that tell \TeX\ to
break; it only inhibits a break at glue that immediately follows. You
should become familiar with \TeX's rules for line breaks and page breaks
if you want to maintain fine control over everything. The remainder of
this chapter is devoted to the intimate details of page breaking.

\ninepoint
\danger \TeX\ breaks lists of lines into pages by computing badness ratings
and penalties, more or less as it does when breaking paragraphs into lines.
But pages are made up one at a time and removed from \TeX's memory; there is
no looking ahead to see how one page break will affect the next one.
In other words, \TeX\ uses a special method to find the optimum
breakpoints for the lines in an entire paragraph, but it doesn't attempt
to find the optimum breakpoints for the pages in an entire document. The
computer doesn't have enough high-speed memory capacity to remember the
contents of several pages, so \TeX\ simply chooses each page break as best
it can, by a process of ``local'' rather than ``global'' optimization.
\bye

Now run TeX on this file:

tex o.tex

Then use the log file to calculate glue set ratio (see p.77 in TeXbook):

1) natural height of boxes:

$ sed -n '/\.\\vbox(528.0/,/^$/{p;/^$/q}' o.log|perl -ne 'print if s/^\.\.\\hbox\(([\d\.]+\+[\d\.]+)\).*/$1/'|paste -s -d+|bc -l
385.09693

2) natural height of glue:

$ sed -n '/\.\\vbox(528.0/,/^$/{p;/^$/q}' o.log|perl -ne 'print if s/^\.\.\\glue(?:\(.*\))? ([\d\.]+)$/$1/'|paste -s -d+|bc -l
129.65283

3) height is less than required, so we need glue stretchability:

$ sed -n '/\.\\vbox(528.0/,/^$/{p;/^$/q}' o.log|perl -ne 'print if s/^\.\.\\glue(?:\(.*\))? [\d\.]+ plus ([\d\.]+).*/$1/'|paste -s -d+|bc -l
8.0

Glue set ratio is then:

(528.0-(385.09693+129.65283))/8.0 = 1.65628

But log file shows: "glue set 0.375".

How to calculate ratio for vertical list?

1

There was an error in the script in case 2). It should have been:

sed -n '/\.\\vbox(528.0/,/^$/{p;/^$/q}' o.log|perl -ne 'print if s/^\.\.\\glue(?:\(.*\))? ([\d\.]+).*/$1/'|paste -s -d+|bc -l

Also, depth of last box does not participate in calculations of glue set ratio (i.e., 1.75 in \vbox(528.0+1.75)).

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.