%% LaTeX package xassoccnt - version 2.0 (2021/11/21 -- 12:14:58)
%% Driver file for xassoccnt.sty
%%
%%
%% -------------------------------------------------------------------------------------------
%% Copyright (c) 2015 -- 2021 by Dr. Christian Hupfer <>
%% -------------------------------------------------------------------------------------------
%%
%% 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 `unmaintained`
%%
%%

\documentclass{book}

\usepackage{xcolor}
\usepackage{totcount}
\usepackage{calc}
\usepackage[autodefinecounters=false]{xassoccnt}


\usepackage{hyperref}
\usepackage{cleveref}


\newcounter{newtotalpages}
\newtotcounter{totalsections}
\newcounter{othersections}
\newtotcounter{totaltables}

\NewTotalDocumentCounter{equations}

\DeclareAssociatedCounters[autodefine=none]{section}{totalsections,othersections,equations}
\AddAssociatedCounters{section}{totalsections}


\DeclareAssociatedCounters{page}{newtotalpages}
\DeclareAssociatedCounters{table}{totaltables}


\begin{document}
\chapter{First}

In \cref{section::dummylabel} we will see that

\section{First}

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


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


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



\section{Other}
\section{Third}

\begin{table}
\caption{Other table}
\end{table}

\begin{equation}
  E=mc^2
\end{equation}

\begin{equation}
  E=mc^2
\end{equation}


\TotalValue{equations}

\chapter{Second chapter}

\section{First section of 2nd chapter} \label{section::dummylabel}

\thesection\ \total{totalsections}\ \theothersections\ \fbox{\color{blue}{\thetotaltables}}


\IsSuspendedCounter{totalsections}{Yes, it's suspended}{Nope, it's not suspended}

\IsAssociatedCounter{totalsections}{Yes, it's associated}{Nope, it's not associated}

\IsSuspendedCounter{equation}{Yes, it's suspended}{Nope, it's not suspended}

\IsAssociatedCounter{equation}{Yes, it's associated}{Nope, it's not associated}


\TotalValue{equations}



\TotalValue{equations}


\SetDocumentCounter{section}{28}

\SetDocumentCounter{totalsections}{100}

\NewDocumentCounter[initial=151]{counterother}[section]



Value of counterother: \thecounterother

\section{Another one}

Value of counterother: \thecounterother





\thesection\ \thetotalsections\ \theothersections\ \fbox{\color{blue}{\thetotaltables}}\ 

\SyncCounters[onlycounters={totalsections}]{section}


\IfIsDocumentCounterTF{section}{%
  Yes, it's a counter
}{%
  No, it's no counter
}


\IsSuperTotalCounterT{numberofruns}{%
  Yes, numberofruns is a super total counter
}

\IsSuperTotalCounterF{chapter}{%
  No, chapter is not a super total counter
}


\countersresetlistcount{chapter}
\SetDocumentCounter{counterother}{\getresetlistcount}

\begin{itemize}
  \item There are \getresetlistcount\  counters in the reset list of chapter
  \item \IfInResetListTF{chapter}{figure}{Yes, figure is in the reset list of chapter}{No, figure is not in the reset list of chapter}
  \item \IfInResetListTF{chapter}{page}{Yes, page is in the reset list of chapter}{No, page is not in the reset list of chapter}
  \item Values: \thesection\ \total{totalsections}\ \theothersections\ \fbox{\color{blue}{\total{totaltables}}}\ \thecounterother. 
\end{itemize}

Total value of equations: \TotalValue{equations}

Internal name: \TotalCounterInternalName{equations}

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


%\stepcounter{equations}


\chapter{Another chapter}

\PrettyPrintCounterName{countertype=general}{equation}
\PrettyPrintCounterName{countertype=driver}{chapter}
\PrettyPrintCounterName{countertype=associated}{totalsections}
\PrettyPrintCounterName{countertype=total}{equations}



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



\chapter{A new chapter}

\begin{equation}
  E=mc^2
\end{equation}

\chapter{Another new chapter}

\begin{equation}
  E=mc^2
\end{equation}




\end{document}