Generaltotcount package

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
melekzedek
Posts: 34
Joined: Sat Aug 08, 2009 1:05 pm

totcount package

Post by melekzedek »

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?
Using Ubuntu 13.10 under the hood and LaTeXing via Vim-LaTeX
ウンベルト

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
mas
Posts: 226
Joined: Thu Dec 04, 2008 4:39 am

totcount package

Post by mas »

Please provide a Infominimal 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
melekzedek
Posts: 34
Joined: Sat Aug 08, 2009 1:05 pm

totcount package

Post by melekzedek »

Here is a MWE

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}
and now in the file preface I have the command

Code: Select all

\total{thm}
but the counter never starts, it's always 0. I guess there is a problem with the input.
Using Ubuntu 13.10 under the hood and LaTeXing via Vim-LaTeX
ウンベルト
mas
Posts: 226
Joined: Thu Dec 04, 2008 4:39 am

totcount package

Post by mas »

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:

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
melekzedek
Posts: 34
Joined: Sat Aug 08, 2009 1:05 pm

totcount package

Post by melekzedek »

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.
Using Ubuntu 13.10 under the hood and LaTeXing via Vim-LaTeX
ウンベルト
mas
Posts: 226
Joined: Thu Dec 04, 2008 4:39 am

Re: totcount package

Post by mas »

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
Post Reply