UK TeX FAQ -- question 136

### Changing the margins in LaTeX

Changing the size of the body of a LaTeX document's text is a surprisingly difficult task: the best advice to the beginner is "don't do it". There are interactions between fundamental TeX constraints, constraints related to the design of LaTeX, and good typesetting and design practice, that mean that any change must be very carefully considered, both to ensure that it "works" and to ensure that the result is pleasing to the eye.

Lamport's warning in his section on 'Customizing the Style' needs to be taken seriously. One-inch margins on A4 paper are fine for 10- or 12-pitch typewriters, but not for 10pt (or even 11pt or 12pt) type because readers find such wide, dense, lines difficult to read: there should ideally be no more than 75 characters per line (though the constraints change for two-column text).

LaTeX's controls allow you to change the distance from the edges of a page to the left and top edges of your typeset text, and the width and height of the text. Changing the last two requires more skill than you might expect: the height should bear a certain relationship to `\baselineskip`, and the width should be constrained as mentioned above.

The controls are expressed as a set of page parameters; they are somewhat complex, and it is easy to get their interrelationships wrong when redefining the page layout. The layout package defines a `\layout` command which draws a diagram of your existing page layout, with the dimensions (but not their interrelationships) shown. This FAQ recommends that you use a package to establish consistent settings of the parameters: the interrelationships are taken care of in the established packages, without you needing to think about them.

The 'ultimate' tool for adjusting the dimensions and position of the printed material on the page is the geometry package; a very wide range of adjustments of the layout may be relatively straightforwardly programmed, and documentation in the `.dtx` file is good and comprehensive.

Somewhat simpler to use is the vmargin package, which has a canned set of paper sizes (a superset of that provided in LaTeX2e), provision for custom paper, margin adjustments and provision for two-sided printing.

If you're still eager to "do it yourself", start by familiarising yourself with LaTeX's page layout parameters. For example, see section C.5.3 of the LaTeX manual (pp. 181-182), or corresponding sections in many of the other good LaTeX manuals (see LaTeX books). The parameters `\oddsidemargin` and `\evensidemargin` are so-called because it is conventionally taken that odd-numbered pages appear on the right-hand side of a two-page spread ('recto') and even-numbered pages on the left-hand side ('verso'). Both parameters refer to the left-hand margin; the right-hand margin is specified by implication, from the size of `\textwidth`. The origin in DVI coordinates is one inch from the top of the paper and one inch from the left side; positive horizontal measurements extend right across the page, and positive vertical measurements extend down the page. Thus, for margins closer to the left and top edges of the page than 1 inch, the corresponding parameters, i.e., `\evensidemargin`, `\oddsidemargin`, `\topmargin`, can be set to negative values.

Another surprise is that you cannot change the width or height of the text within the document, simply by modifying the text size parameters. The simple rule is that the parameters should only be changed in the preamble of the document, i.e., before the `\begin{document}` statement. To adjust text width within a document we define an environment:

    \newenvironment{changemargin}[2]{%
     \begin{list}{}{%
      \setlength{\topsep}{0pt}%
      \setlength{\leftmargin}{#1}%
      \setlength{\rightmargin}{#2}%
      \setlength{\listparindent}{\parindent}%
      \setlength{\itemindent}{\parindent}%
      \setlength{\parsep}{\parskip}%
     }%
    \item[]}{\end{list}}

This environment takes two arguments, and will indent the left and right margins, respectively, by the parameters' values. Negative values will cause the margins to be narrowed, so `\begin{changemargin}{-1cm}{-1cm}` narrows the left and right margins by 1cm.

The chngpage package provides ready-built commands to do the above; it includes provision for changing the shifts applied to your text according to whether you're on an odd or an even page of a two-sided document. The package's documentation (in the file itself) suggests a strategy for changing text dimensions between pages - as mentioned above, changing the text dimensions within the body of a page may lead to unpredictable results.

`chngpage.sty`
  macros/latex/contrib/supported/misc/chngpage.sty
`geometry.sty`
  macros/latex/contrib/supported/geometry.tar.gz
`layout.sty`
  Distributed as part of macros/latex/required/tools.tar.gz
`vmargin.sty`
  macros/latex/contrib/supported/vmargin.tar.gz