Changing margins “on the fly”

One of the surprises characteristic of TeX use is that you cannot change the width or height of the text within the document, simply by modifying the text size parameters; TeX can’t change the text width on the fly, and LaTeX only ever looks at text height when starting a new page.

So the simple rule is that the parameters should only be changed in the preamble of the document, i.e., before the \begin{document} statement (so before any typesetting has happened.

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}}

The 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 1 centimetre.

Given that TeX can’t do this, how does it work? — well, the environment (which is a close relation of the LaTeX quote environment) doesn’t change the text width as far as TeX is concerned: it merely moves text around inside the width that TeX believes in.

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.

Changing the vertical dimensions of a page is clunkier still: the LaTeX command \enlargethispage adjusts the size of the current page by the size of its argument. Common uses are

\enlargethispage{\baselineskip}

to make the page one line longer, or

\enlargethispage{-\baselineskip}

to make the page one line shorter.

chngpage.sty
macros/latex/contrib/misc/chngpage.sty

This question on the Web: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=chngmargonfly