currently i am in a situation where i have inserted some pages via includepdf, followed by additional \includepdf calls that use the addtotoc function, as follows:


\addcontentsline{toc}{part}{Part 1. Part 1}
\includepdf[pages=-,pagecommand={},addtotoc={1, subsection, 2, somename, somenamelabel,
n, subsection, 2, somenameN, somenameNlabel}]{./part1docs}

\addcontentsline{toc}{part}{Part 2. Part 2}
\includepdf[pages=-,pagecommand={},addtotoc={1, subsection, 2, somenamepart2, somenamep2label,
n, subsection, 2, somenamepart2N, somenamep2Nlabel}]{./part2docs}

i would like to now add a new section heading, called "Part 3", where the subsections would refer to the pages in the \includepdf{pdffile1}..\includepdf{pdffile6} calls.

edit: i found someone's macro that allows me to put in entries


via \NoPageAddContents line, so if i add this code:

\NoPageAddContentsLine{toc}{part}{Part 3. Transcripts}

it looks right but the linking is still an issue. even if i add a link=true, linkname=x to each of the pdffiles, it does not work.

any tips on getting a working link to a contents entry added in this way, if the link is created through pdfpages?

  • 1
    Your question is confusing. To clarify: You are talking about two different documents? You want to link from one PDF to another, similar to using \href{foo.pdf#section}{...}. And the difficulty is, that you would like this \href command to be inside a TOC entry. Is this what you want? Sep 25, 2020 at 13:28
  • hi matthias. i reworked my question. i think it's much easier to understand now. this is all for a single tex file. i just want to include some pdf files in a section that is after some pdf files that call addtotoc (and addcontentsline), if that makes sense.
    – user41816
    Sep 25, 2020 at 14:12
  • hi matthias, i am almost there, but i still have an issue with linking. hoping you can check out the additions and help me conjure a solution to hacking a link to each of pages included through pdfpages
    – user41816
    Sep 25, 2020 at 15:21

2 Answers 2


Do you really want a TOC that does not follow the structure of your document? I suppose this will be highly confusing for everyone reading your document.

Maybe a simple table with references to the other pages might be a better solution than putting it into the TOC.

Anyway, here's a quick solution without page numbers. Adding page numbers would be much more cumbersome.


    {\protect\numberline {\thesection}#1}%

\includepdf[pages=-, link, linkname=AAA]{dummy.pdf}

\mysection{Let's see}{AAA.2}

  • thanks for this solution matthias, but one thing i've noticed is that, for my example, this will not show up since "Part 3" is technically an empty "part" (i.e. no \part*{} or \part{} has been declared). if the section is created "normally" (with some declaration prior to adding the entry), then it works.
    – user41816
    Sep 25, 2020 at 17:23

by using


and then adding \label{x} after each includepdf call that's being indexed out-of-order:


and then using hyperref in the nopageaddcontentsline,

\NoPageAddContentsLine{toc}{subsection}{\hyperref[whatiwant]{pdffile1 header name}}

it will work. it's not the prettiest solution, but it's generated so i'll take it.

and i agree matthias, it's not the best way to do things.

but The < Vaunted Entity > is The < Vaunted Entity >. your documents must meet their criteri prior to arguing with them ;)

Your Answer

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