Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
1  
Does a \phantomsection in front of \listoffigures resolve your problem? –  Qrrbrbirlbel Sep 28 '12 at 14:15
    
It does, thanks! –  WakiMiko Sep 28 '12 at 14:19
add comment

2 Answers 2

up vote 5 down vote accepted

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}
share|improve this answer
    
That is even better, thanks! –  WakiMiko Sep 28 '12 at 15:03
add comment

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.

share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.