# How to put an image in \part page

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.

\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.

• take a look at tex.stackexchange.com/questions/40602/… – KJO Apr 20 at 22:17
• @KJO: I had already tried that and it didn't work for me, but it turns out it was a my mistake: Image was too high to fit if scaled at [width=\linewidth]. What is the right spell to say "scale to fit in page"? (I currently put [width=210pt], but that is very fragile). – ZioByte Apr 20 at 22:45
• height=\textheight. Try e.g. \documentclass{article} \usepackage{graphicx} \begin{document} \includegraphics[angle=90,height=0.9\textheight]{example-image-duck} \end{document}. – marmot Apr 21 at 0:55
• – John Kormylo Apr 21 at 1:55
• @marmot: it does not work as-is; apparently \textheight is the full height of text area, while I need "remaining height in current page". Any hint where I should look for that kind of data? I have seen tex.stackexchange.com/a/373312/167976 but I'm unsure how to use it in my case. I will update question. – ZioByte Apr 21 at 8:25

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}}
\newcommand{\printparttitle}[1]{\parttitlefon #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

• Peter a few typo's snuck in so need … \includegraphics[#1]{{#2}}}  second example-image is a Puck? last example unknown=keepadspectratio – KJO Apr 21 at 20:42
• Many thanks for Your code; it works perfectly in plain latex->PDF, but now I'm trying to produce epub using tex4ebook and images simply disappear; can You help with that? – ZioByte Apr 22 at 10:46
• @KJO Thank you. Hopefully I have corrected the typos you pointed out. I have learned over the years that one cannot proofread ones own text.. – Peter Wilson Apr 22 at 19:49
• @ZioByte Sorry, I can't help with that. Perhaps you could ask another question related to tex4book. – Peter Wilson Apr 22 at 19:52
• @PeterWilson I agree it is always easier to find fault with "others" work :-) – KJO Apr 22 at 20:53