Sujet : Re: pgfplots: link to top of embedded page
De : ud.usenetcorrespondence (at) *nospam* web.de (Ulrich D i e z)
Groupes : comp.text.texDate : 27. Sep 2024, 03:51:30
Autres entêtes
Message-ID : <vd56ie$pqj6$1@solani.org>
References : 1
User-Agent : Mozilla/5.0 (X11; Linux i686 on x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0
Holger Schieferdecker wrote:
I include single page PDF documents with \includepdf. They have the same
size and aspect ratio as the output document (A4). With the option
"addtotoc" I can add an entry to the tableofcontents and the bookmarks.
But clicking on that doesn't jump to the top of the included page.
It seems like the link target set by \includepdf is set with respect of
the page margins of the output document. I didn't find any hints in the
manual of pdfpages, besides that "addtotoc" is experimental. Is there a
way of positioning the link target at the top of the included pdf page?
I think there is no official interface but you can hook into
\includegraphics.
To test behavior with multiple pages I created testpictures.pdf from
testpictures.tex;
\documentclass[multi=true]{standalone}
\usepackage{graphicx}
\newenvironment{img}{}{}
\standaloneenv{img}
\begin{document}
\begin{img}%
\includegraphics[width=8cm]{example-image-a}%
\end{img}
\begin{img}%
\includegraphics[width=8cm]{example-image-b}%
\end{img}
\begin{img}%
\includegraphics[width=8cm]{example-image-c}%
\end{img}
\end{document}
This is how I hook into \includegraphics to get a bookmark and a
toc-entry for the first page of the included pdf-file:
\documentclass{article}
\usepackage{graphicx}
\usepackage{pdfpages}
\usepackage{hyperref}
\makeatletter
\newif\iffirstpicture
\newcommand\HookIntoIncludegraphics[4]{%
\let\includegraphicscopy=\includegraphics
\def\includegraphics##1##{\MyIncludegraphicsB{##1}}%
\firstpicturetrue
\def\MyIncludegraphicsB##1##2{%
\ifnum
\iffirstpicture\csname
pdfpages@includegraphics@status\endcsname
\else 0\fi
=1 %
\global\firstpicturefalse
\vbox{%
\
ifAM@landscape\else
\hbox{\kern-\baselineskip\phantomsection}%
\hrule height 0pt
\fi
\hbox{\includegraphicscopy##1{##2}}%
\
ifAM@landscape \hrule height 0pt
\hbox{%
\def\HyperRaiseLinkDefault{-\baselineskip}%
\kern-\baselineskip
\phantomsection
\kern\baselineskip
}%
\fi
\addcontentsline{#1}{#2}{#3}%
\
NR@gettitle{#3}%
\label{#4}%
}%
\else
\includegraphicscopy##1{##2}%
\fi
}%
}%
\makeatother
\begin{document}
\tableofcontents
\bigskip
\noindent \verb|\nameref|-links:
\bigskip
\nameref{sp:ex-a}%
\medskip
\nameref{sp:ex-b}%
\medskip
\nameref{sp:ex-c}%
\begingroup
\HookIntoIncludegraphics{toc}{section}{Example A}{sp:ex-a}%
\includepdf[landscape, scale=0.97, pages=1]{testpictures.pdf}%
\endgroup
\begingroup
\HookIntoIncludegraphics{toc}{section}{Example A, B, C}{sp:ex-b}%
\includepdf[scale=0.97, pages=-]{testpictures.pdf}%
\endgroup
\begingroup
\HookIntoIncludegraphics{toc}{section}{Example B, C}{sp:ex-c}%
\includepdf[landscape, scale=0.97, pages=2-3]{testpictures.pdf}%
\endgroup
Nothing here.
\end{document}
Sincerely
Ulrich