[Tex/LaTex] tocloft, listoffigures, listof=totoc, KOMA: not in tableofcontents

koma-scripttable of contentstocloft

This MWE illustrate the problem:

\documentclass[listof=totoc]{scrreprt}
%\usepackage{tocloft}
\begin{document}
\tableofcontents
\listoffigures
\chapter{test}
\begin{figure}
\caption{test}
\end{figure}
\end{document}

without the package tocloft the listoffigures will be included in the tableofcontents but with tocloft, the "List of Figures" is not in "Contents". What can I do to have the listoffigures in tableofcontents?

Best Answer

Here is an idea based on this answer:

\documentclass{scrreprt}

\usepackage{tocloft}

\makeatletter
\newcommand\mytoc{%
    \tableofcontents
    \section*{Figures}%
    \@starttoc{lof}%
    \bigskip
    \section*{Tables}%
    \@starttoc{lot}}
\makeatother

\begin{document}

\mytoc

\chapter{Chapter 1}

\section{Section 1}
\begin{figure}
\caption{testfig 1}
\end{figure}

\chapter{Chapter 2}

\begin{table}
\caption{testtable}
\end{table}

\begin{figure}
\caption{testfig 2}
\end{figure}

\end{document}

This gives me the following output:

Output with the above code

Is this what you wanted?