Page Layouthyperref | Problem with Hyperlinks in PDF

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
Jojoba86
Posts: 6
Joined: Fri Dec 09, 2011 7:52 pm

hyperref | Problem with Hyperlinks in PDF

Post by Jojoba86 »

Hi,

I'm using PDFLaTeX and the hyperref package. My problem is that I've added something to the contents line manually, which shows up fine, but the hyperlink in the contents does not go to it, instead it just points to the contents page. The environment with the contents line looks like this:

Code: Select all

\newenvironment{role}
{\addcontentsline{toc}{chapter}{Role of the Author} \pagestyle{empty}
\begin{alwayssingle}
\begin{center}
\vspace*{1.5cm}
{\Large \bfseries Role of the Author}
\end{center}
\vspace{0.5cm}
\begin{quote}}
{\end{quote}\end{alwayssingle}}
I'm calling this, via \begin{role} blah blah \end{role} after the contents line.

Anyone know what I may be doing wrong, or if there is a way around this?
Last edited by Jojoba86 on Fri Dec 09, 2011 9:21 pm, 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.

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

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

hyperref | Problem with Hyperlinks in PDF

Post by Stefan Kottwitz »

Hi,

try

Code: Select all

\phantomsection
before \addcontentsline.

Stefan
LaTeX.org admin
Jojoba86
Posts: 6
Joined: Fri Dec 09, 2011 7:52 pm

Re: hyperref | Problem with Hyperlinks in PDF

Post by Jojoba86 »

Thank you so much Stefan, that did the job perfectly!
Post Reply