5.6 Formato visual
The final stage of the production of an important document often needs some manual formatting to avoid bad line or page breaks. In this section we look at various tools and methods to deal with such tasks.
We first look at pagination and show ways to alter it, for example by running some pages long or short. This is followed by a package that offers extensions to and that supports conditional page breaks depending on the remaining available space.
We then turn to problems in paragraphs and take a detailed look at how to detect and avoid so called widows and orphans, i.e., single lines of a paragraph at the end or beginning of a page.
Finally, we discuss the command that directs TEX to alter the paragraph breaking algorithm to lengthen or reduce paragraphs by a line or more. This approach can save the day in difficult situations, especially if it is impossible to alter the textual material.
5.6.1 Herramientas estándar para saltos de página explícitos
For explicit page break standard LaTEX offers the , , , and commands as well as the declaration, although the latter is considered obsolete in LaTEX 2ε. A declaration together with a suitable number of commands lets you request that a certain portion of your document be kept together.
Unfortunately, the results are often not satisfactory; in particular, LaTEX never makes a page larger than its nominal height (i.e., ) but rather moves everything in the scope of the declaration to the next page. The LaTEX 2ε command * described below offers an alternative approach.
5.6.2 Ejecutar páginas y columnas cortas o largas
It is common in book production to “run” a certain number of pages (normally double spreads) short or long to avoid bad page breaks later. This means that the nominal height of the pages is reduced or enlarged by a certain amount— for example, a . To support this practice, LaTEX 2ε offers the command .
5.6.3 addlines - Ajustar spreads dobles completos
As already alluded earlier altering the page height normally has to be done on both verso and recto pages in unison to avoid a ragged look of the spread. This means one usually has to use two identical commands, one for each page. To simplify this approach Will Robertson wrote the addlines package that provides a wrapper around the commands discussed in the previous section.
5.6.4 nextpage - Extensiones para borrar página
In standard LaTEX the commands and terminate the current paragraph and page after placing all dangling floats (if necessary, by producing a number of float pages). In two-sided printing also makes sure that the next page is a right-hand (odd-numbered) one by adding, if necessary, an extra page with an empty text body. However, this extra page still gets a page header and footer (as specified by the currently active page style), which may or may not be desirable.
5.6.5 needspace - Iniciar condicionalmente una nueva página
Instead of unconditionally requesting a new page with one of the commands discussed in the previous sections, you may want to just reserve a certain amount of space and skip to the next if that space is not available on the current page but otherwise continue as normal. A typical example is something like an index section that you may want to start immediately if there is still more than X lines of space available.
For this type of application Peter Wilson developed the needspace package (now maintained by Will Robertson). It offers two commands for this purpose.
5.6.6 Evitar viudas y huérfanos
Splitting off the first or last line of a paragraph at a page or column break is considered bad practice in typesetting circles. It is thus not surprising that the craftspeople have come up with fairly descriptive names for such lines when they appear in typeset documents. Commonly used are the terms “widow” for the last and “orphan” for the first line. These are, for example, used in English, French (“veuve” and “orpheline”), Italian (“Vedova” and “Orfano”), Spanish (“línea huérfana” and “línea viuda”), and to a lesser extent in German (“Witwe” and “Waise”). One way to remember them is to think of orphaned lines appearing at the start (birth) and widows near the end (death) of a paragraph or by using Bringhurst’s mnemonic, “An orphan has no past; a widow has no future” [25].
German typesetters coined some more profane descriptions by calling the widow line a “Hurenkind” (child of a whore) and the orphan line a “Schusterjunge” (son of a shoemaker) allegedly because these boys have been notoriously meddlesome. For German practitioners these are still the predominantly used terms, though “Witwen” and “Waisen” are also well understood. Dutch uses “hoerenjong” and “weeskind”, which translates to son of a whore and orphan, i.e., somewhere in between the German usage and the other languages.
Donald Knuth catered for this typographic detail in the TEX program by providing parameters whose values are used as penalties if the pagination algorithm considers breaking in such a place. Widow lines are penalized via ; however, orphans are not controlled by , as one might expect, but by a parameter named . Again, note that these parameters (and those discussed later in this section) are all TEX counters and get their value assigned with the ⟨parameter⟩=⟨integer⟩ syntax.
Essentially everyone in typography circles agrees that widows and orphans are very distracting to the reader as well as a sign of bad craftsmanship and should therefore be avoided. In fact, most writing guides and other books on typography generally suggest that a document should have no such lines whatsoever, e.g., in older editions of the Chicago Manual of Style we find “A page should not begin with the last line of a paragraph unless it is full measure and should not end with the first line of a new paragraph.” However, that is easier said than done, so in newer editions of the Chicago Manual of Style [40] they no longer forbid orphans; i.e., they dropped the second part of the advice.
As a result of this sort of guidance many journal classes for LaTEX completely forbid widows and orphans by setting and to 10000, which prohibits a break at such points.
Doing this introduces severe problems: Because LaTEX (and in fact all major typesetting systems to date) use a greedy algorithm1 to determine the pagination of a document, they recognize problems with orphan or widow lines late in the game and then have only the current page to work with. This means the best it can do to avoid the situation is to push an orphan to the next page if there is not enough room to squeeze in another line. The same happens with widows; here LaTEX is forced to move the second-to-last line to the next page even though it would still nicely fit.
As a result the current page has an additional line-height worth of white space that needs to be distributed somewhere on the page. If there are headings, displays, lists, or other objects for which the design allows some flexibility in the surrounding white space, then this extra space may not create much of an issue. If, however, the page consists only of text or objects without any flexibility, then all LaTEX can do is run the page or column short, generating a fairly ugly hole at the bottom.
Besides widows and orphans there are a number of similar issues that typography manuals mandate eliminating if at all possible. One is a paragraph split across pages at a hyphenation point so that only a part of the word is visible at any time; another is a widow line with a following display formula. For both, TEX offers parameters to control the undesirability of the scenario. By default Donald Knuth considered them of lesser importance and provided default values of 100 and 50 for and , respectively, while he specified 150 for orphans and widows. However, if your style guide (or your class file) wants to avoid them at all costs, then you are in precisely the same situation as with the widows and orphans discussed above.
A special variation of the last issue is a display formula starting a page, that is, with the introductory material completely on the previous page or column. That is considered a no-no by nearly everybody, so in TEX the controlling parameter has by default a value of 10000. Again, there may be valid reasons to ignore this advice in a special situation, e.g., when the space constraints are high.
The alternative to preventing widows and orphans (or hyphens across page boundaries, etc.) automatically and at all costs is to manually resolve the issues when they arise. For this one finds a number of suggestions in the typography literature. We discuss those that are easy to apply in a LaTEX document below. A more extensive discussion of the subject is given in [136].
5.6.7 widows-and-orphanus - Encontrar a todas las viudas y huérfanos
If the document class you use sets and to 10000, then LaTEX automatically prevents widows and orphans, i.e., an orphan is forced to the top of the next page or column and the same happens to the line preceding a widow. The downside, as discussed previously, is partly empty pages, and if space is a premium (for example, if your conference paper is not allowed to be more than X pages in total), then this is a possible problem. Thus, you are better off allowing widows and orphans (by changing these parameter values) and manually correcting any issue during the final stage of the document production in one way or another.
The question then becomes, how do you identify the problematic page breaks without manually going through the printout of your document and searching for them? While that is certainly an option, it is error prone, and it would be much nicer if LaTEX (even if it cannot automatically resolve the issues for you) at least identifies them so that you only have to check the problem pages.
This is possible by simply loading the package widows-and-orphans by Frank Mittelbach. This package adjusts the parameter values slightly so that all possible combinations if added up lead to distinctive numbers. For example, instead of the LaTEX default values, it would choose
5.6.8 looseness - Acortar o alargar párrafos
As discussed earlier TEX (and therefore LaTEX) uses a globally optimizing line-breaking algorithm to find the best breaks for a given paragraph based on a given set of parameters. It is, however, possible to ask TEX to try to find a solution (within given quality boundaries) that is a number of lines longer or shorter than the optimal result. If such a solution exists, it is used; if not, then TEX tries to match the request as closely as possible. This manual method can be used to resolve pagination issues such as widows or orphans or other problems with the page breaking.
The paragraph will still be optimized (under the new conditions), i.e., its overall gray level will be fairly uniform, etc., but, inevitably, the interword spacing gets looser or tighter in the process, because this is the only parameter that TEX can adjust.
To activate this feature you need to set the TEX counter to the desired value. This has to be done inside or directly in front (no blank line allowed!) of the paragraph text via low-level TEX syntax, because there is no LaTEX interface available.