I am using \section*{} to get unnumbered sections in a document. I need to get those sections in the bookmarks of the resulting PDF but they don't show up.
In addition, if the first section is unnumbered, none of the sections below appear either on the PDF.
Asked
Active
Viewed 1,917 times
11
Martin Scharrer
- 262,582
lostinlatex
- 111
1 Answers
7
You can use the \pdfbookmark command provided by the hyperref package which lets you set bookmarks manually. A little example:
\documentclass{article}
\usepackage{hyperref}
\usepackage{lipsum}% just to generate filler text
\begin{document}
\section{Numbered Section One}
\lipsum[1-6]
\section{Numbered Section Two}
\lipsum[1-6]
\pdfbookmark[1]{Unnumbered Section}{unnumbered}
\section*{Unnumbered Section}
\lipsum[1-3]
\section{Numbered Section Three}
\end{document}
Gonzalo Medina
- 505,128
-
Does
page=2not simply link to the page 2 without taking\phantomsectioninto account? – Martin Scharrer Jun 27 '11 at 13:33 -
@Martin: fixed. I used
\newpageand then replace it with\phantomsectionwhile doing some tests and forgot to delete\phantomsection. – Gonzalo Medina Jun 27 '11 at 13:40 -
But this still forces the document author to manually insert the correct page numbers by hand. Also it links to the whole page, not the unnumbered section. – Martin Scharrer Jun 27 '11 at 14:00
-
@Martin: right. Anyway, I've changed my answer. Now I only use
\pdfbookmarkfromhyperrefwhich, in this case, seems like a better option. – Gonzalo Medina Jun 27 '11 at 14:26
bookmarkpackage. It allows you to add PDF bookmarks by yourself. Are you usingarticleor similar class without a\chapterlevel? – Martin Scharrer Jun 27 '11 at 10:14