[Tex/LaTex] Redefine memoir Part to allow image

graphicsmemoirpartssectioning

I am preparing a book with memoir. The book has three parts. I would like to have the Part title raised and to insert an image directly below the title. I am able to raise the Part title to the upper portion of the page, and to add an image, but the image falls on the following (normally blank) page (see minimum example, below).

How can I get the image to appear on the same page as the Part title, directly under it?

Here is the minimum example:

\documentclass[12pt,letterpaper]{memoir} %
\usepackage[T1]{fontenc}
\usepackage{eso-pic}
\usepackage[english]{babel}
\usepackage[demo]{graphicx}


\makeatletter
\renewcommand*{\beforepartskip}{\null\vskip-2cm}
\renewcommand*{\afterpartskip}{\par\vskip-5cm%
\@afterindentfalse\@afterheading}
\makeatother


\begin{document}

% \frontmatter
%
%
% \mainmatter

\part{This is the first part}
\AddToShipoutPicture*{%
% By default, eso-pic's zero coordinate is in the lower left corner
\put(\LenToUnit{3.5in},\LenToUnit{5.5in}){%
\includegraphics[height=25mm,keepaspectratio]{figs/PA-500942}%
}
}

\part{This is the second part}

\end{document}

Best Answer

Using the same technique as in this question Adding a figure to a Part Page it's much easier to do with memoir:

First we define a command to set the image name for each part. This command takes the same arguments as the \includegraphics command from the graphicx package. Then we add the image to the memoir class \printparttitle command. You can play with the \vfil commands to change the vertical spacing as you require it.

\documentclass{memoir}
\usepackage[demo]{graphicx}
\makeatletter
% define a user command to choose the image
% this command also creates an internal command to insert the image
\def\@partimage{}
\newcommand{\partimage}[2][]{\gdef\@partimage{\includegraphics[#1]{#2}}}
\renewcommand{\printparttitle}[1]{\parttitlefont #1\vfil\@partimage\vfil\gdef\@partimage{}}
\makeatother
\begin{document}
\partimage{foo.png}
\part{A part}
\partimage[width=\textwidth]{bar.png}
\part{Another part}
\end{document}

output of first part page

Related Question