Put a full image before some chapters
The answer needs two "parts":
(1) Prevent \part
in memoir
to issue a \newpage
after filling the part page. This is done redefining \partpageend
by commenting a line. (marked with <<<<<<<<<<<
)
(2) I usually use xcoffins
to put material in the page in the place I want. First the figure or the pdf or text, etc. is put into the special boxes, defined by the package, and then attached (only one in this case) to another box that serves has frame, with X and Y offsets. (X offset, Y offset)
in the command \Join...
The frame is then typeset as a text object in the current insertion point, as if it where the first letter of a text in the page. So we need to displace it to its proper place, the top left corner for example, using the margins dimensions or arbitrary lengths to put it where we want.
I made 3 examples in the document: at the end of a chapter that ends in a even page, so there is a blank odd page before the next chapter; inserting a dummy figure after \part
; and inserting a pdf page after \part
. (The cover of a manual)
Over time, I found that xcoffins
was superior to other alternatives. It is easy to learn, just a few commands, and it emulates a graphic design program, placing the material in boxes and then attaching the boxes and adding offsets using their relative positions. This is a very simple case, but you might well want put more things over the background image: a text, a table or another figure. See for example
https://tex.stackexchange.com/a/573206/161015
This is the code.
\documentclass[10pt, a4paper, twoside, openright]{memoir}
\usepackage{graphicx}
\usepackage{kantlipsum} % dummy text
\RequirePackage{calc} % easier calculations
\usepackage{xcoffins}
\NewCoffin\Framex
\NewCoffin\FigA
\makeatletter
\renewcommand*{\partpageend}{\afterpartskip
\ifm@mnopartnewpage
\else
\if@twoside
\if@openright
\null
\thispagestyle{afterpart}%
% \newpage %<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
\fi
\fi
\fi
\if@tempswa
\twocolumn
\fi}
\makeatother
\setlrmarginsandblock{3.5cm}{2.5cm}{*}
\setulmarginsandblock{2.5cm}{*}{1}
\checkandfixthelayout
\begin{document}
\chapter{Introduction}
\kant[1-12]
%%%%%********************************* image end of chapter
\clearpage
\thispagestyle{empty}
\SetHorizontalCoffin\FigA{\includegraphics[width=\stockwidth, height=\stockheight]{example-image-a}}
\JoinCoffins*\Framex[l,t]\FigA[l,t](-\foremargin,\uppermargin+12pt) % XY offset
\noindent\TypesetCoffin\Framex
%****************************************************************
\part{Tecnologia I}
%%%%%***************************************** image after part
\thispagestyle{empty}
\SetHorizontalCoffin\Framex{} %clear the frame
\SetHorizontalCoffin\FigA{\includegraphics[width=\stockwidth, height=\stockheight]{example-grid-100x100pt}}
\JoinCoffins*\Framex[l,t]\FigA[l,t](-\foremargin,\uppermargin+24pt) % XY offset
\noindent\TypesetCoffin\Framex
%****************************************************************
\chapter{Storia del sonoro per l'audiovisivo}
\kant[30-35]
\part{Tecnologia II}
%%%************************************************ pdf (cover) after part
\thispagestyle{empty}
\SetHorizontalCoffin\Framex{} %clear the frame
\SetHorizontalCoffin\FigA{\includegraphics[width=\stockwidth, height=\stockheight]{pgfmanual.pdf}}
\JoinCoffins*\Framex[l,t]\FigA[l,t](-\foremargin,\uppermargin+24pt) % XY offset
\noindent\TypesetCoffin\Framex
%***********************************
\chapter{Final}
\kant[8-12]
\end{document}
UPDATE
Following Peter Wilson's suggestion it is possible to have everything inside memoir's world.
It is needed to remove another \newpage
, now from \afterpartskip
to prevent memoir from stubbornly keep adding a blank page after \part
The code it is simpler, although I have to reach the page 335 of the manual. Excellent manual, by the way!
%%%%%%% UPDATED CODE
\documentclass[10pt, a4paper, twoside,openright]{memoir}
\usepackage{graphicx}
\usepackage{kantlipsum} % dummy text
\usepackage{pdfpages}
%%%%% ************************* changes to memoir
\makeatletter
\renewcommand*{\partpageend}{%
\afterpartskip
\ifm@mnopartnewpage
\else
\if@twoside
\if@openright
\null
\thispagestyle{afterpart}%
% \newpage %<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
\fi
\fi
\fi
\if@tempswa
\twocolumn
\fi
}
\makeatother
\renewcommand{\afterpartskip}{\vfil%
% \newpage %<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
%%%%% *************************
\setlrmarginsandblock{3.5cm}{2.5cm}{*}
\setulmarginsandblock{2.5cm}{*}{1}
\checkandfixthelayout
\begin{document}
\chapter{Introduction}
\kant[1-12]
\part{Tecnologia I}
\clearpage
\thispagestyle{empty}
\cleartoevenpage{\includegraphics[width=0.8\stockwidth, height=0.8\stockheight]{example-grid-100x100pt}}
\chapter{Storia del sonoro per l'audiovisivo}
\kant[30-35]
\part{Tecnologia II}
\cleartoevenpage{\includepdf[noautoscale,height=\stockheight]{pgfmanual.pdf}}
\chapter{Final}
\kant[8-10]
\end{document}
The memoir
class provides several means of moving onwards to another page. In particular for your case:
\movetoevenpage[stuff]
\cleartoevenpage[stuff]
The \movetoevenpage
stops the current page and starts typesetting on the next even numbered page. \cleartoevenpage
flushes out all floats before going to the next even page. In both cases stuff
, if present, is put on the skipped page (if there is one).
So, you could do something along the lines of:
... last line of the previous chapter.
\cleartoevenpage[\includepdf...]
\chapter{Next chapter}
...
For preventing a blank page after a \part
use @SimonDispa's code for redefining \partpageend
EDIT
I should have said:
\movetoevenpage{stuff}
\cleartoevenpage{stuff}
As noted by @SimoneCorelli.
EDIT 2
Ignore the above, the macros are:
\movetoevepage[stuff]
\cleartoevenpage[stuff]
where stuff
is put on the skipped blank page (if there is one). Calling
\movetoevenpage{stuff}
puts stuff
on the page after the skipped blank page.