According to the bookmark
package documentation the font options for \bookmarksetup
are bold
(for bold bookmarks) and/or italic
(for italics). There can be combined, if required. Here's an MWE with the output viewed in Adobe Acrobat Reader:
\documentclass{article}
\usepackage{bookmark}% http://ctan.org/pkg/bookmark
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\bookmarksetup{bold}% Default bold bookmarks
\begin{document}
\section{First section}
\lipsum[1]
\bookmarksetupnext{bold=false,italic}% Non-bold and italic bookmark only for next sectional unit
\subsection{A subsection}
\lipsum[1-2]
\section{Second section}
\lipsum[2]
\section{Last section}
\lipsum[3]
\end{document}
Assuming that you're using hyperref
already*, the documentation states:
Usually hyperref
automatically adds bookmarks for \section
and similar macros. But they can also set manually.
The manual setting is performed using
\pdfbookmark[<level>]{<text>}{<name>}
where \part
is level -1
, \chapter
is level 0
, \section
is level 1
, ... It places <text>
in the bookmarks and can be referenced internally (via a hyperlink) as <name>
. Or, if you want to place it at a level relative to the current one, use
\currentpdfbookmark{<text>}{<name>}
\subpdfbookmark{<text>}{<name>}
\belowpdfbookmark{<text>}{<name>}
where <text>
and <name>
have similar meanings as before.
In the following MWE, hyperref
creates sectional bookmarks for every unstarred heading up to secnumdepth
and only the numbered, unstarred versions show up in the ToC. The starred versions, removed from the ToC by default, are included using some variation of \...pdfbookmark
:
\documentclass{book}
\usepackage{hyperref}% http://ctan.org/pkg/hyperref
\usepackage{bookmark}% http://ctan.org/pkg/bookmark
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\begin{document}
\tableofcontents
\part{FIRST PART}
\chapter{First chapter} \lipsum[1]
\section{First section} \lipsum[2]
\section*{Second section} \currentpdfbookmark{Second section}{ch:1:sec:2} \lipsum[3]
\section{Third section} \lipsum[4]
\subsection{First subsection} \lipsum[5]
\subpdfbookmark{First subsubsection}{ch:1:sec:3:ssec:1:sssec:1}\subsubsection{First subsubsection} \lipsum[6]
\currentpdfbookmark{Second subsubsection}{ch:1:sec:3:ssec:1:sssec:2} \subsubsection*{Second subsubsection} \lipsum[7]
\subsection{Second subsection} \lipsum[8]
\currentpdfbookmark{Third subsection}{ch:1:sec:3:ssec:3} \subsection*{Third subsection} \lipsum[9]
\pdfbookmark[2]{Fourth subsection}{ch:1:sec:3:ssec:4}\subsection*{Fourth subsection} \lipsum[10]
\subsection{Fifth subsection} \lipsum[11]
\chapter{Second chapter} \lipsum[12]
\end{document}
For the inclusion of sectional numbers in the PDF bookmark panel, use the bookmarksnumbered
option of hyperref
:
\usepackage[bookmarksnumbered]{hyperref}% http://ctan.org/pkg/hyperref
The above MWE will then produce:
* If not, the bookmark
package provides similar, stand-alone functionality for inclusion of PDF bookmarks in your document. In fact, hyperref
suggests using it as improved bookmark organization.
Best Answer
The following provides the functionality to swap titles and numbers in the bookmarks:
The above MWE provides
\reversetitlenum
that acts as a switch. After calling this macro, all subsequent sectional units will have a swapped number/title in the bookmarks.\reverttitlenum
is a switch that reverts back to the default presentation.Separate macros for each sectional unit (
\part
,\chapter
and\section
, although other can also be defined as needed) is also provided to selectively activate the swapping of bookmark constructions.The main approach to this solution is to hack into
\Hy@writebookmark
- the macro that is finally called to construct the bookmark (frombookmark.dtx
):It takes 5 arguments of which the first 2 are the most important from a visual/end user perspective.
#1
contains the sectional unit number<num>
(although it is never used), while#2
contains a ToC-like entry of the form\protect\numberline{<num>}<title>
. The default is to only use#2
. The suggested patch in\reversetitlenumswap
uses both, printing it as#2\ #1
while also temporarily deactivating the macro\numberline
. The patch is inserted just above the\bookmark
entry, while also updating the use of only#2
(resulting in two separate patches).It is not necessary to load
hyperref
.bookmark
loadshyperref
and uses some of its code. See Which package should I load first:hyperref
orbookmark
?