During my last experiences with cross-referencing on total counts between different files, a problem of counting of chapters and appendices appears.
As a MWE we can use a MWE given here with some modifications.
It happens that a simple command like \setcounter{truechapters}{\value{totalchapters}-\value{chapter}} does not work.
I guess, that the reason is in a wrong using of these values.
The question is how to get three counts (total chapters, appendices and true chapters) in one pdf in a simple and reasonable way?
Note, please, also that I cannot use \zlabel like it is described by Heiko here
Here is my MWE:
MyBook.tex:
\documentclass{memoir}
\usepackage{totcount}
\usepackage{assoccnt}
\newtotcounter{totalchapters}
\DeclareAssociatedCounters{chapter}{totalchapters} % Associate the driven counter `totalchapters` to the master counter `chapter`
\AtBeginDocument{
%% register a counter on the basis of the last chapter in totcounter
\regtotcounter{chapter}
}
\newcounter{truechapters}
\begin{document}
\chapter{A}
\chapter{B}
\appendix
\chapter{C}
\chapter{D}
\chapter{E}
\chapter{F}
\chapter{G}
\chapter{H}
\chapter{I}
There are \total{totalchapters} total chapters.
There are \total{chapter} appendix chapters.
%here we need to count the difference of two previous counters
%\setcounter{truechapters}{\value{totalchapters}-\value{chapter}}
There are \thetruechapters \: true chapters.
\end{document}
A screenshot of MyBook.pdf is below:



xassoccnt. I won't updateassoccnt– Apr 15 '17 at 16:46