# Nested TOC from included file using \includepdf possible?

I am inserting my CV (using moderncv) into my set of application documents. The CV is a separate project and I'm using \includepdf to insert the resulting pdf into my main document. This is the contents of my tex file that handles the CV:

\pagebreak
\begin{textblock*}{60mm}(20mm,0.01\textheight)
\color{white}{\section{Curriculum vitae}[Curriculum vitae]*}
\end{textblock*}
\pagebreak


Here is an overview of the structure of my documents:

*
|
+---Cover
|
+---ToC
|
+---Cover letter
|
+---CV
|
+---Work references
|
+---Diplomas and certificates


All sections (yes, sections) are added to the main structure using \input and are separate tex files. All (except for the cover and ToC) contains simple inclusion with some formatting (e.g. scaling) using \includepdf. All but the CV section have no ToC on their own.

CV
|
+---Education
|
+---Working experience
|
+---Soft skills
|
+---Technical experience
|
+---Activities


As I have discovered while the CV pdf file has its own ToC upon inserting it into my main document this ToC disappears. I was expecting for the ToC to be added as a nested one (e.g. a section becomes subsection and so on) but it's not added at all. Below is a mockup what I would like to have:

*
|
+---Cover
|
+---ToC
|
+---Cover letter
|
+---CV
|   |
|   |
|   +---Education
|   |
|   +---Working experience
|   |
|   +---Soft skills
|   |
|   +---Technical experience
|   |
|   +---Activities
|
|
+---Work references
|
+---Diplomas and certificates


Any ideas how to solve this problem?

• \includepdf only looks at the pdf, not the toc file. You could try inputting that, but it would have incorrect page numbers. (For that matter, what do you want to happen to the page numbers?). How many complicated is the CV's toc? Could you use tex.stackexchange.com/a/592007/107497 ? Apr 9, 2021 at 15:34
• What exactly do you mean by "the ToC disappears"? In your CV, do you have a printed table of contents? Or are you talking about the navigation links that show up in the side bar for some PDF viewers? Apr 9, 2021 at 16:19
• @WillieWong I don't have a printed ToC in my CV. I do have one in my main document. And yes, navigation links are not showing. I would actually prefer for them to show only there and not in the ToC but I can live with those showing in both places. Apr 9, 2021 at 20:01
• @Teepeemm The ToC is not visible but is structure of the CV is pretty simple (see updated question) - just a couple of sections (no subsections). While I can create custom ToC content I was looking for a more out-of-the-box solution that I can apply not only for this case (my application documents) but other projects as well. Apr 9, 2021 at 20:03
• @rbaleksandar: I am rather more confused after your edit. You wrote "while the CV pdf file has its own ToC" and also that you "don't have a printed ToC" in the CV. What exactly are your referring to when you say that the pdf file has its own ToC? Apr 10, 2021 at 1:00

Pdfpages doesn't provide any magic which adds entries to the TOC automatically. It can be done manually with addtotoc, but I think it's quite unusual to have a TOC in your application documents. However, it is always nice to have a navigation bar (outlines in pdf jargon).

Here's an example how to add outlines which are linked to pages included with \includepdf.

\documentclass[a4paper]{article}
\usepackage{pdfpages}
\usepackage{bookmark}
\usepackage{mwe}

\newcommand{\mybookmark}[3][0]{%
\hypertarget{#3}{}%
\bookmark[dest=#3, level=#1]{#2}%
}

\newcommand{\mypdfbookmark}[3][0]{%
\bookmark[dest=#3, level=#1]{#2}%
}

\begin{document}

\mybookmark{Cover Letter}{cover}
... cover letter here ...

\mypdfbookmark{CV}{CV.1}
\mypdfbookmark[1]{page 1}{CV.1}
\mypdfbookmark[1]{page 2}{CV.2}
\mypdfbookmark[1]{page 3}{CV.3}