I have modified the formatting of subsections in the toc, so that they appear in one line instead of separate lines. For this i used the titletoc package. Here is a MWE:
\documentclass{scrbook}
\usepackage{titletoc}
\titlecontents*{subsection}%
[3.8em]%
{\small\itshape}%
{\hyperlink{subsection.\thecontentslabel}{\thecontentslabel}\ }%
{}%
{\ \thecontentspage}%
[,\ ]%
[.]%
\usepackage[colorlinks=true,linktoc=all]{hyperref}
\begin{document}
\tableofcontents
\chapter{Chapter}
\section{Section}
\subsection{Subsection}
\subsection{Another Subsection}
\clearpage
\section{Another Section}
\end{document}
This was very easy, but there are two problems:
- The subsection label is not included in the link. This is already fixed in the MWE with the help of the answer to this question: Common style for global TOC, LOF, LOT and titletoc partial TOCs (with hyperref & caption)
- The link to the section following the modified subsections points to the wrong location. In the MWE the link of '1.2 Another Section' points to '1.1.1 Subsection'.
I have not found a solution to the second problem. I have experimented with \phantomsection
without any success. I have read here that titletoc has some incompatibilities with hyperref and tried to implement the same behavior with the tocloft package. I managed to get something similar, but not quite right. The tocloft approach seems to be so much more convenient, if the links would work properly.
On a sidenote: The document i want to apply this to is rather large and is typeset with the classicthesis style.
I would appreciate any tips or solutions to this problem.
scrbase 2012/05/15 v3.11 KOMA-Script package
andtitletoc 1.6
. Your code is working like a charm without any problem or wrong linking.titletoc
really sets a\hypertarget
command at all in the corresponding sections, subsections etc.titletoc
and the KOMA classes