2

I'm using the addtotoc option from includepdf to add a TOC entry for two included PDFs. However, the table of contents always thinks they're on the first page (note that I have rebuilt the document enough times for the aux files to be read properly). Other similar answers on this site seem to suggest using addtotoc, but I'm already doing that (and have the same result if adding the contents line manually as shown in the example).

In this case I expect each document title to show up as an entry in the ToC at the correct page (eg. pages 1 and 220 or so in this specific example):

\documentclass[letterpaper]{book}

\usepackage{pdfpages}
\usepackage{titling}

\setcounter{secnumdepth}{-1}

% Add the title to the Table of Contents
% Has the same result as using the addtotoc option
% \renewcommand{\maketitlehooka}{\phantomsection\addcontentsline{toc}{chapter}{\thetitle}}

\newcommand{\includerfc}[4]{
    \cleardoublepage
    \title{#1}
    \author{#2}
    \date{#3}
    \maketitle
    \cleardoublepage
    \includepdf[pages=-,addtotoc={1, chapter, 1, \thetitle, rfc:#4}]{rfc#4.pdf}
}

\begin{document}

\frontmatter
\tableofcontents
\mainmatter

\includerfc{Extensible Messaging and Presence Protocol: Core}{P. Saint‐Andre}{March 2011}{6120}
\includerfc{Use of Transport Layer Security in the\\*Extensible Messaging and Presence Protocol}{P. Saint‐Andre\\T. Alkemade}{June 2015}{7590}
\end{document}

Is there something I can do to ensure that the page number is the actual page in the output PDF or isn't read until the external PDFs have been inserted?

The PDFs used in this example document are:

2
  • Difficult to compile this is, link to the .pdf files give you must ;-)
    – user31729
    Jul 11 '16 at 19:44
  • EDIT: Links added in the original question. Thanks!
    – Sam Whited
    Jul 11 '16 at 19:45
1

TL;DR — \maketitle was resetting the page numbers.

After digging for a while I decided to go down the list and start commenting things out that seemingly hadnothing to do with the problem in case there were some funny side effects; in retrospect, maybe I should have started with this.

It turned out that when I commented out the \maketitle, everything worked fine. This led me to dig into the titlepage package so I started commenting out things there. Eventually I noticed that it worked when I got rid of the titlepage environment, so I dug into that and found it in the book class.

Turns out that the title page resets the line numbering (as you might expect since it should be the first page), and using the titling environment to insert multiple title pages does not change this behavior or give you a way to configure it (as far as I can see).

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.