I am appending documents of many pages, but would like to have links to the beginnings of each document first page in TOC. Pseudocode for making custom TOC
- Add custom label at the first page of pdf documents
- Add custom labels to TOC
Code which adds pagenumbering on pages without decreasing size of pdf-pages, but does nothing to the application of references at the beginning of pdf-pages
\documentclass{article}
\usepackage{pdfpages}
\usepackage{hyperref} % for links in TOC
% https://tex.stackexchange.com/q/56316/13173
\usepackage{fancyhdr}
\renewcommand{\headrulewidth}{0pt} % Werner, remove top margin border
% https://tex.stackexchange.com/a/338919/13173
\usepackage{letltxmacro}
\LetLtxMacro\oldincludepdf\includepdf
\renewcommand{\includepdf}[2][]{%
\oldincludepdf[pagecommand={\thispagestyle{fancy}},#1]{#2}}
\begin{document}
% TODO add custom labels to TOC
\tableofcontents
% Pseudocode
% \addcontentsline{toc}{someLabelForPdf}{\listPdfBeginningLabels}
% TODO add here a label/... to the beginning of pdf page such that included in TOC
\includepdf[pages=1,pagecommand=\thispagestyle{plain}]{7.pdf}
% No reference to the rest
\includepdf[pages=2-,pagecommand=\thispagestyle{plain}]{7.pdf}
% TODO reference here
\includepdf[pages=1,pagecommand=\thispagestyle{plain}]{8.pdf}
% No reference to the rest
\includepdf[pages=2-,pagecommand=\thispagestyle{plain}]{8.pdf}
\end{document}
Maybe pseudocode \addcontentsline{toc}{someLabelForPdf}{\listPdfBeginningLabels} can work.
Example TOC
Table of Contents
7 1
8 150
Trying Samcarter's proposal
Manual where Samcarter is poiting to is about the following addtotoc so I try the following but I get the following output
\includepdf[pages=-,pagecommand=\thispagestyle{plain},addtotoc={1}]{7.pdf}
Output
<use "7.pdf" > <use "7.pdf" > <use "7.pdf" page1> <use "7.pdf" page1>
[1] <use "7.pdf" page1> <use "7.pdf" page1>
Runaway argument?
addtotoc={1}]{9.pdf} \includepdf [pages=-,pagecommand=\thispagestyle \ETC.
! Paragraph ended before \AM@parse@toclisti was complete.
<to be read again>
\par
l.33
addtotoc Adds an entry to the table of contents. This option requires five
arguments, separated by commas:
addtotoc={hpage number i,hsection i,hlevel i,hheading i,hlabel i}
Iterating Christian's proposal
No need to separate by pages=1 and pages=2-.
Some minor cosmetic changes in links
\documentclass{article}
\usepackage{pdfpages}
\usepackage[hidelinks]{hyperref}
\usepackage{xcolor}
\hypersetup{
colorlinks,
linkcolor={red!50!black},
citecolor={blue!50!black},
urlcolor={blue!80!black}
}
% https://tex.stackexchange.com/q/56316/13173
\usepackage{fancyhdr}
\renewcommand{\headrulewidth}{0pt} % Werner, remove top margin border
% https://tex.stackexchange.com/a/338919/13173
\usepackage{letltxmacro}
\LetLtxMacro\oldincludepdf\includepdf
\renewcommand{\includepdf}[4][]{%
\oldincludepdf[pagecommand={\thispagestyle{fancy}},addtotoc={#4,section,1,#2,#3}, #1]{#2}}
\begin{document}
\tableofcontents
\includepdf[pages=-,pagecommand=\thispagestyle{plain}]{8.pdf}{p1d8}{1}
\end{document}
OS: Debian 8.7
Hardware: Asus Zenbook UX303UB
Test file 7.pdf: http://www.texdoc.net/texmf-dist/doc/latex/pdfpages/pdfpages.pdf
Test file 8.pdf: http://ctan.sharelatex.com/tex-archive/macros/latex/required/graphics/grfguide.pdf
pdfpagesdocumentation, section "Hypertext options" and "Experimental options" – samcarter_is_at_topanswers.xyz Apr 19 '17 at 14:047.pdfor shall we invent some? ;-) – Apr 19 '17 at 17:42addtotocis tricky, one must provide the correct information, which is actually 5 parameters. Shall this be added as 5 additional arguments to\includepdf? – Apr 19 '17 at 18:05