5.2 Cambiando el diseño
When you want to redefine the value of one or more page layout parameters, the and commands should be used. It is important to keep in mind that changes to the geometrical page layout parameters should be made only in class or package files and/or in the preamble (i.e., before the \begin{document} command). Although changing them mid-document is not absolutely impossible, it most likely produces havoc, due to the inner workings of TEX, which involve a number of subtle dependencies and timing problems. For example, if you change the , you might find that the running header of the previous page is changed.
5.2.1 layouts - Mostrando su diseño
To visualize your layout parameter settings and help you experiment with different values there are two packages available. The package layout (originally written by Kent McPherson and converted to LaTEX 2ε by Johannes Braams) provides the command , which produces a graphical representation of the current page parameters with all sizes reduced by a factor of two. If the class option twoside is used, then two pages are produced. In Figure 5.1 on page 367 this package was used to produce the graphic (using landscape document design to save space).
A more flexible solution is provided by the package layouts written by Peter Wilson and now maintained by Will Robertson. This package can be used for two purposes: to produce an abstract graphical representation of the layout parameters (not reflecting the current settings) via (as shown in the next example) or to produce trial layouts that show the effect of setting parameters to trial values and then applying the command . In either mode sets the scale factor to the specified value.
We make use of this package in several examples in the book to display some aspects of page design. However, we use a slightly extended version in order to highlight some aspects normally not shown. Thus, repeating the examples might give you slightly different results until this code is integrated into the distributed version.
5.2.2 Una colección de paquetes de diseño de página
Because the original LaTEX class files were based on American page sizes, European users developed several packages that adapt the page layout parameters for metric sizes. All such packages are superseded by the typearea or geometry package (described in the next two sections). Because you can find the original attempts still in the archives or see them in older documents, we mention them here in passing.
Examples of such packages are a4, which generates rather small pages; a4dutch (by Johannes Braams and Nico Poppelier), which is well documented; and a4wide (by Jean-François Lamy), which produces somewhat longer lines. Moreover, often there exist locally developed files under such names. For A5 pages one has the package files a5 and a5comb (by Mario Wolczko). The problem with all of these early packages was that they allowed little to no customization with respect to the size and placement of the text area, and, for some of them, incompatible implementations exist.
We therefore strongly suggest that you do not use any of these old packages for new documents, but instead either typearea (automatically loaded by KOMA-Script document classes) or geometry, which provides you with all the flexibility that you may ever need and easy ways to specify any special requirements.
5.2.3 typearea - Un enfoque tradicional
In books on typography one usually finds a section that deals with page layout, often describing construction methods for placing the text body and providing one or the other criterion for selecting text width, number of text lines, relationship between margins, and other considerations.
The package typearea by Markus Kohm and Frank Neukam, which is distributed as part of the KOMA-Script bundle [101, 102], offers a simple way to deploy one of the more traditional page layout construction methods that has been used for many books since the early days of printing.
In a nutshell, the page layout generated by typearea provides a text body with the same spatial relationship as given by the paper size on which the document is being printed. In addition, the outer margin will be twice as wide as the inner margin, and the bottom margin will be twice as wide as the top margin.
The construction method works by dividing the paper horizontally and vertically into n equal slices and then using one slice at the top and inner edges and two slices at the bottom and outer edges for the margins. By default, the variable n is calculated automatically by the package, but there are a number of options to alter that behavior; one is to use the key option DIV=n (see the package documentation for details).
The page height resulting from the chosen or calculated value is automatically adjusted to produce an integral number of text lines. For this approach to work, the effective used throughout the document has to be established first. Thus, when using a package like setspace or applying the command , this step should be taken prior to loading typearea.
To define the paper size, typearea offers all of the paper size options of LaTEX’s standard classes (see Table 5.1 on page 368) as well as all sizes of the ISO-A, ISO-B, and ISO-C series (e.g., a0paper or c5paper). To change the text orientation use landscape, as in the example below. We use commands from the layouts package to define a command for displaying the resulting layout. This command is also used in several other examples in this chapter.
5.2.4 geometry - Especificación de diseño con autocompletado
The geometry package written by UMEKI Hideo now maintained by David Carlisle provides a comprehensive and easy-to-use interface to all geometrical aspects of the page layout. It deploys the keyval package so that all parameters (and their values) can be specified through key/value pairs in a setup command or alternatively as options to the
declaration.
In contrast to the typearea package, geometry does not implement a certain typographical concept but rather carries out specifications as requested. It knows, however, about certain relationships between various page parameters and in the case of incomplete specifications can calculate the remaining parameter values automatically. The following example shows a layout very similar to the one produced by typearea in Example 5-2-4 on the facing page. Here a number of values have been explicitly set (e.g., those for the top and left margins), but the size of the page body has been automatically calculated from the paper size (a5paper), the values for top margin (tmargin), and left margin (lmargin), and a specified margin ratio of 1:2 (marginratio).
5.2.5 lscape - Composición tipográfica de páginas individuales en modo horizontal
For most documents the longer side of the paper corresponds to the vertical direction (so-called portrait orientation). However, for some documents, such as slides and tables, it is better to use the other (landscape) orientation, where the longer side is horizontally oriented. Modern printers usually allow printing in both orientations.
The landscape and portrait orientations require different page layouts, and with packages like geometry you have the tools at hand to design them as needed. But sometimes it is desirable to switch between portrait and landscape mode for only some pages. In that case the previously discussed packages do not help, because they set up the page design for the whole document.
For this case you can use the lscape package by David Carlisle that defines the environment landscape to typeset a selected set of pages in landscape orientation without affecting the running header and footer. It works by first ending the current page (with , thereby typesetting any dangling floats). It then internally exchanges the values for and and rotates every produced page body within its scope by 90 degrees. For the rotation it deploys the graphics package, so it works with any output device supported by that package capable of rotating material. When the environment ends, it issues another before returning to portrait mode.
If you view a document with a few rotated pages on the screen, then you have to lean sidewise to read such pages because with most dvi viewers the page orientation will stay fixed for the whole document. However, if the output format of your document is PDF, you can ask for those pages to be also rotated within the viewer program by using the package pdflscape (by Heiko Oberdiek), which is a frontend to lscape and provides that type of rotation support.
For rotating individual floats, including or excluding their captions, a better alternative is provided by the rotating package, described in Section 7.3.3.
5.2.6 savetrees - Opciones para reducir la longitud del documento
If you are pressed for space (for example, because of a page limit of a publication) or if you want to simply save on printed pages during the development of your document, you may want to try Scott Pakin’s savetrees package.
Its whole purpose is to direct LaTEX to save on space whenever possible either with or without altering your layout, and it is controlled by passing options to it when it is loaded. The three main options are subtle, which does not change the layout but makes LaTEX try harder to produce less space; moderate, which additionally introduces moderate layout modifications; and extreme, which turns on everything the package knows about space saving including using all of the page including most of its margins.
If these alternatives are too coarse-grained, then many individual options are available to turn individual features on or off or adjust their behavior by supplying specific parameter values; for details consult the package documentation. Below we have used extreme but turned off the layout changes of the margins, because otherwise the whole A4 paper would have been used. As a result, the paragraph is reduced by one line by using negative character tracking, and additionally the has been slightly reduced. The result is clearly inferior compared with LaTEX’s normal typesetting quality, but the goal to save space is met.