# afterpage clashes with restoregeometry from the geometry package

I'm writing my thesis and have used the geometry package to control the size of the text body so that it follows 'good' typesetting practices as described in the KOMA-script documentation.

Many of my figures are full-page floats that are taller than the text height. Consequently I have been using the newgeometry/restoregeometry and afterpage commands to adjust the page layout and ensure that the figure is appropriately placed in the document.

This works fine except that on the page immediately following the figure, the text 'runs' into the bottom margin. I've have provided a MWE below. Note how the fourth page is formatted incorrectly. (I am using pdfLaTeX).

Does anyone know how to correct this behaviour? (or have an alternative method of accomplishing the same layout?)

It seems to me as though the restoregeometry command is not being executed correctly.

\documentclass{scrbook}
\usepackage{calc}
\usepackage[showframe]{geometry}

% Calculate type area for page
\geometry{ bindingoffset = 8mm,
heightrounded = true,
body = {125mm, 125mm * 16 / 9},
marginratio = {9:16, 9:16},
marginparsep = 5mm,
marginparwidth = 30mm,
footskip = 15mm }

\KOMAoptions{fontsize = 11pt}
% Chapters open on right.
\KOMAoptions{open = right}
% \cleardoublepage command uses the empty page style
\KOMAoptions{cleardoublepage = empty}
% Don't typeset the Chapter and Appendix prefixes
\KOMAoptions{chapterprefix = false}
\KOMAoptions{appendixprefix = false}
% We also avoid having running heads and page numbers on float pages by using the  floatpage
% package to make float pages use the empty page style.
\usepackage{floatpag}
\floatpagestyle{empty}
\rotfloatpagestyle{empty}

% For dummy text
\usepackage{lipsum}
%
\usepackage{afterpage}

% For good control of floats
\usepackage[demo]{graphicx}
\usepackage{floatrow}
\floatsetup{facing=yes,
capbesideposition={outside,center},
footnoterule=none}
\floatsetup[table]{style=plaintop}
\floatsetup[subfigure]{style=plain}
% Allow floats to hang into the outer margin
\DeclareMarginSet{minhangoutside}{%
\setfloatmargins*{\relax}
{\hfill\hskip-\marginparwidth\hskip-\marginparsep}%
}
\floatsetup[figure]{margins=minhangoutside}

% For control of caption formatting
\usepackage{caption}
\usepackage{subcaption}
\captionsetup{font=normal,
format=hang,
labelfont=normal,
labelsep=colon}

% End Preamble
%
%------------------------------------------------------------------------
\begin{document}

\chapter{First Chapter}
%
\section{First Section}%
\lipsum%

% Add a full page figure. I want the preceeding page to be full of text so
% use the afterpage command. Also as the figure is taller than the page height
% I use the newgeometry/savegeometry/restoregeometry commands.
%
\afterpage{%
\newgeometry{bindingoffset = 8mm,
body = {125mm, 125mm * 16 / 9 + 10mm + 15mm},
footskip = 0mm}%
\savegeometry{extraheight}
%
\begin{figure}[pc]%
\centering%
\ffigbox%
{\includegraphics*[width=160mm,height=20mm]{}%
\vspace*{1ex}%

\begin{subfloatrow}%
\ffigbox[\FBwidth]%
{\includegraphics*[width=160mm,height=96.0mm]{}}%
{\caption{First sub-figure}}%
\end{subfloatrow}%
\vspace*{1ex}%

\begin{subfloatrow}%
\ffigbox[\FBwidth]%
{\includegraphics*[width=160mm,height=96.0mm]{}}%
{\caption{Second sub-figure }}%
\end{subfloatrow}}%
{\caption{Main caption of the figure. In reality this runs to two lines long so I'm just filling in space here with meaningless text.}}%
\end{figure}
%
\restoregeometry%
}
%
% Next section
\section{Second Section}%
\lipsum%
%
\section{Third Section}%
\lipsum%

\end{document}

• Have you try the command \resizebox from the pkg geometry? Try using this command to adjust your figure a little smaller? Oct 21, 2013 at 7:17
• I have a situation where I do need \afterpage and \newgeometry and where Ulrike Fischers solution won't do. A solution would be much appreciated. May 20, 2015 at 14:04

I don't think that you need afterpage and restoregeometry. Use negative space to move your graphic around and avoid overful box messages. E.g.

\section{First Section}%
\lipsum%

\begin{figure}[pc]%
\vspace{-2cm}%move up
\begin{minipage}[t][\dimexpr \textheight + 3cm]{\textwidth}
\centering%

\makebox[\linewidth]{\rule{1.1\textwidth}{\textheight}}
\caption{Main caption of the figure. In reality this runs to two lines long so I'm just filling in space here with meaningless text.}%

\end{minipage}
\vspace{-3cm}%avoid "float to large"
\end{figure}

• This is exactly the simple work around I was looking for. The funny thing is that I was originally using \vspace to shift my figures around but the resulting "float to large" warnings drove me nuts. Hence leading me to use \afterpage and \newgeometry. Now I know better.
– luke
Nov 2, 2013 at 3:39