# Probem with Bookmarks and Linking and page numbering

I have several problems with my latex book:

1. I want the appendix bookmark as an extra bookmark on part level, now it is under my second part. In the table of content its is right, but not on the pdf bookmarks.

2. The bookmark link of the Index is not correct, if I click on it, I go to the list of tables, not to the Index

3. The page numbering is totaly wrong. How can I do big roman Letters for the frontmatter and normal letters on the mainmatter without getting problems with the linking? I want that page numbers on every page, now there is no number or totally wrong.

My Latex - Code:

\documentclass{book}
\usepackage{geometry}

\geometry{left=4cm,right=3cm, top=2cm, bottom=2cm}

\usepackage{titlesec}
\titlespacing*{\chapter}{0pt}{-30pt}{20pt}
\titleformat{\chapter}[display]{\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
\usepackage[ngerman]{babel}
\usepackage{mathptmx}
\usepackage{helvet}
\usepackage{wallpaper}
\usepackage{color}
\usepackage[final]{pdfpages}
%,bookmarksopenlevel={1}
\hypersetup{
pdftitle={test},
pdfsubject={test},
pdfkeywords={test},
}

\usepackage{xcolor,bookmark}
\usepackage{scrextend}
\usepackage{titlepic}
\usepackage{shorttoc}
\usepackage{courier}
%
\usepackage{type1cm}

\usepackage{makeidx}         % allows index generation

\usepackage{graphicx}        % standard LaTeX graphics tool
% when including figure files
\usepackage{multicol}        % used for the two-column index
\usepackage[bottom]{footmisc}% places footnotes at page bottom
\usepackage{tocstyle}
\usetocstyle{allwithdot}

\makeindex             % used for the subject index
% please use the style svind.ist with
\setcounter{tocdepth}{4}
\setcounter{secnumdepth}{4}

\begin{document}
\author{test}
\bookmark[page=\thepage,rellevel=1,keeplevel,view={XYZ},bold,color=blue]{Cover}

\includepdf{cover}
\pagestyle{empty}
\newpage

\section*{}
\newpage
\huge
\textbullet \hspace{0.1cm} test \hspace{-0.1cm} \textbullet\\
\\
\vspace{7cm}
\\
\large
test test\\
\vspace{4cm}
\\
\bookmark[page=\thepage,rellevel=1,keeplevel,view={XYZ},bold,color=blue]{Info}
Die Verlagsseite

\frontmatter
\include{dedic}
\newpage\section*{}
\include{foreword}
\newpage\section*{}
\include{preface}
\newpage\section*{}
\include{acknow}
\newpage\section*{}
\include{acronym}
%
\
\shorttableofcontents{Inhalts\"ubersicht}{1}
\bookmark[page=15,rellevel=1,keeplevel,view={XYZ},color=red]{Inhalts\"ubersicht}
\bookmark[page=17,rellevel=1,keeplevel,view={XYZ},color=red]{Inhaltsverzeichnis}
\tableofcontents

%

\mainmatter
\include{part1}
\include{chapter1}
\include{chapter2}
\include{part2}
\include{chapter3}
\include{chapter4}
\backmatter

\appendix

\include{appendix}

\listoffigures
\newpage
\listoftables
\backmatter%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\include{glossary}
%\include{solutions}

\printindex
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\includepdf{ueberautor}
\includepdf{back}
\end{document}


I tried a lot and hard for it and I could find no solution - would be great, if you could help me. Thanks

-
ok, thanks a lot for your answer, but now I have the following problem: If I click on the booksmark in the pdf file I get to the rigth page, but the problem is: Not to the top of e.g. the index, but the the "middle". So the entry "Index" is not readable, one has to scroll up, but I want have the following: Click on the bookmark Index and the Index appears, not scrolled to the middle or something like that thanks a lot again! – Studentgerman Aug 16 '12 at 13:50

## 1. Appendix bookmark

Package bookmarks allows to restart the bookmark hierarchy at top level:

\bookmarksetup{startatroot}


If the appendix is something like

\chapter{Appendix}


\bookmarksetup{startatroot}
\chapter{Appendix}


something like the following can be used:

\cleardoublepage
\phantomsection
\chapter*{\appendixname}


Explanation, see 2.

## 2. Index bookmark

\printindex


Then you get the page number from the end of the index in the table of contents. The bookmark also needs an anchor that can be set by \phantomsection.

\cleardoublepage
\phantomsection % anchor setting
\printindex


The following example shows, how the correct absolute page numbers can be get from labels for use in \bookmark. I use package zref here for the labels and references, because it provides absolute page numbers and expandable extraction methods.

\documentclass{book}

\usepackage[ngerman]{babel}
\usepackage{xcolor}

\usepackage{titlesec}
\titlespacing*{\chapter}{0pt}{-30pt}{20pt}
\titleformat{\chapter}[display]{\normalfont\huge\bfseries}{\chaptertitlename\
\thechapter}{20pt}{\Huge}

\hypersetup{
pdftitle={test},
pdfsubject={test},
pdfkeywords={test},
}
\usepackage{bookmark}
\usepackage{shorttoc}

\usepackage{makeidx}         % allows index generation
\makeindex

\usepackage{tocstyle}
\usetocstyle{allwithdot}

\usepackage{zref-abspage}

\makeatletter
\newcounter{zpage}
\renewcommand*{\thezpage}{pagelabel\the\value{zpage}}
\newcommand*{\pagebookmark}[2][]{%
\stepcounter{zpage}%
\zref@labelbyprops{\thezpage}{abspage}%
\zref@refused{\thezpage}%
\bookmark[{%
page=\zref@extractdefault{\thezpage}{abspage}{1},%
view={XYZ},%
#1%
}]{#2}%
}
\makeatother

\setcounter{tocdepth}{4}
\setcounter{secnumdepth}{4}

\author{test}

\begin{document}
\pagestyle{empty}
\hypersetup{pageanchor=false}

\pagebookmark[rellevel=1,keeplevel,bold,color=blue]{Cover}

\begin{center}
\fbox{\bfseries\Huge Cover}
\end{center}
\newpage

\null\newpage % empty page

% Verlagsseite
\pagebookmark[rellevel=1,keeplevel,bold,color=blue]{Info}
\begingroup
\huge
\textbullet \hspace{0.1cm} test \hspace{-0.1cm} \textbullet

\vspace{7cm}

\large
test test

\vspace{4cm}

Die Verlagsseite
\newpage
\endgroup

\frontmatter
\hypersetup{pageanchor=true}

\chapter*{Dedication}

\chapter*{Foreword}

\chapter*{Preface}

\chapter*{Acknowlegements}

\cleardoublepage
\pagebookmark[rellevel=1,keeplevel,color=red]{Inhalts\"ubersicht}
\shorttableofcontents{Inhalts\"ubersicht}{1}

\cleardoublepage
\pagebookmark[rellevel=1,keeplevel,color=red]{Inhaltsverzeichnis}
\tableofcontents

\mainmatter

\part{First part}
\chapter{First chapter}
\index{first}
\chapter{Second chapter}
\index{second}
\part{Second part}
\chapter{Third chapter}
\index{third}
\chapter{Fourth chapter}
\index{fourth}

\backmatter

\appendix

\bookmarksetup{startatroot}
\chapter{\appendixname}

\listoffigures
\listoftables

\cleardoublepage
\phantomsection
\printindex

\end{document}


The bookmark window:

## 4. Empty pages

\section*{}\newpage


is not the best way to create empty pages, the risk of side effects because of the complex \section is too large. A simple \null is sufficient to get something invisible on the page:

\null\newpage


Headers/footers can also be suppressed, if needed:

\begingroup
\thispagestyle{empty}
\null
\newpage
\endgroup


But in the cases above often a simple

\cleardoublepage


might suffice.

Because the document is intended for printing, invisible links make sense. Since hyperref 2011/02/05 v6.82a option hidelinks is added for this purpose.