Is there any way to do a correct word count of a LaTeX document?

This is in the UK TeX FAQ. The solutions suggested are:

  • detex filename (which tries to strip LaTeX commands), then use any word count tool. (e.g. wc)

  • latexcount.pl, a Perl script for word count

  • texcount, another script even has an online interface

  • wordcount, which has a script that runs LaTeX with some settings, then counts word indications in the log file.


The Texmaker integrated pdf viewer offers a word count feature since version 3.4.
Just right-click in the pdf document, then click Number of words in the document.

enter image description here


Here’s an excerpt from my .vimrc that gives me a comfortable word count in Vim:

function! WC()
    let filename = expand("%")
    let cmd = "detex " . filename . " | wc -w | tr -d [:space:]"
    let result = system(cmd)
    echo result . " words"
endfunction

command WC call WC()

Now I can invoke :WC in command mode to have the word count echoed in the status line.