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
\AddToShipoutPicture{%
\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 makechapterpages.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}%
\addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}#1}%
\chaptermark{#1}%
}%
]{chapter-\thechapter}%
\else
\includepdf[page=\arabic{chapter},
pagecommand={%
\thispagestyle{empty}%
\addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}#1}%
\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}
After processing this file with pdflatex you get an example pdf with green chapter starting picture pages, that are shown at the table of contents with the headings "1 This is my first picture page", "2 Heading on level 0 (chapter)", "2 Heading on level 0 (chapter)", "3 Heading on level 0 (chapter)". Even the hyper links from the table of contents to the green pages are working. The running head at the pages following the green chapter pages are set too.
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 fileschapter-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}%
\addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}#1}%
\chaptermark{#1}%
}%
]{chapter-\thechapterpicture}%
\else
\includepdf[page=\thechapterpicture,
pagecommand={%
\thispagestyle{empty}%
\addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}#1}%
\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}%
\addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}#1}%
\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.
No hay comentarios:
Publicar un comentario