3

Part of the my chapters in the document with documentclass scrartcl should not be listed in the table of contents, but I like to have them in the PDF index. Hence, I used \pdfbookmark to get an index entry. Unfortunately, the created link is not placed correctly. It seems like the links goes to the last line of the previous chapter. How can I obtain a correct link?

\documentclass[twoside]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{blindtext}
\usepackage[]{hyperref}

\begin{document}
\tableofcontents
\chapter{First Chapter}
\Blindtext%

\pdfbookmark{Second Chapter}{2nd}\chapter*{Second Chapter}
\Blindtext%
\Blindtext%

\end{document}
2

You can use:

\setchapterpreamble[o]{\pdfbookmark{Second Chapter}{2nd}}

before \chapter* to have a bookmark with the anchor just before the chapter heading but already on the new page. So, if you select the bookmark, the PDF viewer will jump to the beginning of the chapter heading:

\documentclass[twoside]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{blindtext}
\usepackage[]{hyperref}

\begin{document}
\tableofcontents
\chapter{First Chapter}
\Blindtext%

\setchapterpreamble[o]{\pdfbookmark{Second Chapter}{2nd}}
\chapter*{Second Chapter}
\Blindtext%
\Blindtext%

\end{document}

enter image description here

See the KOMA-Script manual for more information about \setchapterpreamble.

Another suggestion would be to add an explicit \cleardoublepage before the \pdfbookmark in you example:

\documentclass[twoside]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{blindtext}
\usepackage[]{hyperref}

\begin{document}
\tableofcontents
\chapter{First Chapter}
\Blindtext%

\cleardoublepage
\pdfbookmark{Second Chapter}{2nd}
\chapter*{Second Chapter}
\Blindtext%
\Blindtext%

\end{document}

Here the anchor is at the top of the text area, so you have some more white-space above the chapter title, if you jump to the bookmark:

bookmark at the top of the text area

The difference in both suggestions varies depending on the vertical position of the chapter head, e.g., if you would use something like

\RedeclareSectionCommand[beforeskip=-.5\textheight]{chapter}

I would use the first suggestion.

  • Although the linked position varies a bit with respect to an original chapter, it is exactly what I searched for. Thank you very much. – Roos Apr 12 at 6:21
4

Simply move \pdfbookmark{Second Chapter}{2nd} behind \chapter*.

See the complete code:

\documentclass[twoside]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{blindtext}
\usepackage[]{hyperref}

\begin{document}
\tableofcontents
\chapter{First Chapter}
\Blindtext%

\chapter*{Second Chapter}
\pdfbookmark{Second Chapter}{2nd} % <===================================
\Blindtext%
\Blindtext%

\end{document}

and the result after clicking on the second chapter in the bookmark (german "Lesezeichen"):

resulting pdf

  • I already tested that and its a bit better, but then the chapter name cannot be directly read. Isn't it possible to align it above the chapter? – Roos Apr 12 at 6:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.