Re: pgfplots: link to top of embedded page

Liste des Groupes 
Sujet : Re: pgfplots: link to top of embedded page
De : ud.usenetcorrespondence (at) *nospam* web.de (Ulrich D i e z)
Groupes : comp.text.tex
Date : 28. Sep 2024, 01:35:29
Autres entêtes
Message-ID : <vd7j0j$voaf$1@solani.org>
References : 1 2 3
User-Agent : Mozilla/5.0 (X11; Linux i686 on x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0
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

Date Sujet#  Auteur
23 Sep 24 * pgfplots: link to top of embedded page7Holger Schieferdecker
27 Sep 24 `* Re: pgfplots: link to top of embedded page6Ulrich D i e z
27 Sep 24  +* Re: pgfplots: link to top of embedded page4Holger Schieferdecker
28 Sep 24  i`* Re: pgfplots: link to top of embedded page3Ulrich D i e z
30 Sep 24  i `* Re: pgfplots: link to top of embedded page2Holger Schieferdecker
30 Sep 24  i  `- Re: pgfplots: link to top of embedded page1Ulrich D i e z
30 Oct 24  `- Re: pgfplots: link to top of embedded page1Holger Schieferdecker

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal