Hi,
I'm finishing writing a math book and I'm trying to generate a statistics report to include at the end of the preface. After some search, it seems that the appropriate package to use is the totcount, but since I'm using the input to include each chapter, the counter is not working, and I always get 0 as the number. Does anyone knows how to circumvent this problems?
General ⇒ totcount package
-
- Posts: 34
- Joined: Sat Aug 08, 2009 1:05 pm
totcount package
Please provide a
minimal working example to illustrate your problem. You have not shown what you have done so that others can troubleshoot. This will help you get the answers quickly.

OS: Debian/GNU Linux; LaTeX System : TeXLive; Editor : Vim
-
- Posts: 34
- Joined: Sat Aug 08, 2009 1:05 pm
totcount package
Here is a MWE
and now in the file preface I have the command
but the counter never starts, it's always 0. I guess there is a problem with the input.
Code: Select all
\documentclass{book}
\usepackage{amsmath,amsthm,amssymb}
\usepackage{totcount}
\newtheorem{thm}{Theorem}[section]
\regtotcounter{thm}
\begin{document}
\input{preface}
\input{chp1}
\input{chp2}
\end{document}
Code: Select all
\total{thm}
totcount package
It is better, but not complete. You do not mention where you are using the new theorem environment you have defined and the command you are using to get the total number of theorems.
The following code works. Try it and see if it helps in solving your problem:
The following code works. Try it and see if it helps in solving your problem:
Code: Select all
\documentclass{book}
\usepackage{amsmath,amsthm,amssymb}
\usepackage{totcount}
\newtheorem{thm}{Theorem}[section]
\regtotcounter{thm}
\begin{document}
\chapter{Preface}
This is a preface.
There are a total of \total{thm}~theorems in the book.
\chapter{Intro}
This is some sort of an introduction.
\begin{thm}
The theorem is blah blah \dots
\end{thm}
\begin{thm}
The theorem is blah blah \dots
\end{thm}
\chapter{Boring Details}
This is introduction.
\begin{thm}
The theorem is blah blah \dots
\end{thm}
\begin{thm}
The theorem is blah blah \dots
\end{thm}
\begin{thm}
The theorem is blah blah \dots
\end{thm}
\end{document}
OS: Debian/GNU Linux; LaTeX System : TeXLive; Editor : Vim
-
- Posts: 34
- Joined: Sat Aug 08, 2009 1:05 pm
totcount package
Thanks for the answer.
Unfortunately, my problem is that the content of the preface and the chapters are defined as files, they are not written between \begin{document} and \end{document}, they are called using \input, and I think this is the reason the counter is not working.
Unfortunately, my problem is that the content of the preface and the chapters are defined as files, they are not written between \begin{document} and \end{document}, they are called using \input, and I think this is the reason the counter is not working.
Re: totcount package
It does not matter where the content of your preface and chapters are. You can try moving the lines in my example to different files, put appropriate input statements and compile it twice or more times to get the cross-references correct.
OS: Debian/GNU Linux; LaTeX System : TeXLive; Editor : Vim