I am having trouble using \afterpage
in combination with some figures+captions that are too adjusted or directly exceed the document's margins (I assume that this is the cause of \afterpage
not behaving as usual). I don't mind these figures exceeding the margins, but I need to place them close to where they are referenced and they keep being pushed to the end of the document, leaving large empty spaces. Does anybody have a workaround?
The image is an example of what I get, I would like the figure and the caption to be on the second page, and the remaining text in the last page. I have searched the forum, but could not find a suitable solution.
Thank you!
MWE:
\documentclass[a5paper,twoside,openright]{report}
\usepackage{lipsum}
\usepackage{showframe}
\usepackage{afterpage}
\usepackage{mwe}
\usepackage[fontsize=9pt]{scrextend}
\begin{document}
\lipsum[2-3]
*********After page goes here**********
% It works with a short caption:
%
%\afterpage{%
%
%\begin{figure*}
%
% \makebox[\textwidth][c]{
%
% \includegraphics[width=\textwidth]{example-image}}
%
% \caption[A caption]{Short caption.}
%
%\end{figure*}
%}
% It does not work with a long caption:
\afterpage{%
\begin{figure*}
\makebox[\textwidth][c]{
\includegraphics[width=\textwidth]{example-image}}
\caption[A caption]{\lipsum[1]}
\end{figure*}
}
\lipsum[2-3]
\end{document}
\afterpage
(I wrote it, I know what it does:-) but if you do use it for figures I assume you meant to have\clearpage
at the end of the argument