Deutsch   English   Français   Italiano  
<vd7j0j$voaf$1@solani.org>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!news.mixmin.net!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From: Ulrich D i e z <ud.usenetcorrespondence@web.de>
Newsgroups: comp.text.tex
Subject: Re: pgfplots: link to top of embedded page
Date: Sat, 28 Sep 2024 02:35:29 +0200
Message-ID: <vd7j0j$voaf$1@solani.org>
References: <vcrjpsU2ns40L1@usenet.in-ulm.de> <vd56ie$pqj6$1@solani.org>
 <vd69loU3b7quL1@usenet.in-ulm.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 28 Sep 2024 00:35:31 -0000 (UTC)
Injection-Info: solani.org;
	logging-data="1040719"; mail-complaints-to="abuse@news.solani.org"
User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:60.0) Gecko/20100101
 Thunderbird/60.9.0
Cancel-Lock: sha1:OiLcgDaYOeMk+bmsc6KCVpFfPa8=
Content-Language: de-DE
X-User-ID: eJwFwYEBgDAIA7CXrNDCzhEY/59gQhPU4aKcy73o/FD97MBUw9xyvZVuROv0hC0v7p4Ylf0sXhGX
In-Reply-To: <vd69loU3b7quL1@usenet.in-ulm.de>
Bytes: 4354
Lines: 141

Holger Schieferdecker wrote:

> Am 27.09.2024 um 04:51 schrieb Ulrich D i e z:
>> 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.
> 
> Many thanks for your help, that works. There is one difference in the 
> toc entries. These don't get a number. But I consider that even better.

If you wish numbered sections in the table of contents, then remove the
line

\addcontentsline{#1}{#2}{#3}%

right before

\NR@gettitle{#3}%

and replace each call to

\phantomsection

by

\refstepcounter{#2}%
\addcontentsline{#1}{#2}{\protect\numberline{\@currentlabel}#3}%

..






\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\pdfpages@includegraphics@status
      \else 0\fi
    =1 %
      \global\firstpicturefalse
      \vbox{%
        \ifAM@landscape\else
          \hbox{%
            \kern-\baselineskip
            \refstepcounter{#2}%
            \addcontentsline{#1}{#2}{%
              \protect\numberline{\@currentlabel}#3%
            }%
          }%
          \hrule height 0pt
        \fi
        \hbox{\includegraphicscopy##1{##2}}%
        \ifAM@landscape
          \hrule height 0pt
          \hbox{%
            \def\HyperRaiseLinkDefault{-\baselineskip}%
            \kern-\baselineskip
            \refstepcounter{#2}%
            \addcontentsline{#1}{#2}{%
              \protect\numberline{\@currentlabel}#3%
            }%
            \kern\baselineskip
          }%
        \fi
        \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