For a relatively short report I would like to merge the list of figures (LoF) into the document's table of contents. In two related questions, Gonzalo Medina has suggested to just change the file extension LaTeX uses for the LoF, so that entries for figures end up in jobname.toc
:
- Figures: Can the list of figures be embedded into the table of contents?
- How to embed figure short descriptions (as would be displayed in the List of Figures) within the table of contents in LaTeX?
However, if this approach is used in conjunction with hyperref
(to get a PDF ToC), the figure entries end up on chapter level (level 0) in the PDF ToC – with the effect, that the figure becomes the father of all following section or subsection entries:
\documentclass{scrartcl}
\usepackage{tocloft}
\usepackage{subfig}
\usepackage{hyperref}
\makeatletter
\renewcommand\ext@figure{toc}
\makeatother
\newlength\mylen
\renewcommand\cftfigpresnum{Figure~}
\settowidth\mylen{\bfseries\cftfigpresnum\cftfigaftersnum}
\addtolength\cftfignumwidth{\mylen}
\begin{document}
\tableofcontents
\section{Test Section One}
Text
\subsection{Subsection One.1}
\begin{figure}[!ht]
A
\caption{test figure}
\end{figure}
\subsection{Subsection One.2}
Text
\section{Test Section Two}
\begin{figure}[!ht]
A
\caption{another test figure}
\end{figure}
\begin{figure}[!ht]
\subfloat[][A subfigure]{A}
\subfloat[][A subfigure]{B}
\caption{test figure with subfigures}
\end{figure}
\subsection{Subsection Two.1}
Text
\end{document}
The following screenshot shows the problem: In the PDF ToC (left side), Subsection One.2 and even Test Section Two are nested below the entry for test figure. Moreover, the figures are missing the Figure <#> prefix:
Questions:
- How do I get the figure entries to appear on subsection level inside the PDF ToC?
- How to add the Figure <#> prefix to the PDF ToC entries?