I have read a number of other threads about incorrect link anchors for PDF bookmarks but either the suggestions don't work for me or I don't understand them.
I have the following document for which I'd like to have PDF bookmarks. But the PDF bookmarks for the sections go to the wrong pages--they go to the page before the one they should actually go to. But this only happens when the previous section has subsections--if the previous section has no subsections, the section bookmarks go to the correct page.
I believe that this has something to do with the \clearpage
s in my styling of the section using titlesec
. I would like to have the section title on its own page, but I cannot figure out how to get the bookmarks to work when I do it. The bookmarks for the sub- and subsubsections (not shown here) work fine, as far as I can tell.
MWE follows.
\documentclass[12pt]{article}
\usepackage[protrusion=true,expansion=true]{microtype}
\usepackage[margin=1.0in]{geometry}
\usepackage{mathpazo}
\usepackage[T1]{fontenc}
\linespread{1.05}
\usepackage[utf8]{inputenc}
\usepackage{titlesec}
\titleformat{\section}[display]%
{\clearpage\filcenter\Huge\bfseries\scshape}%
{\vspace*{\fill}}{0pt}{}[\vspace*{\fill}\thispagestyle{empty}\clearpage]
\titleformat{\subsection}{\Large\bfseries}{}{6pt}{}
\titleformat{\subsubsection}{\large\bfseries}{}{12pt}{}
\usepackage[stable]{footmisc}
\usepackage{xcolor}
\definecolor{navyblue} {RGB}{0. ,0. ,139.}
\usepackage[hyperfootnotes=false]{hyperref}
\hypersetup{%
colorlinks=true,
breaklinks,
citecolor=black,
filecolor=black,
linkcolor=red,
urlcolor=navyblue,
urlbordercolor=navyblue%
}
\title{Sample Doc}
\author{Me}
\date{\today}
\begin{document}
\maketitle
\thispagestyle{empty}
\tableofcontents
% -----------------------------------------------------------
\section{Section 1}
% -----------------------------------------------------------
\subsection{Subsection 1}
% -----------------------------------------------------------
\section{Section 2}
% -----------------------------------------------------------
\subsection{Subsection 1}
\subsection{Subsection 2}
% -----------------------------------------------------------
\section{Section 3}
% -----------------------------------------------------------
% -----------------------------------------------------------
\section{Section 4}
% -----------------------------------------------------------
\subsection{Subsection 1}
\subsection{Subsection 2}
\subsection{Subsection 3}
% -----------------------------------------------------------
\section{Section 5}
% -----------------------------------------------------------
\subsection{Subsection 1}
\subsection{Subsection 2}
\subsection{Subsection 3}
\end{document}
$ $
would be enough. The mechanism is explained in more detail here: Overfull box and broken pagination with page that contains only section headings