Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am using texcount to count the words in my LaTeX document, but I have quite a lot of text in tables and want to count those too.

Is there any way to do this using texcount? There doesn't seem to be a simple command-line switch, and the documentation for the macros section seems rather confusing.

share|improve this question

1 Answer 1

up vote 10 down vote accepted

You can tell texcount to treat the content of tabular environments like normal text by including the line %TC:group tabular 1 1 in your preamble. The %TC: tells the parser that a textcount instruction follows, group indicates that the instruction concerns an environment that starts with \begin{...} and ends with \end{...}, tabular is the name of the environment we're specifying, the first number defines how many arguments are to be ignored (in this case 1, the column specifications), and the second number defines what to do with the content of the environment (1 tells the parser to count the text).

Parsing the following document using the perl script or the online interface

%TC:group tabular 1 1
One two & three four five six\\
Seven eight, nine & ten eleven!\\
Twelve. Thirteen.


Words in text: 13

Alternatively, you can edit texcount.pl and change the instruction 'tabular'=>0 in the definition of my %TeXgroup to 'tabular'=>1.

If you don't want to edit your TeX file or texcount.pl, you can create a new text file called, say, TCoptions.txt containing the line %group tabular 1 1 (not %TC:group tabular 1 1) and instruct texcount.pl to take its options from that file by calling texcount.pl -opt=TCoptions.txt <TeX file>

share|improve this answer
Amazing! I had no idea about these flags for texcount. –  qubyte Dec 10 '11 at 7:18
If the tabular is inside a table, then words won't be counted; adding %TC:group table 0 1 overrides this default behavior. –  egreg Dec 10 '11 at 10:11

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.