GeneralLinks for ToC Entries of included PDF Files

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
krabby
Posts: 12
Joined: Tue Mar 20, 2012 9:38 pm

Links for ToC Entries of included PDF Files

Post by krabby »

Hi,

I have a problem using pdfpages. I want to include PDF documents for my appendix. Everything seems to be fine. I include the PDF successfully. I want the page to appear as a section in the table of contents so I use this

Code: Select all

\addtocontentsline{toc}{section}{NAME OF PDFPAGE}
Looks good! Numbering is totally correct. Now the problem occurs while I am clicking on the Link in my table of contents. It will always send me to the first page of my appendix which is page 29.

To include the graphics I use this.

Code: Select all

\thispagestyle{empty}
\addtocontentsline{toc}{section}{NAME OF PDFPAGE}
\includepdf[landscape=false]{/home/.../file.pdf}
\clearpage
I am using the classicthesis package if this helps.

Any ideas ?

Thanks in advance!

Greetings from Germany
Last edited by localghost on Tue May 07, 2013 9:21 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

krabby
Posts: 12
Joined: Tue Mar 20, 2012 9:38 pm

Links for ToC Entries of included PDF Files

Post by krabby »

Wow, i solved it by my self. It works with the \refstepcounter command.

For everyone else having the same problem just use \refstepcounter{section} before the \addcontentsline command and it just works fine.!!!

But now there is another question coming up. How can I \label the pdfpage and ref to it? Its not working like in figures where you can put the label command after the \includegraphics
Last edited by cgnieder on Tue May 07, 2013 10:30 am, edited 1 time in total.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Links for ToC Entries of included PDF Files

Post by cgnieder »

I don't have much experience with pdfpages so I won't comment on that.
krabby wrote:But now there is another question coming up. How can I \label the pdfpage and ref to it? Its not working like in figures where you can put the label command after the \includegraphics
It is wrong that one can place \label after \includegraphics to reference a figure. A \label always needs and refers to a referenceable counter, i.e., a counter that has been stepped by \refstepcounter. In case of figures inside a {figure} environment this is done by \caption (which is why you have to place the \label after it).

Regards
site moderator & package author
krabby
Posts: 12
Joined: Tue Mar 20, 2012 9:38 pm

Links for ToC Entries of included PDF Files

Post by krabby »

Hi, thanks for your help!

If i do something like this:

Code: Select all

\thispagestyle{empty}
\begin{figure}
 \refstepcounter{section}
 \addcontentsline{toc}{section}{111111111111}
 \includepdf[landscape=false]{test.pdf}
 \label{111}
\end{figure}
It seems to be working with the labels. The problem now is, that all the graphics are on one page! The next include is on top of the other graphics which have been included before.

Even if I use a \newpage after the figure it wont help. If I use a \clearpage i get errors.

Can someone help me out and tell me how to label an included pdf with the includepdf command?

Thank you!
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Links for ToC Entries of included PDF Files

Post by cgnieder »

Without a Infominimal working example (MWE) it is hard to be concrete but I'm quite sure that your use of the {figure} is wrong here. I'd expect something like

Code: Select all

\thispagestyle{empty}
\refstepcounter{section}\label{111}
\addcontentsline{toc}{section}{111111111111}
\includepdf[landscape=false]{test.pdf}
Is the included PDF supposed to be a section or a figure?


Regards
site moderator & package author
krabby
Posts: 12
Joined: Tue Mar 20, 2012 9:38 pm

Re: Links for ToC Entries of included PDF Files

Post by krabby »

You are the man! Your code does work as intended!

Thank you!
Post Reply