%% Example file for cntperchap.sty
%%
%% License: LaTeX Project Public License version 1.3 
%% Copyright (2015) Dr. Christian Hupfer 
%% Author: Christian Hupfer christian.hupfer@yahoo.de
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%%
%% This work has the LPPL maintenance status `maintained'.
%%
%% This work consists of all files listed in README
%%
%%%%


\documentclass[verbose]{scrbook}


\usepackage{tcolorbox}
\usepackage{cntperchap}

\usepackage{amsthm}
\usepackage{blindtext}
\usepackage{pgffor}



% Register the most important counters
\RegisterCounters{equation,figure,table,section,subsection,subsubsection,paragraph,subparagraph,enumi,enumii,enumiii,enumiv}

% generate the counter automatically by using 'autodefine=true' otherwise the registration would fail
% Define some theorem for using a non-standard-counter
\newtheorem{theorem}{theorem}

\newtheorem{lemma}{lemma}
\RegisterCounter{lemma}


% To show/number the lower levels too
\setcounter{secnumdepth}{5}

\begin{document}
\begin{tcolorbox}[title={Document statistics for demonstration},colbacktitle=red,coltitle=black]
There are \numberofstoredcounters\ counters tracked. 

  \Fullstatistics
\end{tcolorbox}

\tableofcontents
\listoffigures
\listoftables


\chapter{First}
\ShowStatistics[1]

\begin{enumerate}
\item Groucho
\item Zeppo
\item Harpo
\item Chico
\end{enumerate}

\begin{equation}
  c^2 = a^2 + b^2 
\end{equation}

but

\ShowStatistics[4]
\section{First}


\begin{enumerate}
\item This 
\item \begin{enumerate}
  \item is
    \begin{enumerate}
    \item a 
      \begin{enumerate}
      \item useless
      \end{enumerate}
    \end{enumerate}
  \end{enumerate}
\item List \theenumiv
\end{enumerate}




\begin{table}
\caption{faketable}
\caption{other faketable}

\end{table}
\section{Second}

\chapter{Second}
\ShowStatistics

\section{First}
\section{Second}
\section{Third}
\section{Fourth}



% Now a really large chapter
\chapter*{Third}
\ShowStatistics

\foreach \x in {1,...,5} {%
\section{Section \x~in chapter \thechapter}
}
\chapter{Fourth}
\ShowStatistics[3]

\begin{figure}
\caption{fake figure}
\caption{other fakefigure 1}
\caption{other fakefigure 2}
\caption{other fakefigure 3}
\caption{other fakefigure 4}

\end{figure}




\section*{A single section}

\begin{theorem}
\blindtext
\end{theorem}
\subsection{A small subsection}
\subsubsection{An even smaller subsubsection}

\foreach \x in {1,...,10} {%
\begin{equation}
  E = mc^2 
\end{equation}
}


\end{document}