0

Currently, I am working on a package for an association. I am trying to achieve the following: the geometry of the first page should be different from all the following pages. There are some questions answered that achieve exactly what I want, however, when I try to use these answers myself, they do not seem to actually work.

From Question 449245, the following code:

\usepackage{geometry}
\geometry{
    top=3cm,
    hmargin=1in,
}
\usepackage{mwe}
\usepackage{afterpage}
\begin{document}
\newgeometry{top=8cm}
\afterpage{\aftergroup\restoregeometry}
\lipsum
\lipsum
\end{document}

The question provides exactly what I want to achieve, but the provided solution does not actually work for me:text still running of the page

Does anybody know why this solution does not work anymore? Is there a way to fix the code? Thanks in advance.

3
  • 1
    The problem is that the big paragraph in page 2 will trigger the page breaking mechanism too late for \restoregeometry to enter into action, so the second page is built with conflicting page parameters. If your need is because of a different header in the first page, this can be accommodated in different ways. The \afterpage command works when it does, which unfortunately isn't always.
    – egreg
    Feb 21, 2021 at 16:32
  • both \restoregeomety and (especially) \afterpage are far more fragile than you need here and \afterpage{\aftergroup\restoregeometry} with an \aftergroup does the restore at an essentially unknown point. Why do you need to change the geometry at all compared to simply using \vspace*{...} to adjust the start on the first page? Feb 21, 2021 at 16:33
  • is this a duplicate of tex.stackexchange.com/a/420324/1090 Feb 21, 2021 at 16:40

1 Answer 1

0

After trying a bit more, I found that using \globaldefs=1 instead of \aftergroup seemed to resolve any issues I still faced.

6
  • I doubt that \restoregeometry has ever been tested with \globaldefs=1 it might possibly work in some cases but any behaviour would be undefined, it certainly isn't supported by the package. Feb 21, 2021 at 16:37
  • Sorry, but \globaldefs=1 is a very dangerous way of living.
    – egreg
    Feb 21, 2021 at 16:37
  • Any suggestions for a more reliable way then \globaldefs=1 to achieve the intended goal?
    – G. de Man
    Feb 21, 2021 at 20:10
  • @G.deMan as far as I can guess from the code you show you just want 5cm of white space on the first page, so you do not need geometry at all, simply something like \AtBeginDocument{\vspace*{5cm}} see Ulrike's answer in the link I put under the question. Feb 21, 2021 at 21:05
  • 3
    @G.deMan all newgeometry can do is change the top and bottom margin, it can't do and complicated typesetting, and there are almost no cases where you need newgeometry to do that on the first page. I wrote \afterpage and I'd think twice about using it in production. I wrote (in 1993) in the package manual : "This is really a pre-release, to see whether people like the idea of a command like this. This implementation is \emph{not} particularly robust. This implementation does not work in two column mode, and can get `confused' by \LaTeX's floating environments." the code has not changed. Feb 21, 2021 at 21:49

You must log in to answer this question.

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