# How to replace chapter boilerplate with full-page image?

Let's say I am producing a book (using \documentclass{book}) where instead of displaying the chapter name textually, I am inserting an image that includes the chapter text. How can I still start a new chapter and set the chapter name (for headings and TOC) without actually displaying that it's a new chapter?

The code I have right now is:

\chapter{My Chapter Title}
\phantom{asdf}


where chapter-1.png is of course my full-page image, and the \phantom{asdf} is apparently necessary for \AddToShipoutPicture to work right.

Based on "How to format the chapter heading" I tried both of these in my preamble, and neither one worked:

% Generated "LaTeX error: Missing \begin{document}"
\vfill
}

% Had no effect
\vfill
}


Is there something else I can do to change the \chapter template, or even an internal variable that it can set? I'm pretty new to customizing TeX layouts, and have previously only used the predefined styles for thesis et al, so I'm a bit lost.

-

I would define a new command \picturechapter that does it all.

Pre Solution step only for demonstration

Only to have a complete minimal working example, we first make a PDF with all the chapter page pictures. You don't need this in real world, where you already have the chapter page pictures!

% This is only an example file to generate the pictures to be used
% at the following MWE. If you already have picture files (either
% one PDF with one picture per page or one file per picture) you
% won't need this file!!!
\documentclass{article}
\usepackage{graphicx,xcolor,eso-pic}
\begin{document}
\pagestyle{empty}
\centering
\AtPageLowerLeft{%
\color{green}\rule{\paperwidth}{\paperheight}%
}%
}%
\vspace*{\fill}\rotatebox{45}{\Huge Chapter page 1}\vspace*{\fill}\newpage
\vspace*{\fill}\rotatebox{45}{\Huge Chapter page 2}\vspace*{\fill}\newpage
\vspace*{\fill}\rotatebox{45}{\Huge Chapter page 3}\vspace*{\fill}\newpage
\vspace*{\fill}\rotatebox{45}{\Huge Chapter page 4}\vspace*{\fill}\newpage
\end{document}


Save this with the name chapterpages.tex and do pdflatex chapterpages to make chapterpages.pdf. This step has been done only to have a test base for the following suggested solution!

Solutions Suggestion

Now let's define a new command \picturechapter that loads one page chapterpages.pdf to be our chapter picture page, but set up toc entry and running head line like a real \chapter would:

\documentclass{book}
\usepackage{pdfpages}

\usepackage[english]{babel}
\usepackage{blindtext}% For demo only (see below)

\usepackage{hyperref}% to show, that even hyperlinks work

% New switch to decide, if the chapter pictures are chapter-1,
% chapter-2 ... chapter-A, chapter-B ... or the pictures are
% the pages of one file chapterpages.pdf. If you have e.g. an
% appendix you have to use \singlepicturestrue
\newif\ifsinglepagepictures

% At this example we use one file chapterpags.pdf:
\singlepagepicturesfalse

\newcommand*{\picturechapter}[1]{%
\cleardoublepage
\refstepcounter{chapter}%
\ifsinglepagepictures
\includepdf[page=1,
pagecommand={%
\thispagestyle{empty}%
\chaptermark{#1}%
}%
]{chapter-\thechapter}%
\else
\includepdf[page=\arabic{chapter},
pagecommand={%
\thispagestyle{empty}%
\chaptermark{#1}%
}%
]{chapterpages}%
\fi
}

\begin{document}
\tableofcontents
\picturechapter{This is my fist picture chapter}
\blindtext

\let\chapter\picturechapter% for demo purpose only to make \blinddocument use
% \picturechapter
\blinddocument
\blinddocument
\blinddocument
\end{document}


The suggested solution has been testes with book and scrbook (a KOMA-Script class). But is should work also with report or scrreprt or almost every class with \chapter. To use it with an article class, you have to replace chapter by section and \chaptermark by \sectionmark.

Alternative 1 to the shown suggestion (one file per picture)

If you want to use not a single file chapterpages.pdf with all the pictures, but single files chapter-1.png, chapter-2.jpg, chapter-3.pdf etc. you simply have to replace \singlepicturesfalse by \singlepicturestrue. In this case it would even work with appendix with numbers A, B, C etc. The corresponding file names would be chapter-A.png, chapter-B.png etc.

Alternative 2 (be independent from chapter counter) NOTE: If you redefine \thechapter using \singlepicturesturetrue, you have to redefine your chapter pictures too. To avoid this, you may use your own counter:

\newcounter{chapterpicture}
\newcommand*{\picturechapter}[1]{%
\cleardoublepage
\refstepcounter{chapter}%
\stepcounter{chapterpicture}% use next chapter picture file
\ifsinglepagepictures
\includepdf[page=1,
pagecommand={%
\thispagestyle{empty}%
\chaptermark{#1}%
}%
]{chapter-\thechapterpicture}%
\else
\includepdf[page=\thechapterpicture,
pagecommand={%
\thispagestyle{empty}%
\chaptermark{#1}%
}%
]{chapterpages}%
\fi
}


In this case the pictures at the appendix would be names chapter-9.png, chapter-10.pdf etc (if the last chapter before the appendix has been 8).

Alterative 3: (each picture file has it's own name independent from the number of the chapter)

As an alternative you may define a command with a second argument: the name of the chapter picture (you cannot test this with the example above because \blinddocument will not set the second argument):

\newcommand*{\picturechapter}[2]{%
\cleardoublepage
\refstepcounter{chapter}%
\includepdf[page=1,
pagecommand={%
\thispagestyle{empty}%
\chaptermark{#1}%
}%
]{#2}%
}


Usage would be:

\picturechapter{My chapter heading}{filename}


Advantage of this solution would be, that you don't need to rename chapter picture files, if you move, remove or insert chapters into the document.

-
That certainly seems to be the proper TeX-y way to do it: overwrought, overly complicated, and requires a Makefile to update things correctly. ;) –  fluffy Nov 23 '11 at 17:04
@fluffy: This doesn't need a Makefile! Note, that you need the fist file only for this example to have picture files. We don't have your picture files, so we need some. You have picture files (and in your question named them chapter-1.png etc.). So need only change switch \singlepagepicturefalse to \singlepagepicturetrue to use your your already existing picture files running the second document at my answer. And in difference to your idea with overwriting definition of \@makechapterhead it does not overwrite anything. –  Schweinebacke Nov 24 '11 at 7:04
@fluffy I don't agree: the last piece of code (which I'd have presented first) is simple and practical. –  egreg Nov 24 '11 at 8:04
@egreg Yeah, the last \picturechapter macro is pretty decent. +1 for that. When I commented on this answer only the first example code was here. I definitely like \picturechapter a lot better than the other ones. –  fluffy Nov 25 '11 at 4:47
@fluffy: Package pdfpages can handle .png, because it uses \includegraphics internally. Otherwise the example filenames I've given would be wrong but they are not. –  Schweinebacke Nov 28 '11 at 6:39

Instead of disabling the heading commands and placing your own heading commands in the body text, I recommend customizing the default heading commands. Use \makeatletter and \makeatother, otherwise you would get that mentioned error "Missing \begin{document}" because of the @ character in the macro names.

For example:

\makeatletter

Similarly, \@makeschapterhead produces the headings when \chapter* is used, and can be redefined.
Further have a look at the titlesec package, which can be used for customizing heading format and spacing, so you would not have to redefine internal class macros as above.
Thanks! How do I define \chapterimage? Just doing \chapter[chapterimage=foo.png]{ChapterTitle} didn't work (I got a macro error, "Undefined control sequence \chapterimage"). Also I'm including my individual chapters in separate .tex files, if that makes a difference. –  fluffy Nov 23 '11 at 7:57
For now just doing \def\chapterimage{chapter-1.png} \chapter{Chapter Title} seems to work. Thanks! –  fluffy Nov 23 '11 at 8:09