[Tex/LaTex] How to set page geometry for a single page only

afterpagegeometrymargins

I want to change the geometry for a single page only. I set the geometry for the whole document using:

\usepackage[left=1cm,right=2cm,vmargin=2.5cm,footnotesep=0.5cm]{geometry}

The geometry package provides the commands \newgeometry and \restoregeometry; however, the \newgeometry instruction forces a \clearpage. I just want to change the geometry for one page only, is that possible?


(Addendum applied by @JPi, 15 October 2017:)

The original question apparently didn't make sufficiently clear what the OP intended to achieve, and the (now-deleted) answer appears to correspond to a rather narrow interpretation of the question. I have added an MWE that has the special feature that the page with the different geometry is page 1. But a general solution to this question is sought.

Here is an example of a situation in which this would be useful; there are surely others.

\documentclass[12pt]{letter}

\usepackage[margin=1in]{geometry}
\usepackage{graphicx}
\usepackage{eso-pic}
\usepackage{lipsum}
\usepackage{afterpage}

\newcommand\BackgroundPicture{%
    \put(0,0){%
        \parbox[b][\paperheight]{\paperwidth}{%
            \vfill
            \centering
            \includegraphics[width=\paperwidth,height=\paperheight,%
            keepaspectratio]{letterhead.pdf}%
            \vfill
}}}


\begin{document}

\signature{Me}

\begin{letter}{You}
    \AddToShipoutPicture*{\BackgroundPicture}
%\vspace*{1.25in}  % sure this, works, but it's nasty

\newgeometry{margin=1in,top=3in}
\afterpage{\restoregeometry}

    \opening{Dear Sir/Madam,}

\lipsum

\closing{Yours mournfully,}

\end{letter}

\end{document}

(Another example added by @thymaro on 19 October 2017)

tl;dr Can you specify page geometries before the content is typeset on the pages?

Let's say I have a more or less 11 page document with, in it's preamble

\usepackage[whatever-paper-geometry,margin=2cm]{geometry}  %  keep it simple

I want page 3 of my document to have margins set to 10cm (that will be a vertically very narrow box of text) and I really couldn't care less what the text on that page is. As page 3 now contains almost no text any more, the document will be forced to extend to more or less 12 pages.

Can I (you? anyone?) define page geometry of page [1-2, 3, rest of the document*] in the preamble and then let the text flow into these receptacles?

  • "rest of the document" could really first be defined as page 4-20, and after compilation, see that there are only 12 pages and go back to define "rest of the document" as pages 4-12.

I hope this example does the original question justice.

Best Answer

Comment, 15 Oct 2017: The answer given below attempted to address the query as it was phrased originally, i.e., back in October 2012. I’m afraid the answer is not going to be of much interest to the query in its current (Oct. 2017) form.


With help from the afterpage package, the following should work for you:

% ... some material
\afterpage{%
\newgeometry{<options>}
% material for this page
\clearpage
\restoregeometry
} % end of \afterpage{...} material
% ... still more material