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
add comment

1 Answer

up vote 10 down vote accepted
+50

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

\documentclass{article}
%TC:group tabular 1 1
\begin{document}
\begin{tabular}{cc}
One two & three four five six\\
Seven eight, nine & ten eleven!\\
Twelve. Thirteen.
\end{tabular}
\end{document}

returns

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
2  
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
add comment

Your Answer

 
discard

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.