When finalizing documents, one of the last things I do is usually to play with the page geometry to improve the overall layout: get rid of a few orphans or widows, reduce the number of hyphenations, etc.
I usually start by designing my documents with an acceptable or imposed/suggested page geometry, say
but more often than not (if not always), I can actually replace that
0.75 (as an example) by anything in between
0.77 (because even when the page geometry is supposedly "mandatory", most people won't notice the difference...).
My process so far is however manual, tedious and quite subjective, basically trying out different
scale options and picking the one most pleasing to my eye...
A better process would be to have TeX output a few typographical indicators or, better, a global "badness" indicator for the whole document, and then use a small script to optimize the
scale factor based on this. So here are my few related questions:
a) Is it possible to have TeX output such typographic quality indicators such as:
- The number of widows,
- The number of orphans,
- The number of hyphens,
- The standard and maximum inter-word spacing,
- The number of lines with inter-word spacing greater than twice the standard value, and
- Any other relevant typographic quality indicator you believe is useful? (I am assuming cardinal sins like overfull boxes have been dealt with in all cases).
b) For widows, orphans, hyphens and similar relevant grave sins, would it be possible to modify TeX's output routine to identify where they happen? Either directly inside the document, as a Warning in the log, or both at choice (as happens for over- and under-full
Is it possible to get TeX to output a global quality / badness indicator for the whole document? I know TeX works with a system of penalties internally; is it possible to output the penalty total for the whole document, and would that be an appropriate metric for my optimization desire?
(Note: the answer does not have to work on every engine; in particular, Lua code is perfectly acceptable as I guess the question draws to some of the stated objectives of
luatex to "open up the internals of TeX")