I need so setup TeXcount to count the characters of a LaTeX document including those in food and end notes but without those in references, tables, figures, captions, and the titlepage. Better would be if also characters of appendices I specify would be included but that's not important.

I am going to put the output from TeXcount in a file to be input to the title page and I would like the reader to be able to see how the number is calculated. So ideally the contents would look something like

This document contains   4571 characters
(bread text:             4120
equations:                250
food notes:               201)

(formatted in LaTeX but that's no problem).

I have tried to figure out from the TeXcount manual how to do it but I don't quite understand. And now I am in a bit of a hurry.

So please, can anybody help with an approach of a template and a command line?

Thanks in advance,


1 Answer 1


I'll just give a quick response off the top of my head, and then maybe elaborate on it later when I have some more time...and have my new computer set up so I can actually run it. Besides, there seems to be several questions at the same time, so I might be addressing the wrong ones.

To count characters instead of words, you may use the option -char or -letter when running TeXcount. Note that, by default, spaces and punctuation are not counted. You can include punctuation amongst the counted characters by using the option


where Digit,alphabetic is the default option. However, there's no way for TeXcount to actually count spaces, although you can get a rough estimate of the number of spaces from the number of words, assuming there is one space per word.

TeXcount still counts the number of equations, not the number of characters in the equations: perhaps not what you want. There's nothing that can easily be done about that in TeXcount.

As for grouping the counts into categories, TeXcount has some predefined rules: words/characters in main text, in titles, etc. as well as number of equations, floats. If these rules do not give to desired grouping, you'll need to define new macro handling rules for macros/environments you'd like to count differently; you can also define new counters in addition to the predefined ones. However, for now, I'll let that issue be.

What seems closest to the three groups in your example is words/letters in text, number of equations (which is divided into inline and displayed equations), and other words/letters which include footnotes but also captions. The names TeXcount use for these four are text/word, inline/eq, displaymath/dsmath/ds, and other/otherword.

As for templates for formatting the output, you might want to take a peek at a similar question: Using Texcount Templates

The simplest template could be to run TeXcount with options


which will write an output like


where the sum has been defined as text+other+eq+ds (the four counters that have been given coefficients 1 in the -sum option).

I'm not sure, but you may have to use the option -tex since the template contains special TeX characters.

It might be more convenient to define the template in the document using the %TC:template instructions (which TeX ignores as comments but TeXcount parses), or using a template file in which you can also specify the -sum option.

When I get my TeX/TeXcount environment set up again, I might be able to help you out better: as of now, I'm not able to actually make a test example.

  • Thanks a lot. Also for pointing out that TeXcount doesn't count spaces and punctuation which I thought it did and need too. So for now I'll have to count by hand after converting the .pdf to text format. Once again and now in Danish: Mange tak, Einar. Dec 12, 2016 at 6:18
  • @ChristianMartinJäger: For the record, I recalled that punctuation could actually be counted, and have added this to the answer. The number of words can serve as an estimate for the number of spaces. However, TeXcount might also run into additional problems with the references which are by default not counted (and hard to count accurately using TeXcount). So, I guess it will still be easier for you to do a count based on the PDF text. Dec 12, 2016 at 20:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .