GeneralHow to link to Table of Contents and first page in PDF?

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
CeoN
Posts: 6
Joined: Fri Jan 22, 2010 2:50 pm

How to link to Table of Contents and first page in PDF?

Post by CeoN »

I am using the hyperref package to create links to access chapters and sections within the PDF document - which works fine - see a minimal working example below - however i additionally would like to have a direct link in the pdf viewer for the user to click which directly leads towards the first page of the document and the table of contents. Is this possible with the hyperref package or how could one achieve this?

I compiled the following example with latex->dvipdfm

Code: Select all

Code, edit and compile here:
\documentclass[
12pt,
dvipdfm,
openright,
a4paper,
parskip=half,
toc=bibliography,
numbers=noenddot
]{scrbook}
\usepackage[usenames,dvipsnames,showerrors]{xcolor}
\usepackage[
dvipdfm,
colorlinks,
linkcolor=black,
citecolor=black,
urlcolor=black,
bookmarks=true
]{hyperref}
%
\begin{document}
\thispagestyle{empty}
\begin{center}
{\huge Firstpage}
\end{center}
%
\tableofcontents
\chapter{One}
\newpage
\section{One.One}
\newpage
\section{One.Two}
\newpage
\chapter{Two}
\newpage
\section{Two.One}
\newpage
\section{Two.Two}
\newpage
\chapter{Three}
\newpage
\section{Three.One}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

How to link to Table of Contents and first page in PDF?

Post by frabjous »

Do you mean with the PDF bookmarks that are typically displayed in the Side Panel of your PDF viewer? If so, try this:

Code: Select all

Code, edit and compile here:
\documentclass[
12pt,
dvipdfm,
openright,
a4paper,
parskip=half,
toc=bibliography,
numbers=noenddot
]{scrbook}
\usepackage[usenames,dvipsnames,showerrors]{xcolor}
\usepackage[
dvipdfm,
colorlinks,
linkcolor=black,
citecolor=black,
urlcolor=black,
bookmarks=true
]{hyperref}
%
\begin{document}
\thispagestyle{empty}
\phantomsection\pdfbookmark{First page}{firstpage}
\begin{center}
{\huge Firstpage}
\end{center}
%
\cleardoublepage\phantomsection\pdfbookmark{Contents}{contents}
\tableofcontents
\chapter{One}
\newpage
\section{One.One}
\newpage
\section{One.Two}
\newpage
\chapter{Two}
\newpage
\section{Two.One}
\newpage
\section{Two.Two}
\newpage
\chapter{Three}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
This is covered in the hyperref manual.
CeoN
Posts: 6
Joined: Fri Jan 22, 2010 2:50 pm

Re: How to link to Table of Contents and first page in PDF?

Post by CeoN »

Thanks alot! Exactly what i was looking for. And in my eyes not that easy to find within the manual.
mina
Posts: 12
Joined: Sun Jul 12, 2009 4:48 pm

How to link to Table of Contents and first page in PDF?

Post by mina »

Hi,

I'm reopening this topic because CeoN asks the same question I'd like to ask:

how do I get the PDF viewer to display the front page and the TOC in the bookmarks panel?

My mwe will display this (adobe reader 9 on Linux):
adobe.png
adobe.png (8.77 KiB) Viewed 12381 times
Edit by localghost: No external links! Attachments go onto the forum server.

You see the top of the bookmarks panel with at the top the tables, figures and abbreviations page followed by some chapters. I am looking for a way to show bookmarks for the title page and the toc as well.
Is this possible?

My mwe:

Code: Select all

Code, edit and compile here:
\documentclass[a4paper,10pt]{report}
\usepackage[english]{babel}
\usepackage{hyperref}
\hypersetup{
colorlinks=false,
linkcolor=black,
citecolor=black,
filecolor=black,
pagecolor=black,
urlcolor=blue,
bookmarks=true,
pdfborder={0 0 0 0},
pdftitle={sometitle},
pdfauthor={me},
pdfkeywords={somekeywords},
pdfdisplaydoctitle=true,
pdftoolbar=true,
pdfmenubar=true,
pdfstartview=X Y Z
}
\begin{document}
% title page
\pagestyle{empty} % no page numbering
\begin{titlepage}
\begin{center}
\begin{minipage}{1\textwidth}
some titlepage stuff
\end{minipage}
\end{center}
\end{titlepage}
% followed by one blank page!
\clearpage\mbox{}\clearpage
\begin{abstract}
[Abstract]
\end{abstract}
\pagestyle{plain} % pagenumbering
\setcounter{page}{4} % start at page 4 - titlepage is page 1
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Additional packages I use (you never know if they influence anything...):
geometry, titlesec, tocloft (with titles option), graphicx, wrapfig, subfig, sidecap, multicol, mdwlist.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

How to link to Table of Contents and first page in PDF?

Post by localghost »

Well, since you hijacked a solved topic (against the Board Rules), you already have the solution and there is nothing to answer.


Best regards and welcome to the board
Thorsten
Post Reply