[Tex/LaTex] How to put an image in \part page

graphicsmemoirparts

I am trying to put an image into the same page as the \part header, something like a sub-cover.

I tried something along the lines:

\documentclass[10pt,ebook,italian,onecolumn,oneside,titlepage,extrafontsizes]{memoir}
\usepackage[italian]{babel}
\usepackage{graphicx}
...
\title{Book Title}
\begin{document}
\frontmatter
\maketitle
\mainmatter
\chapterstyle{companion}
\tableofcontents
\part{Part I Title}
\includegraphics[width=\linewidth]{PartIcover.jpg}
\chapter{First Chapter TItle}

This does not work well for two reasons:

  • image is not right after "Part I Title", but on next page.
  • in image page I get a spurious "INDEX #" header (which is not present in \part page, of course)

Is it possible to achieve the desired effect? ("Part I Title" on top of page and image below it).

If so: how?

Note: I am almost a newbie to LaTeX, please be lenient.

Update:
following advice in comments I made the following; working, but fragile to say the least:

\documentclass[...]{memoir}
\usepackage[italian]{babel}
\usepackage{graphicx}
...
\def\@partimage{}
\newcommand{\partimage}[2][]{\gdef\@partimage{\includegraphics[#1]{#2}}}
\renewcommand{\printparttitle}[1]{\parttitlefont #1\vfil\@partimage\vfil\gdef\@partimage{}}
\makeatother
...
\title{Book Title}
\begin{document}
\frontmatter
\maketitle
\mainmatter
\chapterstyle{companion}
\tableofcontents
\partimage[width=210pt]{PartIcover.jpg}
\part{Part I Title}
\includegraphics[width=\linewidth]{PartIcover.jpg}
\chapter{First Chapter Title}

This is very fragile because I need to hand-compute remaining height after \part title.

I saw this answer, but I'm unsure how to use it in the above code.

Best Answer

Thank you for essentially using the code I posted to SE about 40602 and 452089.

It is not clear to me whether you will be using the same or different graphics for each \part and how you want them placed on the page --- to fill the \textwidth or take up all the space below the part title text (you might not be able to have both). However, this may help (less any typos)

\documentclass{memoir}
\usepackage{graphicx}
\makeatletter
\def\@partimage{}
\newcommand{\partimage}[2][]{\gdef\@partimage{\includegraphics[#1]{#2}}}
\renewcommand{\printparttitle}[1]{\parttitlefont #1\vfil\@partimage\vfil\gdef  \@partimage{}}
\makeatother
\begin{document}
\partimage[height=0.5\textheight,width =\textwidth,keepaspectratio]{example-image-duck-portrait.pdf}
\part{A Part}
\partimage[height=0.5\textheight,width=\textwidth,keepaspectratio]{example-image-duck.pdf}
\part{Another Part}
\partimage[height=0.5\textheight,width=\textwidth,keepaspectratio]{example-image-duck-portrait.pdf}
\part{Another Part}
\partimage[height=0.5\textheight,width=\textwidth,keepaspectratio]{example-image-duck-portrait.pdf}
\part{The Third}
\end{document}

The above will fit an illustration on the same page as the \part heading constrained to be within the dimensions of half the \textheigt and the \textwidth while maintaining the aspect ratio of the illustration. The example illustrates how a different illustration can be applied to each \part.

GOM

Related Question