What TeXcount does

TeXcount may be run on one or more TeX/LaTeX files, although the online service only takes one file at a time. Elements counted separately are:

It will also produce subcounts per section; if several files are given, or included in the LaTeX code (requires -inc), subcounts per file will also be given.

By using options -v1, -v2, -v3 or -v4 (option -v being -v3), the LaTeX code will be output using colour and style codes to display how the document has been interpreted at different levels of detail: return text words and mark formulae, include ignored text and macros, include comments and macro options, or include internal state at the beginning of every parsed unit (word or group). The ANSI colour codes may not work under Windows: instead, output details in HTML format using the -html option, and view this with a browser.

TeXcount has rules for handling a number of macros and begin-end groups. These rules specify how parameters (\macro{...}) are interpreded. Macro options (\macro[...]) are ignored. Some begin-end groups have been defined to be floats (not counted as text) or mathematics, others are defined to contain ordinary text to be counted.

In addition to precoded macro handling rules, you can add your own: either by leaving instructions for TeXcount in your LateX code (%TC:...) or by adding them to the Perl script.

Be aware that TeXcount has some limitations. First, the LaTeX document need to be a syntactically valid LaTeX document, otherwise TeXcount may get very confused. Also, TeXcount relies on a set of macro handling rules that assume that macros take a given set of {}-enclosed parameters; these also allow []-enclosed options so long as these are not too long and take values that "look like option values". Macros that do not fit this format generally cannot be expected to be handled correctly. Check the detailed output to make sure TeXcount has done the right thing!


Last modified January 29, 2017.