# Redefine report Part with image

I am trying to include an image on the part title page of my report, so that it looks like this, but shows up correctly in the ToC:

\clearpage
\newpage
{\pagestyle{empty} \enlargethispage{10\baselineskip}
{\huge\textbf{Part I: Lorem Ipsum}}\\
\noindent\rule{\textwidth}{0.4pt}
\begin{center}
\includegraphics[width=\textwidth]{figures/part_1_title.pdf}
\end{center}
\clearpage}
\newpage


A similar question has been asked here, but for me the \printparttitle produces an error.

Does someone know how to do this?

An other similar question was asked in an other forum: here.

I tried to modify the defnition of \part from the report.cls file to actually get the title of the Part to look different, but it didn't work. (I need the space for the picture).

What it looks like:
Part I
Lorem Ipsum

What I want it to look like
Part I: Lorem Ipsum which is obtained by this code:

{\pagestyle{empty} \enlargethispage{10\baselineskip}
{\huge\textbf{Part I: Lorem ipsum}}\\
\noindent\rule{\textwidth}{0.4pt}
\begin{center}
\includegraphics[width=\textwidth]{figures/PartI_Loerm.pdf}
\end{center}


Does someone have an idea?

-
If you want to change the appearance of the part title you shouldn't remove \@spart, but only modify the definition of \@part. –  egreg Apr 12 '13 at 7:05

Add the image typesetting to the command \@endpart:

\makeatletter
\newcommand{\imagepart}[1]{\def\@theimagepart{#1}\part}
\def\@endpart{%
\par\medskip
\hrule
\begin{center}
\includegraphics[width=\textwidth]{\@theimagepart}
\end{center}
\vfil\newpage
\if@twoside
\if@openright
\null
\thispagestyle{empty}%
\newpage
\fi
\fi
\if@tempswa
\twocolumn
\fi}
\makeatother


Complete example (the demo option is just for the example)

\documentclass{report}
\usepackage[demo]{graphicx}
\makeatletter
\newcommand{\imagepart}[1]{\def\@theimagepart{#1}\part}
\def\@endpart{%
\par\medskip
\hrule
\begin{center}
\includegraphics[width=\textwidth]{\@theimagepart}
\end{center}
\vfil\newpage
\if@twoside
\if@openright
\null
\thispagestyle{empty}%
\newpage
\fi
\fi
\if@tempswa
\twocolumn
\fi}
\makeatother

\begin{document}
\imagepart{figures/part_1_title.pdf}{Part title}
\end{document}


A possible redefinition also of \@part, with some minor modifications to \@endpart, in order not to have line breaks in the title.

\documentclass{report}
\usepackage[demo]{graphicx}
\makeatletter
\newcommand{\imagepart}[1]{\def\@theimagepart{#1}\part}
\def\@endpart{%
\par\vskip12pt\hrule\vskip12pt
{\centering
\includegraphics[width=\textwidth]{\@theimagepart}\par}
\vfil\newpage
\if@twoside
\if@openright
\null
\thispagestyle{empty}%
\newpage
\fi
\fi
\if@tempswa
\twocolumn
\fi}
\def\@part[#1]#2{%
\ifnum \c@secnumdepth >-2\relax
\refstepcounter{part}%
\else
\fi
\markboth{}{}%
{\centering
\interlinepenalty \@M
\normalfont
\ifnum \c@secnumdepth >-2\relax
\huge\bfseries \partname\nobreakspace\thepart:
\fi
#2\par}
\@endpart}

\makeatother

\begin{document}
\imagepart{figures/part_1_title.pdf}{Part title}
\end{document}


If you want to move up the part title, you have to change the \vfil in the definition of \part; for instance, by adding

\renewcommand\part{%
\if@openright
\cleardoublepage
\else
\clearpage
\fi
\thispagestyle{plain}%
\if@twocolumn
\onecolumn
\@tempswatrue
\else
\@tempswafalse
\fi
\null\vspace{\stretch{1}}
\secdef\@part\@spart}


and changing the \vfil in the redefinition of \@endpart to \vspace{\stretch{2}} you'll have twice as much space at the bottom than at the top.

# Final version

Left of the picture the result of \imagepart, right your wish.

\documentclass{report}
\usepackage[demo]{graphicx}
\makeatletter
\newcommand{\imagepart}[1]{\def\@theimagepart{#1}\part}
\def\@endpart{%
\par\vskip12pt\hrule\vskip12pt
{\centering
\includegraphics[width=\textwidth]{\@theimagepart}\par}
\vfil\newpage
\if@twoside
\if@openright
\null
\thispagestyle{empty}%
\newpage
\fi
\fi
\if@tempswa
\twocolumn
\fi}
\renewcommand\part{%
\if@openright
\cleardoublepage
\else
\clearpage
\fi
\thispagestyle{empty}%
\if@twocolumn
\onecolumn
\@tempswatrue
\else
\@tempswafalse
\fi
\null\vspace{-2\baselineskip}
\secdef\@part\@spart}
\def\@part[#1]#2{%
\ifnum \c@secnumdepth >-2\relax
\refstepcounter{part}%
\else
\fi
\markboth{}{}%
{\raggedright
\interlinepenalty \@M
\normalfont
\ifnum \c@secnumdepth >-2\relax
\huge\bfseries \partname\nobreakspace\thepart:
\fi
#2\par}
\@endpart}

\makeatother

\begin{document}
\imagepart{figures/part_1_title.pdf}{Part title}

\clearpage
\newpage
{\pagestyle{empty} \enlargethispage{10\baselineskip}
{\huge\textbf{Part I: Lorem Ipsum}}\\
\noindent\rule{\textwidth}{0.4pt}
\begin{center}
\includegraphics[width=\textwidth]{figures/part_1_title.pdf}
\end{center}
\clearpage}
\newpage

\end{document}


-
Awesome! Thank you for addidng that! Now there is just the problem of the picture getting to a new page after the title. So I skipped th hrule, but even that would not help. –  Jonas Apr 12 '13 at 10:12
\enlargethispage{5\baselineskip} helps, but it does not solve the problem. - How can I bring the \part further up? I tried a \vspace{-5em}, but it would produce errors: \newcommand{\imagepart}[1]{\def\@theimagepart{#1}\vspace{-5em}\part} I guess, I need to revert the effect of \vskip 20 in the part definition? –  Jonas Apr 12 '13 at 11:35
@Jonas Rather than shooting at random, why don't you add to your question the precise specifications of what you wish? –  egreg Apr 12 '13 at 12:18
Good point! I tried to do this now. :) –  Jonas Apr 13 '13 at 1:51

If you use a KOMA class you can do this by \setpartpreamble. The command has two optional arguments to specify the position and width.

\documentclass{scrreprt}
\usepackage{mwe}
\begin{document}
\setpartpreamble{%
\begin{center}
Here some text and a picture

\includegraphics[width=.48\linewidth]{example-image-a}
\end{center}
}
\part{foo}
\end{document}


-