GeneralPDFpages and Hyperref

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
ddenton
Posts: 34
Joined: Tue Mar 20, 2007 6:08 pm

PDFpages and Hyperref

Post by ddenton »

I am importing from PDF files using PDFpages using code that looks like this:

\includepdf[pagecommand={\thispagestyle{plain}}, pages=1,
fitpaper=true, addtolist={1, map, Area of fieldwork activities
and place names mentioned in the text,
carte_mentionnes}]{figs/carte_mentionnes}

This works very well and addtolist= creates the proper line on the TOC.
However, the link back to the imported page does not work. Instead, the TOC link takes my to the first page of my document. I have tried link=true but cannot get this to work.

Could some one please tell me how to make hyperref and PDFpages work together so that the TOC links work back to the included page.

Thanks!

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

countbela666
Posts: 64
Joined: Thu Apr 26, 2007 2:44 pm

PDFpages and Hyperref

Post by countbela666 »

Could you provide a minimum example reproducing the error you're confronted with? The code you posted above works if I use it in the following way:

Code: Select all

\documentclass[demo,english,all]{article}
\usepackage{babel,blindtext,pdfpages,hyperref,hypcap}
\def\demofig{\begin{figure}\centering\includegraphics{foo}\caption{I'm figure \thefigure}\end{figure}}
\begin{document}
  \listoffigures
  \Blindtext
  \demofig\demofig
  \includepdf[%
    pagecommand={\thispagestyle{plain}},
    pages=1,
    fitpaper=true,
    addtolist={1,figure,{Some interesting title},fig:pdf}]%
  {foo}
  \Blindtext
  \demofig\demofig
\end{document}
Regards
Marcel
Listen to me children of the night, beyond the doors of darkness you will find
a thousand worlds for you to see here, take my hand and follow me...
mcclur51
Posts: 9
Joined: Wed Mar 24, 2010 10:30 pm

Re: PDFpages and Hyperref

Post by mcclur51 »

I'm having the same problem....here's a MWE:

\documentclass{article}
\usepackage{pdfpages}
\usepackage{amsmath,amssymb,amsthm,paralist}
\usepackage{graphicx}
\begin{document}
\listoffigures
blah blah blah~\ref{sBib}
\includepdf[pages={1-5},
addtolist={5, table, Literature references for annotated genes, \pageref{sBib}}, label={sBib}]
{Image}
\label{sBib}
\end{document}

How do I get the label so that I can refer to this pdf figure elsewhere in my document?
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

PDFpages and Hyperref

Post by localghost »

From your code I assume that you want to insert an image in PDF format. If so, just use the \includegraphics command from the graphicx package.


Thorsten
mcclur51
Posts: 9
Joined: Wed Mar 24, 2010 10:30 pm

Re: PDFpages and Hyperref

Post by mcclur51 »

Sorry for the confusion. I'm actually trying to add a 'supplementary bibliography' which is 5 pages long and contains references for certain figures. I know, bibtex makes bibliographies...but my boss is difficult and insisted this bibliography be prepared in word. Rather than having to convert to bibtex, I'd like to just insert the pages as pdf print-out. Does this help clear things up?
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

PDFpages and Hyperref

Post by frabjous »

I think you probably want something like:

Code: Select all

\documentclass{article}
\usepackage{pdfpages}
\usepackage{amsmath,amssymb,amsthm,paralist}
\usepackage{graphicx}
\begin{document}
\listoftables
blah blah blah~\ref{sBib}
\includepdf[pages={1-5},
addtolist={1, table, {Literature references for annotated genes}, sBib}]{sbib.pdf}
\end{document}
For addtolist, the first number gives how many pages into the included pdf you want the list to link to -- presumably you want this to go to the first page, not the last one, if you're inserted five pages.

You'd want a list of tables not a list of figures if you're adding this as a table. (Do you really want it as a table though?)

The last thing is the actual name of the label you want if you want to refer to this elsewhere. It's not a place to refer to the label.
Edmund237
Posts: 1
Joined: Sun May 01, 2011 4:58 pm

PDFpages and Hyperref

Post by Edmund237 »

For myself, the package only seems to work to the extend of placing my figure into the list of figures. But when I attempt to use

Code: Select all

\ref 
or

Code: Select all

\pageref 
to refer to the figure, it produced a compiler error - Reference undefined.

Any help into what the problem can be is greatly appreciated. I have followed the instructions on this forum as thus far.
Post Reply