0

I have a workflow that involves adding some of the chapters in a report in via the \includepdf command from the package pdfpages. In this process I want some of the PDFs to be the start of a new chapter. And every chapter gets a new page before it with a title which I configure with \titleformat{\chapter}[display]. I use the addtotoc switch to tell latex to add the PDF as a new chapter and add it to the TOC. In the past this has worked just dandy, but on my latest document I find that I'm not getting a new page with chapter title before the PDF chapter. The TOC gets updated, but there's no chapter title page. I have whittled my tex file down to the pretty minimal reproducible doc below. The file example.pdf is a very simple PDF document for testing. You can download it here.

What I find most mystifying is that I have another workflow that uses this same logic... and it works. And I can't figure out the material difference between the example below and the one that works properly.

Any idea?

\documentclass{book}
\usepackage{pdfpages}        % for inserting pdfs
\usepackage{fancyhdr}        % for fancy editing of footers
\usepackage{titlesec}

\usepackage{lipsum}

\pdfminorversion=6     %kills PDF version warning in output
\pagestyle{fancy}

%% this sets up the title page for each chapter
\titleformat{\chapter}[display]
{\normalfont\Large\filcenter\sffamily}
{\titlerule[1pt] \vspace{1pt} \titlerule \vspace{1pc}
\LARGE\MakeUppercase{\chaptertitlename} \thechapter}
{1pc}
{\titlerule
\vspace{1pc}%
\Huge}
[\newpage] % creates the new page

\begin{document}

\tableofcontents

\includepdf[ pages=-, addtotoc={1,chapter,1,A. Ex 1,p1}]{./example.pdf}
\chapter{ch 2}
\lipsum{1-5}
\includepdf[ pages=-, addtotoc={1,chapter,1,A. Ex 3,p1}]{./example.pdf}

\end{document}
2
  • 1
    I get the page for chapter 2; of course, since there is no \chapter command before the first inclusion, no separate page is added.
    – egreg
    Apr 26 '18 at 20:56
  • aaaaand I'm an idiot. I realize now that we were handcrafting section pages in the PDFs that emulated the chapter breaks. So I was totally wrong that I had had this working before.
    – JD Long
    Apr 26 '18 at 21:16
1

As the name addtotoc suggests, this options simply adds an entry to the table of contents, but does not really start a chapter. If you want real chapters, including the title page, you can simply add your pdf after the begin of a chapter.

\documentclass{book}
\usepackage{pdfpages}        % for inserting pdfs
\usepackage{fancyhdr}        % for fancy editing of footers
\usepackage{titlesec}

\usepackage{lipsum}

\pdfminorversion=6     %kills PDF version warning in output
\pagestyle{fancy}

%% this sets up the title page for each chapter
\titleformat{\chapter}[display]
{\normalfont\Large\filcenter\sffamily}
{\titlerule[1pt] \vspace{1pt} \titlerule \vspace{1pc}
\LARGE\MakeUppercase{\chaptertitlename} \thechapter}
{1pc}
{\titlerule
\vspace{1pc}%
\Huge}
[\newpage] % creates the new page

\begin{document}

\tableofcontents

\chapter{A. Ex 1}
\includepdf[ pages=-,
% addtotoc={1,chapter,1,A. Ex 1,p1}
 ]{example-image-a4}
\chapter{ch 2}
\lipsum{1-5}
\chapter{A. Ex 3}
\includepdf[ pages=-,
% addtotoc={1,chapter,1,A. Ex 3,p1}
 ]{example-image-a4}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.