[Tex/LaTex] Using \clearpage breaks \hyperref bookmarks

hyperref

From this question I have used

\usepackage{titlesec}
\newcommand{\sectionbreak}{\clearpage}

to ensure that sections start on their own page. However when using the hyperref package this results in the section bookmarks pointing to the end of the previous section instead of the start of the new one.

Here is a MWE:

\documentclass{article}
\usepackage[pdftex]{hyperref} % Generate PDF links and bookmarks.
\hypersetup{
  bookmarks=true,
  bookmarksnumbered=true
}

\usepackage{titlesec}
\newcommand{\sectionbreak}{\clearpage}

\begin{document}
\section{First}
Some text

\section{Second}
More Text

\end{document}

If you use Adobe Reader or Preview on OSX and use the bookmarks you will notice that the second bookmark will be on the first page at the end of the previous section and not on the second page where the second section starts.

How can I fix this?

Best Answer

Switch the load order of hyperref and titlesec:

\usepackage{titlesec}% http://ctan.org/pkg/titlesec
\usepackage{hyperref}% http://ctan.org/pkg/hyperref

From the hyperref documentation (section 2 Implicit behavior):

This package can be used with more or less any normal LaTeX document by specifying in the document preamble

\usepackage{hyperref}

Make sure it comes last of your loaded packages, to give it a fighting chance of not being over-written, since its job is to redefine many LaTeX commands.

Packages that can be loaded after is given in Which packages should be loaded after hyperref instead of before?

Related Question