5.4 Estilos de página
While the dimensions remain the same for almost all pages of a document, the format of the running headers and footers may change in the course of a document. In LaTEX terminology the formatting of running headers and footers is called a page style, with different formattings being given names like empty or plain to be easily selectable. New page styles can be selected by using the command or the command , both of which take the name of a page style as their mandatory argument. The first command sets the page style of the current and succeeding pages; the second applies to the current page only.
In small or medium-size documents sophisticated switching of page styles is normally not necessary. Instead, one can usually rely on the page styles automatically selected by the document class. For larger documents, such as books, typographic tradition, publisher requirements, or other reasons might force you to manually adjust the page style at certain places within the document.
5.4.1 La interfaz de estilo de página de bajo nivel
Internally, the page style interface is implemented by the LaTEX kernel through four internal commands, of which two are called on any one page in order to format the running headers and footers. By redefining these commands different actions can be carried out.
@oddhead For two-sided printing, it generates the header for the odd-numbered pages; otherwise, it generates the header for all pages.
@oddfoot For two-sided printing, it generates the footer for the odd-numbered pages; otherwise, it generates the footer for all pages.
@evenhead For two-sided printing, it generates the header of the even-numbered pages; it is ignored in one-sided printing.
@evenfoot For two-sided printing, it generates the footer of the even-numbered pages; it is ignored in one-sided printing.
A named page style simply consists of suitable redefinitions for these commands stored in a macro with the name @⟨style⟩; thus, to define the behavior of the page style style, one has to (re)define this command. As an example, the kernel definition of the plain page style, producing only a centered page number in the footer, is similar to the following code:
5.4.2 fancyhdr - Personalización de estilos de página
Given that the page styles of standard LaTEX allow modification only via internal commands, it is not surprising that a number of packages have appeared that provide special page layouts. For example, the page style declaration features of the package titlesec (for defining heading commands, see Section 2.2.7) are worth exploring.
A well-established stand-alone package in this area is fancyhdr by Pieter van Oostrum, which allows easy customization of page headers and footers [160]. The default page style provided by fancyhdr is named fancy. It should be activated via after any changes to are made, as fancyhdr initializes the header and footer widths using the current value of this length.
The look and feel of the fancy page style is determined by six declarations that define the material that appears on the left, center, and right of the header and footer areas. For example, specifies what should show up on the left in the header area, while defines what appears in the center of the footer area. The results of all six declarations are shown in the next example.
5.4.3 truncate - Truncar texto a una longitud determinada
A potential problem when producing running headers or footers is the restricted space available: if the text is too long, it simply overprints. To help in this and similar situations you can deploy the package truncate written by Donald Arseneau. It provides a command to truncate a given text to a given width.
5.4.4 continue - Ayuda para pasar páginas
Sometimes it is advantageous to give the readers additional hints about what is coming up on the next page. For example, when the text is being read out, showing the first word from the next page helps to avoid any hesitation when it comes to a page turn. Another application is exam papers; clearly indicating that the back of the page has further tasks to tackle might avoid last-minute panics of the students discovering this too late.
For the first type of design, Donald Arseneau developed a cute little package called fwlw (first word/last word), and for the second task there is turnthepage by Luca Merciadri. Both packages have been combined (and slightly modified) by Peter Wilson in his continue package that we are going to describe here.
If used without options, the package helps with the basic page turn by displaying the content of at the bottom of a recto page (default is the word “Continued”) unless it is the last page, in which case the content of (default “End”) is shown. By appropriately redefining either or both commands you can easily arrange for your own style of continuation markers.