The problem is as follows.

In a memoir document, I defined the page geometry:


Then I defined an environment to put a piece of text dead centre on a page:


When using this environment,

What is the Noble Truth of Suffering? ...

Saṃyutta Nikāya 56.11, Dhammacakkappavattana Sutta

The next page (the one after \restoregeometry was called) will begin with good header and textwidth, but the page content runs way off the page at the bottom. The page after that has good header, footer, text width, height and all.

text runs off the page

However, this doesn't happen if I don't use an environment. If I just copy-paste the code which the environment should insert, the page after \restoregeometry is good, and so are the rest.

Very puzzling. Something is going wrong with how I defined the environment, but I can't figure it out. Can someone see the problem?

2 Answers 2


You're using a group too many and don't restore properly the geometry, as the \restoregeometry command is issued when LaTeX is still processing the environment, which forms a group:


You may want to look at other solutions, for example TikZ provides the ability to put nodes at the physical page center.

   \begin{tikzpicture}[remember picture,overlay]  
   \node at (current page.center) {\usebox{\quotepagebox}};
  • Thanks for the neat codeblock! I'll look into the tikz node business too, sounds much simpler.
    – Gambhiro
    Jan 9, 2012 at 10:35
  • @Nyiti You may want to look at the code provided in my last edit.
    – egreg
    Jan 9, 2012 at 10:48
  • @egreg that works, but it removes \doublespacing in my case. Is that intentional?
    – ghx
    Jul 8, 2020 at 1:32
  • @ghx That might depend on many factors; please, ask a new question with all the needed details.
    – egreg
    Jul 8, 2020 at 7:28
  • @egreg ok please see: tex.stackexchange.com/questions/552734/…
    – ghx
    Jul 8, 2020 at 12:50

As egreg said, \restoregeometry must be executed outside the environment.

You can use the \AfterEndEnvironment-hook from the etoolbox package for that.

From the etoolbox documentation:


Appends arbitrary code to a hook executed at a very late point by the \end command, after the group holding the environment has been closed.






Output of the MWE in dual view. Despite page 2 having newgeometry, text on page 3 does not run off the page bottom.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .