I am using pdfpages
to tie several PDF documents together (yes, they must be separate documents) into a portfolio. My problem is that I need to place many, many links within one child document that link to the first page of other child documents (which are bookmarked in the outer document). Here is an MWE:
******ChildOne.tex:******
\documentclass{article}
\usepackage[bookmarksopenlevel=1,%
pdfpagemode=UseOutlines]{hyperref}
\hypersetup{
pdfinfo={
Title={Child One},
Author={Me}
}
}
\author{Me}
\title{Child One}
\begin{document}
\maketitle
Here is where I want to refer to Child Two.
I can do it by \href[page=3]{OuterDoc.pdf}{absolute page reference},
but the zoom level changes, and I don't always know the absolute
page number ahead of time (because there are so many child documents
of varying lengths).
My preference would be to refer to Child Two automatically, and
\href{OuterDoc.pdf#nameddest=ChildTwo}{a named destination} doesn't
seem to work.
\end{document}
******ChildTwo.tex:******
\documentclass{article}
\usepackage{lipsum}
\usepackage[bookmarksopenlevel=1,%
pdfpagemode=UseOutlines]{hyperref}
\hypersetup{
pdfinfo={
Title={Child Two},
Author={Me}
}
}
\author{Me}
\title{Child Two}
\begin{document}
\maketitle
\lipsum[1-5]
\end{document}
After compiling ChildOne.tex
and ChildTwo.tex
, I run pax
on ChildOne.pdf
(using the information in this question), and then compile OuterDoc.tex
.
******OuterDoc.tex:******
\documentclass{article}
\author{Me}
\title{Big Title}
\usepackage{pdfpages}
\newcommand{\singlepageinpdf}{1}
\newcommand{\pagesinpdf}{1}
\newcounter{includepdfpage}
\newcounter{currentpagecounter}
\newcommand{\addlabelstoallincludedpages}[1]{%
\refstepcounter{includepdfpage}%
\stepcounter{currentpagecounter}%
\label{#1.\thecurrentpagecounter}}
\newcommand{\modifiedincludepdf}[4]{%
\setcounter{currentpagecounter}{0}%
\includepdf[pages=1,pagecommand={\pdfbookmark[#1]{#2}{#3}\addlabelstoallincludedpages{#3}}]{#4}%
\pdfximage{#4}%
\renewcommand{\pagesinpdf}{\the\pdflastximagepages}%
\if\pagesinpdf\singlepageinpdf%
\relax%
\else%
\includepdf[pages=2-,pagecommand=\addlabelstoallincludedpages{#3}]{#4}%
\fi%
}
\usepackage{pax}
\usepackage[bookmarksopenlevel=1,%
pdfpagemode=UseOutlines,%
pdfpagelayout=OneColumn,%
pdfnewwindow=false,%
pdfstartview=FitH]{hyperref}
\hypersetup{
pdfinfo={%
Title={Outer Doc},%
Author={Me}%
}%
}
\usepackage{bookmark}
\begin{document}
\bookmark[page=1, level=0]{Title Page}
{\begin{center}
\Huge \textbf{My Big Document}
\end{center}
}
\modifiedincludepdf{0}{First Child}{ChildOne}{ChildOne.pdf}
\modifiedincludepdf{0}{Second Child}{ChildTwo}{ChildTwo.pdf}
\end{document}
Because my \href[page=3]{OuterDoc.pdf}{absolute page reference}
link works correctly, it looks to me like the linking system, including pax
, is working as expected. However, \href{OuterDoc.pdf#nameddest=ChildTwo}{a named destination}
doesn't give me any joy.
Am I possibly out of luck because a bookmark is not a valid destination?? (And if so, what brilliant person out there can think of a workaround?)
An additional (but small) problem is that the pdfstartview=FitH
option of hyperref
(2012/11/06 v6.83m) doesn't load the page in fitted width (for the [page=3]
link) -- it zooms to the whole-page view.