TeXbook 第 110 页中有话说:
...计算不良程度评级...与将段落分成行时的操作大致相同。
TeXbook 第 112 页有页面构建的示例。让我们使用此示例计算胶水固化率:
\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
现在对此文件运行 TeX:
tex o.tex
然后使用日志文件计算胶水凝固率(参见 TeXbook 第 77 页):
1)箱子的自然高度:
$ 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)胶水自然高度:
$ 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)高度小于要求,因此我们需要胶水的拉伸性:
$ 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
胶水固化比率为:
(528.0-(385.09693+129.65283))/8.0 = 1.65628
但日志文件显示:“ glue set 0.375
”。
如何计算垂直列表的比例?
答案1
案例 2) 中的脚本有错误,其应该是:
sed -n '/\.\\vbox(528.0/,/^$/{p;/^$/q}' o.log|perl -ne 'print if s/^\.\.\\glue(?:\(.*\))? ([\d\.]+).*/$1/'|paste -s -d+|bc -l
此外,最后一个盒子的深度不参与胶水凝固率的计算(即1.75
)\vbox(528.0+1.75)
。