2

The pagenumber from "Inhaltsverzeichnis" is missing in the bookmarks.

I manually added the Inhaltsverzeichnis (TOC) with

\addcontentsline{toc}{chapter}{Inhaltsverzeichnis}

but it doesn't print the pagenumber. The LOF or LOT, which I added with the same command, appear as I wish.

Missing page number for pdfbookmark

When I add

\pdfbookmark{Inhaltsverzeichnis}{Inhaltsverzeichnis}

instead of \addcontentsline, I get what I want in the bookmarks but the TOC disappears from the TOC.

Missing "Inhaltsverzeichnis" in TOC

How to fix that?

UPDATE

Here's the MWE

\documentclass[12pt,a4paper,oneside]{scrbook}
\usepackage[ngerman]{babel}     % deutsche Worttrennung
\usepackage[T1]{fontenc}        % Ausgabe von Sonderzeichen und Akzenten in PDF verbessert
\usepackage[utf8]{inputenc}     % Eingabe von Sonderzeichen möglich
\usepackage{lipsum}

\setcounter{secnumdepth}{3}     % subsubsections nummerieren
\setcounter{tocdepth}{3}        % subsubsections in TOC

\usepackage[ %
    pdfproducer={Texmaker},     % 
    pdfcreator={pdfLaTeX},      % 
    hidelinks,                  % versteckt die Boxen um die Links in der PDF
    bookmarksnumbered,          % nummereiert Lesezeichen
    ]{hyperref}                 % PDF Metainformationen hinzufügen 

\begin{document}

\pagenumbering{gobble}
\chapter*{Sperrvermerk}
\addcontentsline{toc}{chapter}{Sperrvermerk}
\lipsum[1]
\clearpage

\chapter*{Vorwort}
\addcontentsline{toc}{chapter}{Vorwort}
\lipsum[2]
\clearpage

\pagenumbering{Roman}
\pagestyle{headings}

\addcontentsline{toc}{chapter}{Inhaltsverzeichnis}
\tableofcontents

\chapter{One}
\lipsum[3]
\section{One.1}
\lipsum[4]
\section{One.2}
\lipsum[5]

\end{document}
5
  • \addcontentsline adds the bookmark automatically. \pdfbookmark will not add an entry to the Toc however. Please provide a minimal working example (MWE)
    – user31729
    Commented Sep 4, 2014 at 12:25
  • Bookmarks do not show pagenumbers, normally
    – user31729
    Commented Sep 4, 2014 at 12:33
  • 2
    Are you using a KOMA class? There is a much simple and safer way: \setuptoc{toc}{totoc} But ask yourself, why it is not put there by default.
    – Johannes_B
    Commented Sep 4, 2014 at 12:43
  • 1
    It seems you like to get yourself into trouble. Correct use of hyperref and addcontentsline
    – Johannes_B
    Commented Sep 4, 2014 at 12:48
  • Indeed, setuptoc did it. Didn't know that command until now. Thank you very much! Commented Sep 4, 2014 at 12:59

3 Answers 3

3

As long there is no MWE, I assume book.cls

\documentclass{book}

\usepackage{hyperref}

\begin{document}

\phantomsection
\tableofcontents
\addcontentsline{toc}{chapter}{\contentsname}%
\chapter{First}
\section{First}

\end{document}

Another solution for the MWE

Use \setuptoc{toc}{totoc} in the preamble and remove the line \addcontentsline for the contents. It will appear otherwise again.

\documentclass[12pt,a4paper,oneside]{scrbook}
\setuptoc{toc}{totoc}
\usepackage[ngerman]{babel}     % deutsche Worttrennung
\usepackage[T1]{fontenc}        % Ausgabe von Sonderzeichen und Akzenten in PDF verbessert
\usepackage[utf8]{inputenc}     % Eingabe von Sonderzeichen möglich
\usepackage{lipsum}

\setcounter{secnumdepth}{3}     % subsubsections nummerieren
\setcounter{tocdepth}{3}        % subsubsections in TOC

\usepackage[ %
    pdfproducer={Texmaker},     % 
    pdfcreator={pdfLaTeX},      % 
    hidelinks,                  % versteckt die Boxen um die Links in der PDF
    bookmarksnumbered,          % nummereiert Lesezeichen
    ]{hyperref}                 % PDF Metainformationen hinzufügen 

\begin{document}

\pagenumbering{gobble}
\chapter*{Sperrvermerk}
\addcontentsline{toc}{chapter}{Sperrvermerk}
\lipsum[1]
\clearpage

\chapter*{Vorwort}
\addcontentsline{toc}{chapter}{Vorwort}
\lipsum[2]
\clearpage

\pagenumbering{Roman}
\pagestyle{headings}

\tableofcontents

\chapter{One}
\lipsum[3]
\section{One.1}
\lipsum[4]
\section{One.2}
\lipsum[5]

\end{document}
1
  • you're the man, thanks! setuptoc did the magic.. Commented Sep 4, 2014 at 12:57
1

Assuming you're using KOMA-Book (scrbook) and after providing a wrong solution (duplicate entries in pdf bookmarks, see my first answer), I googled a bit and found a solution for your problem. \setuptoc{toc}{totoc} is what you need. After compiling the document three times, everything should be fine:

\documentclass{scrbook}
\setuptoc{toc}{totoc}

\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{blindtext}
\usepackage{bookmark}

\begin{document}
\frontmatter

\title{foobar}
\maketitle

\chapter{Before TOC 1}
\Blindtext

\chapter{Before TOC 2}
\Blindtext

\tableofcontents

\mainmatter
\chapter{Chap 1}
\Blindtext

\chapter{Chap 2}
\Blindtext

\end{document}

pdf

3
  • This solution has made it from my comment to christians answer a while back. The OP also gave the tick to @christian a few minutes ago.
    – Johannes_B
    Commented Sep 4, 2014 at 13:20
  • @Johannes_B: Yeah, just saw that after I added my (correct) answer... Is there a way to delete own (wrong, ...) answers?
    – albert
    Commented Sep 4, 2014 at 13:25
  • You should see a delete button next to the edit button.
    – Johannes_B
    Commented Sep 4, 2014 at 13:40
0

Just use both \pdfbookmark and \addcontentsline like this:

% part before generating the TOC

\pdfbookmark[chapter]{\contentsname}{toc} %add TOC to bookmarks
\addcontentsline{toc}{chapter}{\contentsname} %add TOC to TOC
\tableofcontents

% part after generating the TOC

enter image description here

2
  • This does not work! First [chapter] is unknown and it adds a double entry to the bookmarks
    – user31729
    Commented Sep 4, 2014 at 12:41
  • @ChristianHupfer: Ohh, didn't realized the double entries in my bookmarks. Sorry...
    – albert
    Commented Sep 4, 2014 at 12:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .