6

I am using the titlesec package to change the section font to sans-serif. Unfortunately, this breaks the links to "unnumbered" sections both in the TOC and in the bookmarks sidebar of PDF readers. I am using the tocbibind package and the heading=bibintoc setting of biblatex to add both the bibliography and the list of figures to the TOC.

In the following example, only the link to "Section" works. Clicking on "List of Figures" jumps to the TOC instead, clicking on "References" jumps to "Section".

foo.tex

\documentclass{article}
\usepackage[sf,bf]{titlesec}
\usepackage[nottoc]{tocbibind}
\usepackage[backend=biber]{biblatex}
\usepackage{hyperref}

\addbibresource{foo.bib}

\begin{document}

\tableofcontents

\clearpage

\listoffigures

\clearpage

\section{Section}

\clearpage

\nocite{foo}

\printbibliography[heading=bibintoc]

\end{document}

foo.bib (only needed because biblatex otherwise complains about an empty bibliography)

@book{foo,
author = {foo},
title = {foo}
}

Any way to fix this?

  • 1
    Does a \phantomsection in front of \listoffigures resolve your problem? – Qrrbrbirlbel Sep 28 '12 at 14:15
8

It seems that there's a problem with titlesec; in this particular case, a possible solution is to use the sectsty package instead; this will produce the correct links without having to manually add \phantomsection (after all, that's part of the role of tocbibind):

\documentclass{article}
\usepackage{sectsty}
\usepackage[nottoc]{tocbibind}
\usepackage[backend=biber]{biblatex}
\usepackage{hyperref}

\allsectionsfont{\sffamily\bfseries}

\addbibresource{biblatex-examples.bib}

\begin{document}

\tableofcontents
\clearpage
\listoffigures
\clearpage
\section{Section}
\clearpage
\nocite{*}
\printbibliography[heading=bibintoc]

\end{document}
2

Add \phantomsection in front of \listoffigures and printbibliography:

\documentclass{article}
\usepackage[sf,bf]{titlesec}
\usepackage[nottoc]{tocbibind}
\usepackage[backend=biber]{biblatex}
\usepackage{hyperref}

\addbibresource{foo.bib}

\begin{document}
\tableofcontents\clearpage

\phantomsection
\listoffigures\clearpage

\section{Section}
\clearpage

\nocite{foo} \phantomsection
\printbibliography[heading=bibintoc]
\end{document}

hyperref manual states:

This sets an anchor at this location. It works similar to \hypertarget{}{} with an automatically chosen anchor name. Often it is used in conjunction with \addcontentsline for sectionlike things (index, bibliography, preface). \addcontentsline refers to the latest previous location where an anchor is set.

  • You should check that the link to the references, with your example, points to Section 1. Without titlesec all the links are correct without adding \phantomsection. – egreg Sep 28 '12 at 14:29

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.