TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to put the statistic data of my book in a certain page right after the title page but before "This book is presented to my kittens..." page.

The statistic data includes:

  1. The total number of words used from chapter 0 to appendixes.
  2. The total number of sentences used from chapter 0 to appendixes.
  3. The total number of characters used from chapter 0 to appendixes.
  4. The total number of pages from chapter 0 to appendixes.
share|improve this question
Why?........... – Matthew Leingang Dec 26 '10 at 2:17
Because the number of pages does not reflect the density of words used in the book. By knowing the density of words, the reader can make a rough prediction of the time needed to read the book. – xport Dec 26 '10 at 2:23
nltk.org – Yiannis Lazarides Dec 26 '10 at 2:57
If you have math in the book, this complicates the count; I suggest you throw in the number of inline and displayed equations as well. Counting words in the source is of course not so easy with macros interfering, though if they could all be expanded you could just count the number of spaces (ignoring repeats, outside math) and add 1. Sentences would be harder to detect, since you have to ignore abbreviations; this seems like a good candidate for an NLTK like Yiannis suggests. – Ryan Reich Dec 26 '10 at 8:14
For word counts see also this post. – Hendrik Vogt Dec 28 '10 at 12:13
up vote 1 down vote accepted

There is a useful LaTeX word count Perl script to count words and the number of formulas. The seems to be an alpha version of it that also counts letters. Create a separate master file for texcount that only includes the main text. You could probably get a good estimate of the number of sentences by counting the number of ., ? and ! in your TeX files. Counting the number of pages should be easy (the book class starts numbering pages from \mainmatter).

share|improve this answer

Personally, I'd go with something simple like pdftotext and then just use wc (or any standard utility) to get approximate answers. If you need exact answers, it's going to be significantly harder (and unlikely to be worth your trouble).

share|improve this answer
This won't do well, since pdftex typesets the text and thus breaks words at the end of lines whenever appropriate. – walkmanyi Oct 8 '12 at 20:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.