# Float numbering does not include chapter when using \DeclareNewTOC

I use the \DeclareNewTOC command from the KOMA classes because it automatically produces hanging indents for the caption, same as the builtin floating environments like figure. However, unlike figure, the number of my newly defined float does not include the chapter number. The level option that is mentioned in the KOMA manual does not seem to do anything.

How can I fix it to show e.g. 1.1? Alternative solutions that produce the same result are also welcome.

\documentclass[paper=A6]{scrreprt}
\DeclareNewTOC[
float, type=floatlisting, types=floatlistings,
%level=2, % Doesn't do anything
name=Listing, listname={List of Listings}
]{lol}

\begin{document}
\chapter{Topic}
\begin{floatlisting}[h]
Foo
\caption{Some really long caption that leads to a line break.}
\end{floatlisting}
\begin{figure}[h]
Foo
\caption{Some really long caption that leads to a line break.}
\end{figure}
\end{document}

• btw: package listings has it's own implementation of captions. Sep 9 '14 at 16:06
• Yes, you are right of course. But when using the [float,caption=Foo] options on the lstlisting environment, I can't center the code (see this question: tex.stackexchange.com/questions/5818/how-to-center-a-listing ). Sep 9 '14 at 16:26

Use the option counterwithin=chapter.

\documentclass[paper=A6]{scrreprt}
\DeclareNewTOC[
float, type=floatlisting, types=floatlistings,
counterwithin=chapter,%<-%%%%%%%%%%%%%%%%%%%%
name=Listing, listname={List of Listings}
]{lol}

\begin{document}
\chapter{Topic}
\begin{floatlisting}[h]
Foo
\caption{Some really long caption that leads to a
line break.}
\end{floatlisting}
\begin{figure}[h]
Foo
\caption{Some really long caption that leads to a
line break.}
\end{figure}
\end{document}

• Thanks. I don't really know how I did miss that in the manual... -.- Sep 9 '14 at 16:29
• Of by the way, the key is called counterwithin, not counterwith. I see that it is correct in the code but not in the opening text. Sep 9 '14 at 16:30
• @Fritz I was in a hurry, thanks for fixing this. Sep 9 '14 at 19:32