when I use the command texcount filename.tex in CMD, half-spaced words count two words instead of one word. How can I solve this problem? \Thanks

% Compile with XeLaTeX
من می‌روم ز کوی تو و دل نمی‌رود

This example is 8 words, but latex counts it 10 words. Half-spaced used in می‌روم and نمی‌روم words. I have a lot of half-spaced words in different situation with another alphabet. Half space is U+200C (ZERO WIDTH NON-JOINER) or in Persian standard keyboard is Shift + Space.

Yas font link

1 Answer 1


There is a simple, but not very elegant, quick-fix for this. It requires modifying the TeXcount Perl script.

There is a line in the code of texcount.pl which defines the pattern for words.


In version 3.1 it is at line 496, but should be the same line in all fairly recent versions of TeXcount. It's essentially a regular expression, but where @ is later to be replaced by a regular expression matching letters. Essentially, it says that a word is a sequence of letters, but where the characters -, ', and . may be contained within it.

To add Unicode character U+200C to the list of characters permitted within a word, this line may be changed to


where \x{200C} has been inserted. Admittedly, this is not a very elegant solution, and there may be other characters that should also be permitted within words.

A better solution could involve using Unicode character classes to identify separator characters that should be permitted within words, but I'm not sure what would be an appropriate rule: this would likely impact other languages with similar characters as well, which might give either a desired or undesired effect.

You must log in to answer this question.

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