I have a set of pdf files which I want to merge into a larger pdf files. Each individual pdf file is an article with sections. I am hoping to make the merged pdf file into a book format with each article being a chapter, whose sections and subsections correspond to that of the individual chapter.
What I need is a table of contents page which shows the chapters, the sections, and subsections and links to them with this table of contents page being displayed in the sidebar of a pdf reader such as evince (which calls it an index).
What I have right now:
\documentclass{report}
\author{<somename>}
\title{<sometitle>}
\date{<somedate>}
\usepackage{pdfpages}
\usepackage[pdfauthor={<somename>},%
pdftitle={<sometitle>},%
pdftex]{hyperref}
\begin{document}
\tableofcontents
\clearpage\phantomsection
\addcontentsline{toc}{chapter}{<chaptername>}
\includepdf[pages=-,linktodoc=false]{file1.pdf}
\clearpage\phantomsection
\addcontentsline{toc}{chapter}{<chaptername>}
\includepdf[pages=-,linktodoc=false]{file2.pdf}
\clearpage\phantomsection
\addcontentsline{toc}{chapter}{<chaptername>}
\includepdf[pages=-,linktodoc=false]{file3.pdf}
\clearpage\phantomsection
\addcontentsline{toc}{chapter}{<chaptername>}
\includepdf[pages=-,linktodoc=false]{file4.pdf}
\end{document}
Now file3.pdf and file4.pdf have sections and subsections in them. How do I display these sections and subsections in the table of contents and link from there to the actual page? (And I also would like this info to be displayed in the sidebar of a pdf reader such as evince).