I am embedding full pages from another PDF document (using the pdfpages package), but I would like to be able to declare my own section headings before each embedded document (for e.g. hyperlinking / TOC purposes). pdfpages has an experimental feature which lets me do this, but the problem is that I want to put all of these embedded documents inside a section, so I need to insert a section heading and a subsection heading on the first document I embed. Unfortunately pdfpages doesn't seem to be able to do this. Is there a way for me to do this?
Edit: Thank you for the suggestions. I am also in need of something similar for general labels — at the moment I am abusing the addtolist
option of \includePDF
but the objects I'm labelling aren't really figures or tables.
Best Answer
You can create entries in the table of contents (TOC) when importing a PDF. Here is an example:
Parameters for each TOC entry are:
pages={3-10}
, the smallest possible number would be3
.You can create two entries for a single page on different levels (like
section
andsubsection
). In the example, the first two entries go to the same page. A label (likep2
) can be used to refer to a page that is part of the included PDF.Unfortunately error messages from
pdfpages
are not helpful when the above list contains errors. I encountered the following error, which was hard to spot:pages={3-10}
the first entry in anaddtotoc
record must be3
or larger. It was1
in my case but the error message wasn't pointing to it.