2

I have the following MWE where to get the desired output I need to issue two \restoregeometry commands in order to ensure the second page doesn't spill of the bottom and so that the first page adheres to the requested margins. Issuing this command twice seems erroneous/bad practice.

There are some related questions and answers:

MWE

\documentclass[11pt, a4paper, twoside]{extarticle}
\usepackage{afterpage}
\usepackage{lipsum}
\usepackage[top=40mm, right=50mm, bottom=40mm, left=50mm]{geometry}
\begin{document}
% Making a nice cover page (no page number desired).
\thispagestyle{empty} 
\afterpage{
    \pagestyle{empty}
    \newgeometry{left = 10mm, right = 10mm, top = 10mm, bottom = 10mm} % Very close to the page edge. 
    \centering
    \textbf{\Huge Some cover page material}\\[5em]
    \vfill \lipsum
    \restoregeometry
    %\aftergroup\restoregeometry % Do I need this?
}
    \restoregeometry
\clearpage
\section{Something else}
\lipsum
\end{document}

OUTPUT

enter image description here

However, my suspicion is that I don't understand what is going on here correctly, and that there is more than likely a better practice to achieve what I want.

NB - While this example is somewhat trivial, I use these two packages for similar projects, so would rather void solutions which might drift towards "don't use these packages" (or similar). I tend to use this as a more elaborate \maketitle.

  • 1
    As you have a \clearpage before the \section, which means that you know where the page break is, there is really absolutly no need to use \afterpage. – Ulrike Fischer Jul 9 '18 at 16:11
  • @UlrikeFischer, It's not clear to me how that makes \afterpage redundant? The \clearpage is after the \afterpage (which so happens to be followed by section, although this can likely be expected). The reasoning behind the afterpage was to allow some page(s) to have a custom margin separate to the main document. It is true I also happen to know where the explicit page breaks are. – oliversm Jul 9 '18 at 16:29
  • It seems that you definitely do not need afterpage and I can't see why you need restoregeometry either. Both of these are rather fragile commands I wouldn't use in production unless an absolute last resort. Certainly afterpage should be used rarely, and using it in connection with forced page breaks can never do anything useful. – David Carlisle Jul 9 '18 at 21:47
3

Your afterpage setup is unneeded. You get the same output with a much simpler layout:

\documentclass[11pt, a4paper, twoside]{extarticle}
\usepackage{lipsum}
\usepackage[top=40mm, right=50mm, bottom=40mm, left=50mm]{geometry}
\begin{document}
% Making a nice cover page (no page number desired).
\newgeometry{left = 10mm, right = 10mm, top = 10mm, bottom = 10mm} 
\thispagestyle{empty}
\centering
\textbf{\Huge Some cover page material}\\[5em]
\vfill \lipsum

\restoregeometry

\section{Something else}
\lipsum
\end{document}

\afterpage is only needed when you don't know where the page break will be .

As an example:

\documentclass{article}
\usepackage{lipsum,afterpage,xcolor}

\begin{document}
\afterpage{\textcolor{red}{continued from previous page}}
\lipsum\lipsum
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.